smithery.ai

idapython

IDA Pro Python scripting for reverse engineering.

First seen Mar 11, 2026

Installation

$ npx skills add https://smithery.ai

Summary

  • 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.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 5,007 B
  • docs SUMMARY.md 344 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 3 installs

SKILL.md

IDAPython

Use modern ida_* modules. Avoid legacy idc module.

Module Router

Task Module Key Items
Bytes/memory ida_bytes getbytes, patchbytes, getflags, create*
Functions ida_funcs funct, getfunc, addfunc, getfunc_name
Names ida_name setname, getname, demangle_name
Types ida_typeinf tinfot, applytinfo, parse_decl
Decompiler ida_hexrays decompile, cfunct, lvart, ctree visitor
Segments ida_segment segmentt, getseg, addsegm
Xrefs ida_xref xrefblkt, addcref, add_dref
Instructions ida_ua insnt, opt, decode_insn
Stack frames ida_frame getframe, definestkvar
Iteration idautils Functions(), Heads(), XrefsTo(), Strings()
UI/dialogs ida_kernwin msg, ask_*, jumpto, Choose
Database info ida_ida infget*, infis64bit()
Analysis ida_auto autowait, planand_wait
Flow graphs ida_gdl FlowChart, BasicBlock
Register tracking ida_regfinder findregvalue, regvalueinfo_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
idaname.SNNOCHECK Skip name validation
idatypeinf.TINFODEFINITE Force type application
oreg, omem, oimm, odispl, o_near Operand types
dtbyte, dtword, dtdword, dtqword Data types
flCF, flCN, flJF, flJN, fl_F Code xref types
drR, drW, dr_O Data xref types

Critical Rules

  1. NEVER convert hex/decimal manually — use int_convert MCP tool
  2. Wait for analysis: Call idaauto.autowait() before reading results
  3. Thread safety: IDA SDK calls must run on main thread (use @idasync)
  4. 64-bit addresses: Always assume ea_t can 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: idabytes, idafuncs, idahexrays, idatypeinf, ida_name, idautils
  • Medium-use: idasegment, idaxref, idaua, idaframe, ida_kernwin
  • Specialized: idadbg (debugger), idanalt (netnode storage), ida_regfinder (register tracking)

Full RST sources from hex-rays.com available at docs/<module>.rst.