Ailment: Angr Intermediate Language

9.2.158 · active · verified Thu Apr 16

Ailment is the Intermediate Language (IL) used by the angr binary analysis framework. It provides a higher-level, more abstract representation of program execution than traditional assembly or micro-code, aiding in static analysis and program transformation. Currently at version 9.2.158, it is actively maintained as a core component of the angr ecosystem, with frequent updates tied to angr's release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to manually construct basic AIL objects: a constant expression, a register expression, an assignment statement, and finally a block containing that statement. It highlights the modular nature of AIL components and their hierarchical structure.

from ailment.expression import Const, Register
from ailment.statement import Assignment
from ailment.block import Block

# Create a 64-bit constant expression with value 0x123
constant_expr = Const(0, None, 64, 0x123)

# Create a 64-bit register expression representing RAX (offset 0 in an abstract context)
# In AIL, registers are often identified by their size and offset within a CPU context.
rax_reg = Register(0, None, 64, 0) # stmt_idx=0, ins_addr=None, size=64 bits, reg_offset=0

# Create an assignment statement: RAX = 0x123
# Arguments: stmt_idx, dst_expression, src_expression
assignment_stmt = Assignment(0, rax_reg, constant_expr)

# Create an AIL block containing the assignment statement
# Arguments: addr, size, statements (must be a list), idx (optional)
# 'addr' and 'size' are the abstract address and size of the block.
ail_block = Block(0x400000, 10, [assignment_stmt])

print(f"Created AIL Block at 0x{ail_block.addr:x}:")
print(f"  Statements: {len(ail_block.statements)}")
print(f"  First statement: {ail_block.statements[0]}")
print(f"    Destination: {ail_block.statements[0].dst}")
print(f"    Source: {ail_block.statements[0].src}")

view raw JSON →