IDA 允许使用N快捷方式重命名程序实体(例如寄存器、变量、函数)。是否可以在 IDA 中获取此类用户定义名称的列表?
是否可以在 IDA 中获取用户定义名称的列表?
逆向工程
艾达
蟒蛇
Python
2021-06-10 00:46:34
3个回答
idautils.Names您可能会对这个函数感兴趣,因为它返回(ea, name)IDB 中定义的所有名称的元组列表以及它们所在的 ea。
此外,您可以使用 Igor 链接问题的答案(使用 IDA python 获取全局变量列表)来获取所有函数的列表。
获得eas 后,您可以执行以下操作来确定函数或 ea 是否由用户命名:
def is_user_name(ea):
f = idc.GetFlags(ea)
return idc.hasUserName(f)
如果 EA 的名称由用户以编程方式或手动方式设置,则此函数将返回 true。
您可以使用 View->Open subview->Names 或Shift-F4. 请注意,该列表包括所有名称,包括用户定义的名称以及 IDA 生成的名称(例如 ASCII 字符串名称)。
另请参阅相关使用 IDA python 获取全局变量列表
运行此 .idc 脚本以导出所有用户定义的函数名称。在 IDA 7.0 上测试的脚本。
对于 IDA < 7.0:请使用函数hasUserName(addr)而不是has_user_name(addr)
#include <idc.idc>
static FuncDump(start)
{
auto ea, str, count, ref;
auto end;
auto teststr;
ea = start;
while( ea != BADADDR )
{
str = GetFunctionName(ea);
if( str != 0 )
{
end = FindFuncEnd(ea);
count = 0;
ref = RfirstB(ea);
while(ref != BADADDR)
{
count = count + 1;
ref = RnextB(ea, ref);
}
teststr = sprintf("sub_%X", ea);
if(has_user_name(GetFlags(ea)) && !((GetFunctionFlags(ea) & FUNC_LIB) == FUNC_LIB) && teststr != str ) {
Message("-s 0x%X=%s\n", ea, str );
}
//Message("%s, 0x%d, 0x%x, 0x%x, 0x%x, %d\n", str, count, ea, end, end-ea, end-ea );
}
ea = NextFunction(ea);
}
}
static main()
{
Message("FuncDump: Start\n");
FuncDump(0x40000);
Message("FuncDump: Done\n");
}
其它你可能感兴趣的问题