idapython

13
0
Source

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.

Install

mkdir -p .claude/skills/idapython && curl -L -o skill.zip "https://mcp.directory/api/skills/download/2164" && unzip -o skill.zip -d .claude/skills/idapython && rm skill.zip

Installs to .claude/skills/idapython

About this skill

IDAPython

Use modern ida_* modules. Avoid legacy idc module.

Module Router

TaskModuleKey Items
Bytes/memoryida_bytesget_bytes, patch_bytes, get_flags, create_*
Functionsida_funcsfunc_t, get_func, add_func, get_func_name
Namesida_nameset_name, get_name, demangle_name
Typesida_typeinftinfo_t, apply_tinfo, parse_decl
Decompilerida_hexraysdecompile, cfunc_t, lvar_t, ctree visitor
Segmentsida_segmentsegment_t, getseg, add_segm
Xrefsida_xrefxrefblk_t, add_cref, add_dref
Instructionsida_uainsn_t, op_t, decode_insn
Stack framesida_frameget_frame, define_stkvar
IterationidautilsFunctions(), Heads(), XrefsTo(), Strings()
UI/dialogsida_kernwinmsg, ask_*, jumpto, Choose
Database infoida_idainf_get_*, inf_is_64bit()
Analysisida_autoauto_wait, plan_and_wait
Flow graphsida_gdlFlowChart, BasicBlock
Register trackingida_regfinderfind_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

ConstantValue/Use
BADADDRInvalid address sentinel
ida_name.SN_NOCHECKSkip name validation
ida_typeinf.TINFO_DEFINITEForce type application
o_reg, o_mem, o_imm, o_displ, o_nearOperand types
dt_byte, dt_word, dt_dword, dt_qwordData types
fl_CF, fl_CN, fl_JF, fl_JN, fl_FCode xref types
dr_R, dr_W, dr_OData xref types

Critical Rules

  1. NEVER convert hex/decimal manually — use int_convert MCP tool
  2. Wait for analysis: Call ida_auto.auto_wait() 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

AvoidDo Instead
idc.* functionsUse ida_* modules
Hardcoded addressesUse names, patterns, or xrefs
Manual hex conversionUse int_convert tool
Blocking main threadUse execute_sync() for long ops
Guessing at typesDerive 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.

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

642969

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

591705

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318398

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

339397

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

451339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.