以获取二进制文件中 socket 函数调用中 domain 参数的具体值为例学习如何编写 ida 脚本自动化实现该功能。

环境

  • Arch Linux
  • IDA Pro 9.1
  • python 3.12
  • ida_domain pip包

脚本

domain api

示例脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os
import argparse

os.environ["IDADIR"] = "/home/eutopia/Tools/REVERSE/ida_pro_91/"
from ida_domain import Database


parser = argparse.ArgumentParser(description="Quick Usage Example")
parser.add_argument('-f', '--input-file', type=str, required=True)
args = parser.parse_args()

with Database() as db:
if db.open(args.input_file):
for func in db.functions:
print(f'{func.name}: {len(list(db.functions.get_instructions(func)))} instructions')


然后参考官方提供的 ida api,我们实现自动获取 socket domain 参数功能如下:

1

参考链接