ida版本为IDA9.0
用VScode编写IDApython
找到这个项目IDAcode ,把下来的文件加到你ida的plugins文件夹中。
修改idacode_utils/settings.py中的PYTHON路径为本地的python路径
在本地中用控制台安装依赖
1 python -m pip install --user debugpy tornado
在VScode中安装IDAcode插件
在VScode按CTRL+Shift+P输入”Open User Settings(JSON)”打开后添加如下代码。
1 2 3 4 5 6 "python.autoComplete.extraPaths" : [ "E:\\CTFtoolsNEW\\Reverse\\IDA90\\python\\3" ], "python.analysis.extraPaths" : [ "E:\\CTFtoolsNEW\\Reverse\\IDA90\\python\\3" ],
在VScode按CTRL+Shift+P,搜索ida即可找到想要的功能。
在ida插件中打开idacode,显示Listening on 127.0.0.1:7065即成功。
如果出现找不到依赖的报错,请在ida目录下找到并运行idapyswitch.exe,选择同样的python解释器(切换解释器可能会导致库的缺失,请自行安装缺失的库)。
如果写的命令发到ida执行报错,请在VScode中选择同样的python解释器,不要用虚拟解释器。
[!NOTE]
在ida9中idc库似乎有些内容被弃用,我们可以用ida_ida库实现相同的功能。官方也说明了idc库中的某些内容可能在将来的版本中被弃用。”This file is subject to change without any notice. Future versions of IDA may use other definitions.”
[]: https://python.docs.hex-rays.com/namespaceidc.html “hex-rays”
对于一些ida90的兼容性问题可参考: https://www.52pojie.cn/thread-1957552-1-1.html
脚本总结 模板去花指令 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 import idautilsimport idcimport idaapidef nop_jzjnz (start_addr,endaddr,pattern ): length =len (pattern) flag = 0 while start_addr < endaddr: getbytes =idc.get_bytes(start_addr,length) if (getbytes[0 ]==pattern[0 ] and getbytes[2 ]==pattern[2 ] and getbytes[4 ] == pattern[4 ] ): flag = 1 for i in range (length): idc.patch_byte(start_addr + i,0x90 ) print (f"success! nop 0x{hex (start_addr)} to 0x{hex (start_addr + length -1 )} length:{length} " ) start_addr += length - 1 start_addr += 1 if (flag == 0 ): print ("Not find!!!" ) def nop_range (start_addr,end_addr ): while (start_addr <= end_addr): idc.patch_byte(start_addr,0x90 ) start_addr += 1 print (f"success! nop 0x{start_addr} to 0x{end_addr} " ) def remount (): try : addr = idc.get_screen_ea() func = idaapi.get_func(addr) func_start = func.start_ea idaapi.del_func(func_start) idaapi.add_func(func_start) print (f"success!! remount the func in 0X{func} " ) except Exception as a: print ("some errors occur, remount falrue" ) print (f"error : {a} " ) start_addr = 0x0401020 end_addr = 0x040122F pattern_jzjnz1 = [0x74 , 0x00 , 0x75 , 0x00 , 0xE8 ] pattern_jzjnz2 = [0x74 , 0x00 , 0x75 , 0x00 , 0xE9 ]
获取寄存器 1 2 3 4 import ida_dbgecx = ida_dbg.get_reg_val("ecx" ) print ("," ,ecx,end="" )
一些函数 1 2 3 4 5 6 7 idc.get_bytes() idc.patch_byte() idaapi.get_func(addr) idaapi.del_func(func_start) idaapi.add_func(func_start)