Skip to content

Commit 0885b76

Browse files
authored
feat: add simple model printing to CLI (#91)
* feat: enhance configuration handling and logging in CrackersCommands * feat: add better outputting * fix: change default config * fmt and readme * refactor: remove benchmark command and clean up imports * fmt
1 parent 266c700 commit 0885b76

File tree

7 files changed

+293
-200
lines changed

7 files changed

+293
-200
lines changed

README.md

Lines changed: 46 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -171,88 +171,63 @@ for your use case and then used with:
171171
crackers synth my_config.toml
172172
```
173173

174-
There are many options to configure in this file. An example is below:
174+
There are many options to configure in this file. An example (created with `crackers new`) is below:
175175

176176
```toml
177-
# Location to find a Ghidra installation. This is only used for
178-
# SLEIGH architecture definitions
177+
[meta]
178+
seed = -6067361534454702534
179+
log_level = "INFO"
180+
181+
[specification]
182+
RawPcode = """
183+
EDI = COPY 0xdeadbeef:4
184+
ESI = COPY 0x40:4
185+
EDX = COPY 0x7b:4
186+
EAX = COPY 0xfacefeed:4
187+
BRANCH 0xdeadbeef:1
188+
"""
189+
190+
[library]
191+
max_gadget_length = 5
192+
path = "csaw_diary"
193+
179194
[sleigh]
180195
ghidra_path = "/Applications/ghidra"
181196

182197
[synthesis]
183-
# crackers separates the ROP chain synthesis problem into a gadget assignment and gadget validation problem.
184-
# This field determines the strategy used for the assignment problem:
185-
# * "sat" is a simple boolean SAT problem encoding gadget assignments
186-
# * "optimize" is a weighted SAT problem, giving preference to shorter gadgets
187-
# Optimize tends to perform better when only one validation worker is present and SAT scales better with more workers
188198
strategy = "sat"
189-
# The maximum number of candidates considered for each sub-slice of the specification
190-
# If you don't want to cap this, just set it arbitrarily high. Might make it optional later
191-
max_candidates_per_slot = 50
192-
# The number of chain validation workers to use
193-
parallel = 8
194-
195-
# crackers works by taking in an "example" computation and synthesizing a compatible chain
196-
# Right now, it does not support specifications with control flow
197-
[specification]
198-
# The path at which to find the raw binary containing the bytes of the specification computation
199-
path = "bin/execve_instrs.bin"
200-
# The number of assembly instructions in the specification
201-
max_instructions = 5
199+
max_candidates_per_slot = 200
200+
parallel = 6
201+
combine_instructions = true
202202

203-
# Settings involving the file from which to pull gadgets
204-
[library]
205-
# The path to the file. It can be any type of object file that gimli_object can parse (e.g., ELF, PE)
206-
path = "bin/libc_wrapper"
207-
# The maximum length of gadget to extract. Raising this number increases both the complexity of the gadgets
208-
# that are reasoned about and the total number of found gadgets
209-
max_gadget_length = 4
210-
# Optionally randomly sample the set of parsed gadgets to a given size
211-
random_sample_size = 20000
212-
# Optionally use a set seed for gadget selection
213-
# random_sample_seed = 0x234
214-
215-
# From this point on are constraints that we put on the synthesis
216-
# These are fairly self-explanatory
217203
[constraint.precondition.register]
218-
RAX = 0
219-
RCX = 0x440f30
220-
RDX = 0x7fffffffe608
221-
RBX = 0x400538
222-
RSP = 0x7fffffffe3b8
223-
RBP = 0x403af0
224-
RSI = 0x7fffffffe5f8
225-
RDI = 1
226-
R8 = 0
227-
R9 = 6
228-
R10 = 0x36f8
229-
R11 = 0x206
230-
R12 = 0x403b90
231-
R13 = 0x0
232-
R14 = 0x4ae018
233-
R15 = 0x400538
234-
GS = 0
235-
FS = 0
236-
237-
[constraint.postcondition.register]
238-
RAX = 0x3b
239-
RSI = 0
240-
RDX = 0
241-
242-
# This constraint enforces that the value pointed to by this register
243-
# must be equal to the given string
244-
[constraint.postcondition.pointer]
245-
RDI = "/bin/sh"
246-
247-
# ANY pointer access, read or write, must fall in this range
248-
# Might separate read/write later
249-
[constraint.pointer]
250-
min = 0x7fffffffde00
251-
max = 0x7ffffffff000
204+
RSP = 0x80000000
205+
206+
[constraint.postcondition]
207+
208+
[[constraint.pointer.read]]
209+
min = 0x7fffff80
210+
max = 0x80000080
211+
212+
[[constraint.pointer.write]]
213+
min = 0x7fffff80
214+
max = 0x80000080
215+
252216
```
253217

254-
Note that using the CLI, a successful synthesis will print out a listing of the gadgets that were selected,
255-
but not the memory model found in synthesis.
218+
#### CLI Output
219+
220+
When synthesis succeeds, the CLI will print:
221+
222+
1. **A listing of selected gadgets** - The assembly instructions for each gadget in the chain
223+
2. **Assignment Model Details** - A detailed breakdown including:
224+
- **Inputs (Locations Read)** - All register and memory locations read by each gadget, along with their evaluated values from the model
225+
- **Outputs (Locations Written)** - All register and memory locations written by each gadget, along with their evaluated values at the end of the chain
226+
- **Final Branch Destination** - The program counter value after the final gadget (if determinable)
227+
228+
_Note: The models produced through the CLI only represent the transitions within a chain. They do not constrain the
229+
system state to redirect execution to the chain.
230+
If you need to encode constraints for redirecting execution to your chain, consider using the Rust or Python API._
256231

257232
### Rust Crate
258233

crackers/src/bench/mod.rs

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)