首页
/ trace_natives 项目使用教程

trace_natives 项目使用教程

2024-08-17 09:01:35作者:卓炯娓

1. 项目的目录结构及介绍

trace_natives 项目的目录结构如下:

trace_natives/
├── LICENSE
├── README.md
├── test.png
└── traceNatives.py

文件介绍

  • LICENSE: 项目的许可证文件,采用 GPL-3.0 许可证。
  • README.md: 项目的说明文档,包含项目的基本介绍和使用方法。
  • test.png: 项目的测试图片文件。
  • traceNatives.py: 项目的主要脚本文件,用于在 IDA 中跟踪 SO 文件中的 native 函数调用。

2. 项目的启动文件介绍

项目的启动文件是 traceNatives.py。该文件是一个 IDA 插件脚本,用于在 IDA 中加载并运行,以跟踪 SO 文件中的 native 函数调用。

traceNatives.py 文件内容概述

class traceNatives(plugin_t):
    flags = PLUGIN_PROC
    comment = "traceNatives"
    help = ""
    wanted_name = "traceNatives"
    wanted_hotkey = ""

    def init(self):
        print("traceNatives(v0.1) plugin has been loaded")
        return PLUGIN_OK

    def run(self, arg):
        # 查找需要的函数
        ea, ed = getSegAddr()
        search_result = []
        for func in idautils.Functions(ea, ed):
            try:
                functionName = str(idaapi.idc.GetFunctionName(func))
                if len(list(idautils.FuncItems(func))) > 10:
                    # 如果是thumb模式,地址+1
                    arm_or_thumb = idc.get_sreg(func, "T")
                    if arm_or_thumb:
                        func += 1
                    search_result.append(hex(func))
            except:
                pass
        so_path, so_name = getSoPathAndName()
        search_result = [f"-a '[so_name] [offset]'" for offset in search_result]
        search_result = " ".join(search_result)
        script_name = so_name.split(" ")[0] + "_" + str(int(time.time()))
        # 其他代码...

使用方法

  1. traceNatives.py 文件放入 IDA 的 plugins 目录中。
  2. 在 IDA 中运行如下命令找到 plugins 目录:
    import os
    os.path.join(idaapi.get_user_idadir(), "plugins")
    
  3. 在 IDA 中选择 Edit -> Plugins -> traceNatives,IDA 输出窗口将显示相关信息。

3. 项目的配置文件介绍

trace_natives 项目没有明确的配置文件。项目的配置主要通过 traceNatives.py 脚本中的代码实现。用户可以根据需要修改脚本中的参数和逻辑,以适应不同的跟踪需求。

配置示例

traceNatives.py 脚本中,可以修改以下参数:

  • wanted_name: 插件的名称。
  • wanted_hotkey: 插件的快捷键。
  • flags: 插件的标志位。

例如:

class traceNatives(plugin_t):
    flags = PLUGIN_PROC
    comment = "traceNatives"
    help = ""
    wanted_name = "traceNatives"
    wanted_hotkey = "Ctrl+Alt+T"

通过修改这些参数,可以自定义插件的行为和快捷键。


以上是 trace_natives 项目的使用教程,希望对您有所帮助。

登录后查看全文
热门项目推荐