Repository navigation
[Generator] IDA Symbolic Script From Symbol File
高级页面仔 edited this page Aug 15, 2020
·
3 revisions
Generate an IDA Symbolic Script from symbol file.
iblessing 0.2.6 and above.
First, you need to generate a symbol file from jtool2 or other tools, let's take xnu kernel as an example:
> JTOOLDIR=. jtool2 --analyze ../kernelcache.dec
> head kernelcache.dec.ARM64
0x1|_nstat_control_disconnect|
0x17fff007fb668c|_exec_mach_imgact|
0x17fff007fb8a28|_exec_fat_imgact|
0x17fff007fb8cc0|_exec_shell_imgact|
0x57fff009235f00|_kmod|
0x107fff009216940|_pmap_object_store|
0xfffffff007004001||
0xfffffff00700d4e0|vm_min_kernel_address|
0xfffffff00700d4e8|vm_max_kernel_address|
0xfffffff00700e2e0|_getattrlist_common_tab|
Then, we can use iblessing to generate an IDA Script to import them to IDA, there are three extra-args:
- delimiter: separator between symbol infos within a line
- addrIdx: each line will be divided into an array by the delimiter, addrIdx represents the index of the address in the array
- nameIdx: similar to addrIdx, but it represents the index of symbol name in the array
> iblessing -m generator -i ida-symbolic -f kernelcache.dec.ARM64 -d 'delimiter=|;addrIdx=0;nameIdx=1'
[*] set output path to /Users/soulghost/Desktop/git/iblessing
[*] input file is ~/kernelcache.dec.ARM64
[*] start IDASymbolicScriptGenerator
[+] using delimiter=|, addrIdx=0, nameIdx=1
[*] saved to ~/kernelcache.dec.ARM64_ida_symbolic.py
> head -n 20
# -*- coding: utf-8 -*-
# Powered by iblessing (https://github.com/Soulghost/iblessing)
import idc
def ib_setname(addr, name):
orig_name = ida_name.get_name(addr)
if len(orig_name) == 0 or orig_name.startswith('sub_'):
idc.create_insn(addr)
ida_funcs.add_func(addr)
idc.set_name(addr, name, idc.SN_NOWARN)
def ib_symbolic():
ib_setname(0x1,"_nstat_control_disconnect")
ib_setname(0x17fff007fb668c,"_exec_mach_imgact")
ib_setname(0x17fff007fb8a28,"_exec_fat_imgact")
ib_setname(0x17fff007fb8cc0,"_exec_shell_imgact")
ib_setname(0x57fff009235f00,"_kmod")
ib_setname(0x107fff009216940,"_pmap_object_store")
Finally, let IDA run this script.
You can replace the above three parameters by specifying 'mode=jtool2' for symbol files generated by jtool2:
> iblessing -m generator -i ida-symbolic -f kernelcache.dec.ARM64 -d 'mode=jtool2'