GKLBB

当你经历了暴风雨,你也就成为了暴风雨

导航

逆向分析 --- ghidra和ida导出所有函数名称脚本

IDA

1.保存下面脚本

import idautils
import idaapi
import idc

# 打开一个文件用于写入函数名称
with open("C:\\Users\\21558\\Downloads\\Compressed\\ghidra_11.1.1_PUBLIC_20240614\\ghidra_11.1.1_PUBLIC\\2.txt", "w") as file:
# 遍历所有函数
for function_ea in idautils.Functions():
function_name = idc.get_func_name(function_ea)
file.write(function_name + "\n")

print("Function names have been exported.")

 

2.打开ida,文件->脚本文件,运行

 

Ghidra

1.打开窗口-》脚本管理,右键新建,保存下面脚本,运行

# This script extracts all function names from the current Ghidra program
# and writes them to a specified output file. It is useful for documenting
# and analyzing the functions present in a binary or program being analyzed
# with Ghidra.

# Author: [Your Name]
# Category: _NEW_
# Keybinding: 
# Menupath: 
# Toolbar: 

# Import necessary Ghidra modules
from ghidra.program.model.listing import FunctionManager
from ghidra.util.task import TaskMonitor  # Correct import path for TaskMonitor

# Get the current program
program = getCurrentProgram()

# Get the function manager
function_manager = program.getFunctionManager()

# Get all functions in the current program
functions = function_manager.getFunctions(True)

# Open a file to write the function names
with open("C:\\Users\\21558\\Downloads\\Compressed\\ghidra_11.1.1_PUBLIC_20240614\\ghidra_11.1.1_PUBLIC\\1.txt", "wb") as file:
    # Iterate through all functions and write their names to the file
    for function in functions:
        try:
            file.write((function.getName() + "\n").encode('utf-8'))
        except UnicodeEncodeError as e:
            print("Encoding error for function {}: {}".format(function.getName(), e))

print("Function names have been exported.")

注意:修改你的文件输出路径

 

posted on 2024-06-18 07:54  GKLBB  阅读(52)  评论(0编辑  收藏  举报