Sunday, October 11, 2026

miasm for binary reverse engineering, emulation and symbolic analysis

miasm for binary reverse engineering, emulation and symbolic analysis

miasm is an open-source Python reverse engineering framework that disassembles, emulates and symbolically analyzes binaries across x86, ARM, MIPS and more for authorized researchers.

Toolcea-sec/miasm — GPLv2 Python reverse engineering framework for analyzing, modifying and generating binary programs
CategoryReverse engineering framework (disassembler, JIT emulator, symbolic execution engine)
Primary UseAnalyzing and deobfuscating binaries in authorized malware research, CTF work and vulnerability analysis using IR, JIT emulation and SymbolicExecutionEngine
Safe UseIntended for authorized security assessments, malware analysis labs, CTF exercises and defensive research on samples you have the right to examine
Telemetry NotePure analysis library running locally in your Python environment; it touches no network infrastructure itself, so its use is invisible to targets and leaves only local execution traces

miasm, hosted at cea-sec/miasm and licensed under GPL-2.0, is a mature Python framework whose stated goal is to analyze, modify and generate binary programs. With roughly four thousand stars and active CI badges from GitHub Actions and Code Climate, it presents itself as a serious engineering project rather than a script collection. The feature list in the README is compact but dense: opening, modifying and generating PE and ELF binaries in 32- and 64-bit, both little- and big-endian; assembling and disassembling x86, ARM, MIPS, SH4 and MSP430; an intermediate representation for assembly semantics; JIT-based emulation for dynamic code analysis and unpacking; and expression simplification aimed at automatic de-obfuscation. That combination positions it as a Swiss-army framework for anyone doing authorized reverse engineering work.

The architecture, as far as the README reveals it, is layered around a few central abstractions. The Machine class is the entry point per architecture — Machine('x86_32') or Machine('mips32b') hands you a mnemonic object mn that handles both fromstring parsing and asm/dis round trips. The LocationDB tracks symbolic locations so that labels and addresses stay consistent across the analysis pipeline. Above that sits the Container abstraction in miasm.analysis.binary, which normalizes input — the README shows it ingesting a raw shellcode string and producing a ContainerUnknown object with a bin_stream the disassembly engine can consume. This layered design means you can work at the raw-bytes level, the assembly level or the semantic level without changing tooling.

The disassembler is multi-block aware rather than purely linear. The dis_engine combined with dis_multiblock recovers a full asmcfg with basic blocks and explicit edge annotations — the README output shows c_next and c_to successors on conditional jumps, which is what you want when reconstructing control flow of obfuscated or hand-written code. Because miasm also assembles, the framework round-trips: you can parse 'XOR ECX, ECX' into an instruction object, swap an operand to EAX via l.args[0] = mn_x86.regs.EAX, and re-encode. Notably, mn_x86.asm returns multiple encodings — the example yields four byte sequences for the same instruction — which reflects the framework's attention to encoding alternatives, useful for patch engineering and studying instruction-length tricks in packers.

The intermediate representation is where miasm distinguishes itself from simpler disassembly libraries. Instructions are lifted through lifter_model_call into an ircfg, a graph of irblock objects composed of assignblk assignments. The README's ARM example lifts ADD R2, R8, R0 into two assignments — the register write and an IRDst update representing control flow — making side effects explicit and queryable via get_rw(). This IR is not cosmetic: the symbolic execution engine and the expression simplifier both consume it, so de-obfuscation is performed on semantics rather than syntax. The project publishes a Jupyter Notebook, doc/expression/expression.ipynb, dedicated to the expression system, which is the right place to start if the IR syntax of sliced expressions like ECX[0:8] looks unfamiliar.

Emulation is handled by the jitter, a JIT engine initialized with machine.jitter(loc_db, jit_type='python'). The README demonstrates the full workflow on a small x86_32 shellcode: init_stack(), mapping the code into the virtual memory with vm.add_memory_page(run_addr, PAGE_READ | PAGE_WRITE, s), planting a sentinel breakpoint that terminates execution by setting jitter.running = False, and pushing a return address with push_uint32_t. The set_trace_log() option produces a full instruction-by-instruction register dump — flags, RIP, memory mappings — which is exactly the instrumentation you need for unpacking workflows where you watch writes to newly allocated pages. Direct CPU state access (jitter.cpu.EAX, jitter.cpu.ESI = 12) makes it scriptable as a concolic harness. This is a defensive analysis capability: running untrusted code inside a controlled sandbox you own, not on any target system.

The symbolic execution layer, miasm.ir.symbexec.SymbolicExecutionEngine, runs the lifted ircfg with symbolic register values. The README's walkthrough is instructive: running the shellcode symbolically yields a program counter expression ((ECX + 0x4)[0:8] + 0xFF)?(0xB,0x10) — a conditional select over both branch targets — which is the essence of path-aware analysis without enumerating paths. Step logging shows how each CMP flag (zf, nf, pf, of, cf, af) is derived as a bit-sliced expression over the operands. Then the concolic turn: binding ECX to a concrete ExprInt(-3, 32) collapses the symbolic state and lets execution reach the shellcode's end, demonstrating how concrete inputs interact with symbolic state.

This symbolic-plus-simplification machinery is the framework's answer to obfuscation. Expression simplification, listed as a headline feature, means tangled arithmetic identities injected by obfuscators can be algebraically reduced inside the IR instead of being untangled by hand. Combined with JIT emulation for dynamic unpacking, this gives an analyst both the dynamic route (run the code, observe memory and registers) and the static-symbolic route (reason over all inputs at once) within a single Python session. That dual capability is what makes miasm a framework rather than a disassembler, and it is the reason it appears regularly in CTF solutions and malware research writeups.

Operationally, the README directs users to the official blog at miasm.re for extended examples and demos, and points to a documentation section covering software requirements, configuration and a Windows-and-IDA integration path — the latter notable because it signals that the framework is meant to slot into existing commercial reverse engineering workflows, not replace them. There is a testing section, an active Gitter chat channel, and a hacktoberfest topic tag, all consistent with a project that welcomes contribution. Installation follows standard Python practice, for example pip install miasm, and the pure-Python jit_type='python' backend means you can get emulation running without native JIT dependencies before opting into faster backends.

For defenders and authorized analysts, miasm fits into a specific niche: it is a library, not a product. You compose it into your own unpacking scripts, deobfuscation pipelines, firmware analysis harnesses — the MSP430 and SH4 support in particular tilts it toward embedded work that mainstream tools handle poorly. Because it is fully local and touches no network services, it carries no operational risk to third parties; the responsibility is the usual one of running untrusted samples only inside isolated, authorized analysis environments. As an educational artifact the README itself is a compact course in modern binary analysis concepts — lifting, IR, JIT, symbolic execution — and working through its examples is a legitimate way for a professional to build real reverse engineering fundamentals.

Official project repository for cea-sec/miasm.
Download Tool

Educational analysis for authorized security professionals. Use only in controlled, authorized environments.

Sponsored
Share articleFacebookXLinkedIn

Continue exploring

Browse all articles →

0 comentários:

Post a Comment

Note: Only a member of this blog may post a comment.