我目前正在反转一些 C++ 二进制文件(macOS 内核扩展)。
但是,有很多vtable函数,所以我想使用IDAPython制作一些vtable结构。
我知道如何自己制作结构,但我不知道如何在以下情况下获得符号。
UNDEF:0000000000003E60 ; IORegistryEntry::compareName(OSString *, OSString **)const
UNDEF:0000000000003E60 extrn __ZNK15IORegistryEntry11compareNameEP8OSStringPS1_:qword
UNDEF:0000000000003E60 ; DATA XREF: __const:0000000000002410↑o
UNDEF:0000000000003E60 ; __const:0000000000002F40↑o
UNDEF:0000000000003E68 ; IORegistryEntry::getLocation(IORegistryPlane const*)const
UNDEF:0000000000003E68 extrn __ZNK15IORegistryEntry11getLocationEPK15IORegistryPlane:qword
UNDEF:0000000000003E68 ; DATA XREF: __const:0000000000002428↑o
UNDEF:0000000000003E68 ; __const:0000000000002F58↑o
UNDEF:0000000000003E70 ; IORegistryEntry::getProperty(OSString const*)const
UNDEF:0000000000003E70 extrn __ZNK15IORegistryEntry11getPropertyEPK8OSString:qword
UNDEF:0000000000003E70 ; DATA XREF: __const:0000000000002320↑o
UNDEF:0000000000003E70 ; __const:0000000000002E50↑o
UNDEF:0000000000003E78 ; IORegistryEntry::getProperty(OSString const*, IORegistryPlane const*, unsigned int)const
UNDEF:0000000000003E78 extrn __ZNK15IORegistryEntry11getPropertyEPK8OSStringPK15IORegistryPlanej:qword
UNDEF:0000000000003E78 ; DATA XREF: __const:0000000000002338↑o
UNDEF:0000000000003E78 ; __const:0000000000002E68↑o
UNDEF:0000000000003E80 ; IORegistryEntry::getProperty(OSSymbol const*)const
UNDEF:0000000000003E80 extrn __ZNK15IORegistryEntry11getPropertyEPK8OSSymbol:qword
UNDEF:0000000000003E80 ; DATA XREF: __const:0000000000002318↑o
UNDEF:0000000000003E80 ; __const:0000000000002E48↑o
UNDEF:0000000000003E88 ; IORegistryEntry::getProperty(OSSymbol const*, IORegistryPlane const*, unsigned int)const
UNDEF:0000000000003E88 extrn __ZNK15IORegistryEntry11getPropertyEPK8OSSymbolPK15IORegistryPlanej:qword
UNDEF:0000000000003E88 ; DATA XREF: __const:0000000000002330↑o
UNDEF:0000000000003E88 ; __const:0000000000002E60↑o
UNDEF:0000000000003E90 ; IORegistryEntry::getProperty(char const*)const
UNDEF:0000000000003E90 extrn __ZNK15IORegistryEntry11getPropertyEPKc:qword
UNDEF:0000000000003E90 ; DATA XREF: __const:0000000000002328↑o
UNDEF:0000000000003E90 ; __const:0000000000002E58↑o
...
我想得到上面的符号名称。
我尝试使用 idc.GetFunctionName 和 idautils.Functions(),我无法完全获取符号名称。结果如下。
Python>import idautils
Python>for func in idautils.Functions():
Python> print(hex(func), idc.GetFunctionName(func))
...
('0x3950L', '__ZN15OSMetaClassBase12safeMetaCastEPKS_PK11OSMetaClass')
('0x3a08L', '__ZN8OSObjectdlEPvm')
('0x3a10L', '__ZN8OSObjectnwEm')
('0x3e00L', '__ZN9IOServiceC2EPK11OSMetaClass')
('0x3e08L', '__ZN9IOServiceD2Ev')
('0x3e38L', '__ZNK11OSMetaClass19instanceConstructedEv')
('0x3fb0L', '__ZNK9IOService10isInactiveEv')
有什么获得符号的好方法吗?