meltedinhex/analyst-ai-pack / skills/scripting-ida-with-idapython
scripting-ida-with-idapython
VerifiedAutomates IDA Pro analysis with IDAPython by generating scripts that enumerate functions, decode strings, rename by signature, and export analysis results, and by documenting the headless idat batch invocation. Activates for requests to script IDA Pro, write IDAPython automation, or run IDA in batch/headless mode.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 340 B |
| SKILL.md | skill md | 2.7 KB |
| references/api-reference.md | markdown | 1.4 KB |
| scripts/analyst.py | script | 2.7 KB |
scripts/analyst.py
View on GitHub#!/usr/bin/env python3
"""Generate IDAPython analysis scripts and the headless idat batch command.
`script` emits an IDAPython script that enumerates functions and/or strings and exports JSON.
`batch` builds the `idat -A -S"<script>" <input>` invocation. This tool only generates text — it
does not run IDA or any sample.
"""
from __future__ import annotations
import argparse
import json
import shlex
import sys
from pathlib import Path
FUNCTIONS_SNIPPET = '''
import idautils, idc
for ea in idautils.Functions():
result["functions"].append({
"name": idc.get_func_name(ea),
"start": hex(ea),
})
'''
STRINGS_SNIPPET = '''
import idautils
for s in idautils.Strings():
result["strings"].append({"ea": hex(s.ea), "value": str(s)})
'''
def script(out: str, emit: list[str]) -> dict:
keys, body = [], []
if "functions" in emit:
keys.append('"functions": []')
body.append(FUNCTIONS_SNIPPET)
if "strings" in emit:
keys.append('"strings": []')
body.append(STRINGS_SNIPPET)
text = (
"# IDAPython analysis script (generated skeleton).\n"
"import json\n"
"import ida_pro\n"
"import ida_auto\n\n"
"def run():\n"
" ida_auto.auto_wait() # ensure auto-analysis is complete\n"
" result = {%s}\n%s"
" with open(ida_pro.idainfo_get_path() + '.ida.json', 'w') as fh:\n"
" fh.write(json.dumps(result, indent=2))\n\n"
"run()\n"
"ida_pro.qexit(0) # exit IDA after the script in batch mode\n"
) % (", ".join(keys), "".join(body))
Path(out).write_text(text, encoding="utf-8")
return {"output": out, "emits": emit}
def batch(script_path: str, input_path: str) -> dict:
# -A: autonomous (no dialogs), -S: run script, then the input file.
cmd = f'idat -A -S{shlex.quote(script_path)} {shlex.quote(input_path)}'
return {"command": cmd,
"note": "use idat64 for 64-bit inputs; add -L<logfile> to capture output"}
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="Generate IDAPython automation")
sub = parser.add_subparsers(dest="cmd", required=True)
ps = sub.add_parser("script")
ps.add_argument("--emit", default="functions,strings")
ps.add_argument("--out", required=True)
pb = sub.add_parser("batch")
pb.add_argument("--script", required=True)
pb.add_argument("--input", required=True)
args = parser.parse_args(argv)
if args.cmd == "script":
print(json.dumps(script(args.out, [e.strip() for e in args.emit.split(",")]), indent=2))
else:
print(json.dumps(batch(args.script, args.input), indent=2))
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 193k | Updated | Claude CodeCodex | Verified | Install |