\python\3\ 下面可以找到所有的 python 封装的 py
idaapi:所有的 api
idautils: 较高层的 idapython 封装
idautils.cpu 可以取得寄存器对象,
print(f"EAX:{idautils.cpu.eax:x}")
idautils.cpu.eax = 0xffffff
暴力 make code
import idaapi
for i in range(0, 0x100000):
idaapi.auto_make_code(i)
makecode in ida7
idaapi.create_insn(ea)
disable auto analysis
ida_ida.inf_set_auto_enabled(False)
here()
清除 log 消息
idaapi.msg_clear()
in ida_bytes bytes.hpp
is_code()
is_unknown()
...
ida app call
idc 可以直接调用 c 语言函数
函数需要有函数原型,不然需要 add local type
使用 enum 也同理
extern a;
申明变量
直接 console 输入结构体名,可以打印详细信息
apply_type 函数可以为函数定义原型
idc 脚本
static main(){dbg_appcall(LocByName("name"),args);
}
idc.here() 可以获得光标所在的偏移。
idc.GetDisasm 可以获得和反汇编器一样的输出,包括重命名以及注释
idc.print_operand 可以打印出 oprand
推荐使用 decode instruction, 在 idautils
idautils.DecodeInstruction(ea)
dt type 代表大小
itype 代表类型
insn.itype == ida_allins.ARM_XXX
const optype_t
o_void = 0, ///< No Operand.
o_reg = 1, ///< General Register (al,ax,es,ds...).
o_mem = 2, ///< Direct Memory Reference (DATA).
o_phrase = 3, ///< Memory Ref [Base Reg + Index Reg].
o_displ = 4, ///< Memory Ref [Base Reg + Index Reg + Displacement].
o_imm = 5, ///< Immediate Value.
o_far = 6, ///< Immediate Far Address (CODE).
o_near = 7, ///< Immediate Near Address (CODE).
o_idpspec0 = 8, ///< processor specific type.
o_idpspec1 = 9, ///< processor specific type.
o_idpspec2 = 10, ///< processor specific type.
o_idpspec3 = 11, ///< processor specific type.
o_idpspec4 = 12, ///< processor specific type.
o_idpspec5 = 13;
开发指南
https://github.com/allthingsida/qscripts
使用这个插件可以快速调试脚本
然后如果使用 Pycharm 编写而且需要 api 提示的话
在 Project Structure 里面把 IDA 的 python 路径给加到路径里面,然后设置为 source 就可以了