execute_script
Execute custom Python scripts within IDA Pro to automate reverse engineering tasks, analyze binary data, and modify the database using IDAPython modules.
Instructions
Execute arbitrary IDAPython code in the IDA environment.
The code has access to all IDA modules (idaapi, ida_funcs, ida_bytes, etc.).
Use 'result' variable to return a value from the script.
WARNING: This is a powerful tool - use with caution as it can modify the database.
Example:
code = '''
# Count functions with more than 100 instructions
count = 0
for func_ea in idautils.Functions():
func = ida_funcs.get_func(func_ea)
if func and func.end_ea - func.start_ea > 100:
count += 1
result = f"Found {count} large functions"
'''
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "execute_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python code to execute in the IDA environment | |
| timeout_seconds | No | Maximum execution time in seconds (default: 30) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | Yes | ||
| output | Yes | ||
| success | Yes | ||
| return_value | Yes |