File size: 986 Bytes
dee983b
 
 
 
 
 
 
 
 
 
8464e89
 
 
 
dee983b
8464e89
dee983b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json

def dump_functions_to_json():
    functionManager = currentProgram().getFunctionManager()
    functions = functionManager.getFunctions(True)
    
    # Create a dictionary to store function names and their corresponding addresses
    functions_dict = {}
    
    for func in functions:

        if func.isExternal() or func.isThunk():
            continue

        func_name = func.getName()
        func_address = func.getEntryPoint().getOffset()
        
        # Add function name and address to the dictionary
        functions_dict[func_address] = func_name
    
    # Convert the dictionary to a JSON object
    json_data = json.dumps(functions_dict, indent=4)
    
    args = getScriptArgs()

    if len(args) == 0:

        # Print JSON output to the console
        print(json_data)

    else:
            
        # Write JSON output to a file
        with open(args[0], 'w') as f:
            f.write(json_data)
    
# Run the function
dump_functions_to_json()