Python API Reference

Welcome to Maat's Python API documentation. The Python API is user friendly and perfect to quickly write portable binary analysis scripts. If you are just getting started with Maat, checkout our tutorials.

  • The tutorials showcase the Python API pretty well and cover almost all features of the framework. If you're unsure about how to use some classes or functions, there is probably a tutorial in there that explains it
  • The classes page shows all classes exposed by the Python API


Get started

from maat import *

# Create a symbolic engine for Linux X86-32bits
engine = MaatEngine(ARCH.X86, OS.LINUX)

# Load a binary with one command line argument
engine.load("./some_binary", BIN.ELF32, args=[engine.vars.new_symbolic_buffer("password", 20)])

# Get current eax value
engine.cpu.eax

# Read 4 bytes at the top of the stack
engine.mem.read(engine.cpu.esp, 4)

# Set a callback displaying every memory read
def show_mem_access(engine):
    mem_access = engine.info.mem_access
    print(f"Inst at {engine.info.addr} reads {mem_access.size} bytes at {mem_access.addr}")

engine.hooks.add(EVENT.MEM_R, WHEN.BEFORE, callbacks=[show_mem_access])

# Take and restore snapshots
snap = engine.take_snapshot()
engine.restore_snapshot(snap)

# Run the binary
engine.run()