我想用 Ida python 找到 2 个连续的指令
move r2,r3 ; move r2 r4
使用 Ida python 查找地址的简单方法是什么?
我可以Functions遍历所有函数并为每个函数进行分解idc.GetDisasm,然后查找值,但这需要很多时间。
有没有更聪明更快捷的方法?
我想用 Ida python 找到 2 个连续的指令
move r2,r3 ; move r2 r4
使用 Ida python 查找地址的简单方法是什么?
我可以Functions遍历所有函数并为每个函数进行分解idc.GetDisasm,然后查找值,但这需要很多时间。
有没有更聪明更快捷的方法?
您可以使用模块ida_search 和函数 find_binary。如果我理解正确的话,论点是
首先,您应该找到表示所需指令的二进制文件(您可以通过在可执行文件中进行文本搜索或为您的体系结构组装它),然后将其用作参数。
您可以在 github 上找到大量有关此函数用法的示例以供参考。
如果要进行文本搜索,可以find_text在ida_search模块中使用。不过,使用更智能的搜索方法可能会更好。我个人会做的是用来ida_ua::decode_insn生成一个insn_t对象,将其itype成员与move指令的平台特定常量进行比较,然后检查寄存器编号以确保它们与我想要的匹配。像这样的东西:
# Decode instruction at ea
ins = ida_ua.insn_t()
if ida_ua.decode_insn(ins,ea) == 0:
print("%#x: could not disassemble?" % ea)
return False
# Check to see if it's the "movl" instruction
if ins.itype != ida_allins.ARM_movl:
return False
# Is the first operand a register, internal register number 2?
if ins.op[0].type != ida_ua.o_reg:
return False
# Or whatever the register number for r2 is, might not be 2
if ins.op[0].reg != 2:
return False
# Is the first operand a register, internal register number 3?
if ins.op[1].type != ida_ua.o_reg:
return False
# Or whatever the register number for r3 is, might not be 3
if ins.op[1].reg != 3:
return False
print("%#x: found movl r2, r3" % ea)