idapython
- Repo stars 9,020
- Author updated Live
- Author repo ida-pro-mcp
- Domain
- Writing
- Compatible agents
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- Trust score
- 88 / 100 · community maintained
- Author / version / license
- @mrexodia · no license declared
- Token usage
- Lean
- Setup complexity
- Guided setup
- External API key
- Not required
- Operating systems
- Unspecified (assume cross-platform)
- Runtime requirements
- Python
- Permissions
-
- Read-only
- Write / modify
- Shell exec
- Network behavior
- Local-only
- Install commands
- 26 variants
Profile is derived at build time from SKILL.md and install vectors. Subject to drift from author intent.
Heads up: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: idapython
description: IDA Pro Python scripting for reverse engineering. Use when writing IDAPython scripts, analyzing…
category: writing
runtime: Python
---
# idapython output preview
## PART A: Task fit
- Use case: IDA Pro Python scripting for reverse engineering. Use when writing IDAPython scripts, analyzing binaries, working with IDA's API for disassembly, decompilation (Hex-Rays), type systems, cross-references, functions, segments, or any IDA database manipulation. Covers ida_* modules (50+), idautils iterators, and common patterns..
- Inputs: target material, constraints, expected output, and acceptance criteria.
- Evidence boundary: follow “Module Router / Core Patterns / Iterate functions” and do not present inference as author intent.
## PART B: Execution result
- **01** The card summarizes the use case; runtime output centers on “IDA Pro Python scripting for reverse engineering. Use when writing IDAPython scripts, analyzing binaries, working with IDA's API for disassembly, decompilation (Hex-Rays), type systems, cross-references, functions, segments, or any IDA database manipulation. Covers ida_* modules (50+), idautils iterators, and common patterns.”.
- **02** When the source has headings, the agent prioritizes “Module Router / Core Patterns / Iterate functions” so the result follows the author’s structure.
- **03** Typical output includes task judgment, concrete steps, required commands or file edits, validation, and follow-up options.
- **04** Risk context follows the fingerprint: read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
## Running Rules
- read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding scope.
- Return the result, validation criteria, and next iteration options. The source does not require a stable slash command. After installation, invoke the skill by name and describe the task.
Name target files or source material, expected output, forbidden changes, and whether network or shell access is allowed. Permission fingerprint: read files, write/modify files, run shell commands.
Start with a small task and check whether the result follows “Module Router / Core Patterns / Iterate functions”. Inspect diffs, logs, previews, or tests before expanding scope.
Confirm the final output includes a concrete result, evidence, and next action. If it stays generic, tighten inputs, boundaries, and acceptance criteria.
---
name: idapython
description: IDA Pro Python scripting for reverse engineering. Use when writing IDAPython scripts, analyzing…
category: writing
source: mrexodia/ida-pro-mcp
---
# idapython
## When to use
- IDA Pro Python scripting for reverse engineering. Use when writing IDAPython scripts, analyzing binaries, working with…
- Use it when the task has clear inputs, repeatable steps, and validation criteria.
## What to provide
- Target material, scope, expected result, and forbidden changes.
- Whether network, commands, file writes, or external services are allowed.
## Execution rules
- Organize steps around “Module Router / Core Patterns / Iterate functions” and keep inference separate from source facts.
- read files, write/modify files, run shell commands; mostly runs locally; usually needs no extra API key.
- Validate with a small sample before expanding the task.
## Output requirements
- Return the deliverable, key evidence, validation method, and next action.
- Mark missing information as unknown; do not invent commands, platforms, or dependencies. The author source anchors workflow facts; repository files anchor sources and commands; Fluxly only adds fit, limitations, and quality judgment.
skill "idapython" {
input -> user goal + target files + boundaries + acceptance criteria
context -> Module Router / Core Patterns / Iterate functions
rules -> SKILL.md triggers / order / output contract
runtime -> Python | read files, write/modify files, run shell commands | mostly runs locally
guardrails -> usually needs no extra API key + small-sample validation + diff/log review
output -> copyable result + checklist + next iteration
} IDAPython
Use modern ida_* modules. Avoid legacy idc module.
Module Router
| Task | Module | Key Items |
|---|---|---|
| Bytes/memory | ida_bytes |
get_bytes, patch_bytes, get_flags, create_* |
| Functions | ida_funcs |
func_t, get_func, add_func, get_func_name |
| Names | ida_name |
set_name, get_name, demangle_name |
| Types | ida_typeinf |
tinfo_t, apply_tinfo, parse_decl |
| Decompiler | ida_hexrays |
decompile, cfunc_t, lvar_t, ctree visitor |
| Segments | ida_segment |
segment_t, getseg, add_segm |
| Xrefs | ida_xref |
xrefblk_t, add_cref, add_dref |
| Instructions | ida_ua |
insn_t, op_t, decode_insn |
| Stack frames | ida_frame |
get_frame, define_stkvar |
| Iteration | idautils |
Functions(), Heads(), XrefsTo(), Strings() |
| UI/dialogs | ida_kernwin |
msg, ask_*, jumpto, Choose |
| Database info | ida_ida |
inf_get_*, inf_is_64bit() |
| Analysis | ida_auto |
auto_wait, plan_and_wait |
| Flow graphs | ida_gdl |
FlowChart, BasicBlock |
| Register tracking | ida_regfinder |
find_reg_value, reg_value_info_t |
Core Patterns
Iterate functions
for ea in idautils.Functions():
name = ida_funcs.get_func_name(ea)
func = ida_funcs.get_func(ea)
Iterate instructions in function
for head in idautils.FuncItems(func_ea):
insn = ida_ua.insn_t()
if ida_ua.decode_insn(insn, head):
print(f"{head:#x}: {insn.itype}")
Cross-references
for xref in idautils.XrefsTo(ea):
print(f"{xref.frm:#x} -> {xref.to:#x} type={xref.type}")
Read/write bytes
data = ida_bytes.get_bytes(ea, size)
ida_bytes.patch_bytes(ea, b"\x90\x90")
Names
name = ida_name.get_name(ea)
ida_name.set_name(ea, "new_name", ida_name.SN_NOCHECK)
Decompile function
cfunc = ida_hexrays.decompile(ea)
if cfunc:
print(cfunc) # pseudocode
for lvar in cfunc.lvars:
print(f"{lvar.name}: {lvar.type()}")
Walk ctree (decompiled AST)
class MyVisitor(ida_hexrays.ctree_visitor_t):
def visit_expr(self, e):
if e.op == ida_hexrays.cot_call:
print(f"Call at {e.ea:#x}")
return 0
cfunc = ida_hexrays.decompile(ea)
MyVisitor().apply_to(cfunc.body, None)
Apply type
tif = ida_typeinf.tinfo_t()
if ida_typeinf.parse_decl(tif, None, "int (*)(char *, int)", 0):
ida_typeinf.apply_tinfo(ea, tif, ida_typeinf.TINFO_DEFINITE)
Create structure
udt = ida_typeinf.udt_type_data_t()
m = ida_typeinf.udm_t()
m.name = "field1"
m.type = ida_typeinf.tinfo_t(ida_typeinf.BTF_INT32)
m.offset = 0
m.size = 4
udt.push_back(m)
tif = ida_typeinf.tinfo_t()
tif.create_udt(udt, ida_typeinf.BTF_STRUCT)
tif.set_named_type(ida_typeinf.get_idati(), "MyStruct")
Strings list
for s in idautils.Strings():
print(f"{s.ea:#x}: {str(s)}")
Wait for analysis
ida_auto.auto_wait() # Block until autoanalysis completes
Key Constants
| Constant | Value/Use |
|---|---|
BADADDR |
Invalid address sentinel |
ida_name.SN_NOCHECK |
Skip name validation |
ida_typeinf.TINFO_DEFINITE |
Force type application |
o_reg, o_mem, o_imm, o_displ, o_near |
Operand types |
dt_byte, dt_word, dt_dword, dt_qword |
Data types |
fl_CF, fl_CN, fl_JF, fl_JN, fl_F |
Code xref types |
dr_R, dr_W, dr_O |
Data xref types |
Critical Rules
- NEVER convert hex/decimal manually — use
int_convertMCP tool - Wait for analysis: Call
ida_auto.auto_wait()before reading results - Thread safety: IDA SDK calls must run on main thread (use
@idasync) - 64-bit addresses: Always assume
ea_tcan be 64-bit
Anti-Patterns
| Avoid | Do Instead |
|---|---|
idc.* functions |
Use ida_* modules |
| Hardcoded addresses | Use names, patterns, or xrefs |
| Manual hex conversion | Use int_convert tool |
| Blocking main thread | Use execute_sync() for long ops |
| Guessing at types | Derive from disassembly/decompilation |
Detailed API Reference
For comprehensive documentation on any module, read docs/<module>.md:
- High-use:
ida_bytes,ida_funcs,ida_hexrays,ida_typeinf,ida_name,idautils - Medium-use:
ida_segment,ida_xref,ida_ua,ida_frame,ida_kernwin - Specialized:
ida_dbg(debugger),ida_nalt(netnode storage),ida_regfinder(register tracking)
Full RST sources from hex-rays.com available at docs/<module>.rst.
Decide Fit First
Design Intent
How To Use It
Boundaries And Review