본문으로 건너뛰기
Skillpedia
일반 코딩13k · #11376

idapython

하는 일

이 스킬은 역공학을 위한 IDA Pro의 Python 인터페이스 가이드를 AI 에이전트에게 제공합니다. 컴파일된 프로그램을 분석하는 보안 연구자와 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓IDA Pro 데이터베이스에서 함수나 상호 참조를 나열하는 스크립트가 필요할 때.
  • ✓IDA에서 분석 중인 바이너리의 바이트를 패치하거나 이름을 바꾸거나 타입을 정하고 싶을 때.
  • ✓Python에서 Hex-Rays 디컴파일러를 사용하는 경우.

스킬 링크

https://github.com/mrexodia/ida-pro-mcp/blob/main/skills/idapython/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/mrexodia/ida-pro-mcp/blob/main/skills/idapython/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 바이너리에서 strcpy를 호출하는 모든 함수를 나열하는 IDA Python 스크립트를 작성해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 알맞은 ida_* 모듈과 함수, 명령, 참조를 순회하는 일반 패턴을 사용합니다. 그다음 IDA 안에서 실행할 수 있는 스크립트를 씁니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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

  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

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 Pro가 필요한가요?

네. 스크립트는 IDA Pro 안에서 실행되므로 그 도구가 설치되어 있어야 합니다.

오래된 idc 모듈을 쓰나요?

아니요. 스킬은 최신 ida_* 모듈을 우선하고 오래된 idc 모듈은 피하라고 안내합니다.

디컴파일러도 도울 수 있나요?

네. ctree 방문자와 지역 변수를 포함한 Hex-Rays 디컴파일을 다룹니다.

상세 정보

작성자의 원본 설명

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.

repo: mrexodia/ida-pro-mcp

인기도

GitHub 스타
13k
순위
#11376
라이선스
MIT
업데이트
2026. 9. 26.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

비슷한 스킬