crackers: A Tool for Synthesizing Code-Reuse Attacks from p-code Programs
This repository contains the source code for crackers, a tool for synthesizing
code-reuse attacks (e.g., ROP) built around the Z3 SMT Solver and Ghidra's SLEIGH code translator.
How does it work?
crackers takes as input a "reference program," usually
written in an assembly language, a binary (of the same architecture) in which to look
for gadgets, and user-provided constraints to enforce on synthesized chains. It will always
return an answer (though there is no strict bound on runtime), reporting either that the problem
is UNSAT or providing an assignment of gadgets that meet all constraints, along with a model
of the memory state of the PCODE virtual machine at every step in the chain. This memory model can
then be used to derive the inputs necessary to realize the ROP chain.
crackers itself makes no assumptions about the layout of memory in the target program, nor the extent of an attacker's
control over it: it assumes that all system state is usable unless explicitly prohibited through a constraint.
This approach increases flexibility, with the drawback of requiring more human-guided
configuration than many other ROP tools.
To validate chains, crackers builds a mathematical model of the execution of a candidate chain and makes assertions on it
against a model generated from a specification (itself expressed as a sequence of PCODE operations). When this verification
returns SAT, crackers returns the Z3 model of the memory state of the chain at every point of its execution. This
memory model may be used to derive the contents of memory needed to invoke the chain, and transitively the input needed to
provide to the program to realize it.
crackers is available as a command-line tool, a Rust crate, or a Python package.
This software is still in alpha and may change at any time
How do I use it?
You have three options:
Python Package
The easiest way to use crackers is through the PyPI package. For every release, we provide wheels for [MacOS, Windows, Linux] x [3.10, 3.11, 3.12, 3.13].
A simple usage looks like the following:
# Custom state constraint example
=
=
return ==
# Custom transition constraint example
# Dummy: always true
return
=
=
=
=
=
=
=
=
=
:
:
Rust CLI
You can install the crackers CLI from crates.io by running:
You can then run:
to generate a new configuration for the tool at my_config.toml. This config file can be adjusted
for your use case and then used with:
There are many options to configure in this file. An example (created with crackers new) is below:
[]
= -6067361534454702534
= "INFO"
[]
= """
EDI = COPY 0xdeadbeef:4
ESI = COPY 0x40:4
EDX = COPY 0x7b:4
EAX = COPY 0xfacefeed:4
BRANCH 0xdeadbeef:1
"""
[]
= 5
= "libc.so.6"
[]
= "/Applications/ghidra"
[]
= "sat"
= 200
= 6
= true
[]
= 0x80000000
[]
[[]]
= 0x7fffff80
= 0x80000080
[[]]
= 0x7fffff80
= 0x80000080
CLI Output
When synthesis succeeds, the CLI will print:
- A listing of selected gadgets - The assembly instructions for each gadget in the chain
- Assignment Model Details - A detailed breakdown including:
- Inputs (Locations Read) - All register and memory locations read by each gadget, along with their evaluated values from the model
- Outputs (Locations Written) - All register and memory locations written by each gadget, along with their evaluated values at the end of the chain
Note: The models produced through the CLI only represent the transitions within a chain. They do not constrain the system state to redirect execution to the chain. If you need to encode constraints for redirecting execution to your chain, consider using the Rust or Python API.
Rust Crate
crackers is on crates.io and can be added to your project with:
API documentation can be found on docs.rs.
** The API is unstable and largely undocumented at this time. **
Research Paper
crackers was initially developed in support of our research paper, Synthesis of Code-Reuse Attacks from p-code Programs,
presented at Usenix Security 2025.
If you found the paper or the implementation useful, you can cite it with the following BibTeX: