### Example: --sigcheck on ScreenConnect Client Setup Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-triage.md Run --sigcheck on a specific executable to see a human-readable summary including cert blob size, signer and issuer CNs, signing time, and full chain CNs. This command is part of the example for the --sigcheck option. ```bash rsleigh ~/Downloads/ScreenConnect.ClientSetup.exe --sigcheck ``` ```text === Authenticode signature for /Users/.../ScreenConnect.ClientSetup.exe === Cert blob size: 93984 bytes (revision 0x0200, type 0x0002) Signer CN: Connectwise, LLC Issuer CN: DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1 Signing time: 2025-04-08 18:37:56 UTC Cert chain CNs (6): [0] DigiCert Trusted Root G4 [1] DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1 [2] Connectwise, LLC [3] DigiCert Trusted G4 RSA4096 SHA256 TimeStamping CA [4] DigiCert Timestamp 2024 [5] DigiCert Assured ID Root CA ``` -------------------------------- ### Start Colima VM for container builds Source: https://github.com/shanebreazeale/rsleigh/blob/master/CLAUDE.md Starts a Colima VM with 4 CPUs, 4 GB memory, and 20 GB disk. Requires prior installation of colima and docker via Homebrew. ```bash colima start --cpu 4 --memory 4 --disk 20 ``` -------------------------------- ### Run probe_check2_ssa example Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/specs/2026-04-16-ssa-call-clobber-design.md Run the probe_check2_ssa example to verify that check2 and main probes show Expr::Unknown clobbers after each Call. ```bash cargo run -p test-harness --example probe_check2_ssa ``` -------------------------------- ### rsleigh --index example commands and jq query Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/agent-workflow.md Example commands for building an index, verifying it, and querying functions.json with jq. Verification checks input hash, tool version, generation manifest, and artifact presence, size, checksum, and schema. Version 1 indexes must be rebuilt. ```bash rsleigh FILE --index out/ --limit 100 ``` ```bash rsleigh FILE --verify-index out/ ``` ```bash functions_path=$(jq -r '.files[] | select(.name == "functions.json") | .path' out/index.json) ``` ```bash jq '.functions[] | select(.imports | index("recv"))' "out/$functions_path" ``` -------------------------------- ### rsleigh invocation examples Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-reference.md Shows three sample invocations: with --agent-brief, with --xrefs using a virtual address, and with --card and --pcode. Put the binary path first; quote paths with spaces and use ./ for filenames starting with a dash. ```bash rsleigh ./sample.exe --agent-brief ``` ```bash rsleigh ./sample.exe --xrefs 0x140001000 ``` ```bash rsleigh ./sample.exe 0x140001000 --card --pcode ``` -------------------------------- ### Round 2: xrefs and card with pcode Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/AGENTS-rsleigh.md For each chosen address, run these commands to get cross-references and a card with P-code. ```bash rsleigh FILE --xrefs ADDR rsleigh FILE ADDR --card --pcode ``` -------------------------------- ### Agent-brief and card usage examples Source: https://github.com/shanebreazeale/rsleigh Shows common rsleigh CLI invocations for agent-brief, card, SSA slice, compare, and investigate modes. Use these to explore a binary with different analysis options. ```bash rsleigh ./sample.exe --agent-brief --limit 5 rsleigh ./sample.exe 0x140001000 --card --json --pcode --decompile rsleigh ./sample.exe --ssa-slice 0x140001000 --return --evidence-store ./store rsleigh ./sample.exe --compare new.exe --json rsleigh ./sample.exe --investigate ./store --question "What does main return?" ``` -------------------------------- ### Test extraction on one binary Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-17-decompiler-compare-implementation.md Runs the extract-functions example on a test binary. Expected output is JSON with 5-10 functions and addresses. ```bash cd /Users/shane/repos/rsleigh cargo run -p test-harness --example extract-functions -- ~/Downloads/test_bin/main.exe ``` -------------------------------- ### Build rsleigh with SMT on Linux (apt) Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/smt-backend.md Install the Z3 development package via apt and build the rsleigh CLI with the smt feature on Linux. Requires a Rust toolchain and system Z3. ```bash sudo apt install libz3-dev cargo build -p rsleigh-cli --release --features smt ``` -------------------------------- ### Sample IOC extraction output (text) Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-triage.md Example output from `rsleigh ~/Downloads/sample.exe --ioc`. Shows sorted indicator lists per category and total count. ```text === IOCs from /Users/.../sample.exe === URLs (12) http://178.16.54.109/grab.exe http://178.16.54.109/xmr.exe ... IPv4 (1) 178.16.54.109 Paths (2) %APPDATA%\2353253532535.txt %TEMP%\d3333333333333333333.txt Mutexes/Named Objects (2) Global\WixWaitForEventFail Global\WixWaitForEventSucceed Total: 17 indicators ``` -------------------------------- ### Summarize spot-check results per function Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-17-decompiler-compare-implementation.md Example summary of spot-check findings for crackme_bobgambling.exe, noting variable naming differences and a missed return flow in rsleigh. ```markdown ### crackme_bobgambling.exe - **Function decrypt:** Both tools recover the XOR loop correctly. Ghidra names variables better (key, plaintext); rsleigh uses lVar1, lVar2. **Verdict: Correct, minor readability difference.** - **Function validate:** Ghidra recovers the early return on failure; rsleigh misses flow control, produces unreachable code. **Verdict: Major difference.** ``` -------------------------------- ### Raw firmware analysis example Source: https://github.com/shanebreazeale/rsleigh Invokes rsleigh on raw ARM32 firmware with a specified base address and target address. Use for firmware without a standard executable format. ```bash rsleigh ./firmware.bin --raw arm32 --base 0x08000000 0x08001235 ``` -------------------------------- ### Run tests and install CLI Source: https://github.com/shanebreazeale/rsleigh/blob/master/README.md Commands for testing the rsleigh project from a checkout with a Rust toolchain and make. Includes generating decoders, running the harness, running decompiler regression tests, pseudocode regression gate, and installing the CLI. ```bash make test # generate decoders and run the harness ``` ```bash cargo test -p rsleigh-decompile --release --lib ``` ```bash make decomp-bench # pseudocode regression gate ``` ```bash cargo install --path rsleigh-cli ``` -------------------------------- ### Run SMT fixture tests Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/smt-backend.md Builds the SMT fixtures and runs the CLI integration and library tests for the smt feature. Requires a host-built sample environment and the same native header/library setup as the successful build. A default-feature test run does not validate Z3 solving. ```bash bash test-harness/fixtures/smt/build.sh cargo test -p rsleigh-cli --features smt --test smt_explore_integration cargo test -p rsleigh-decompile --release --features smt --lib smt_explore cargo test -p rsleigh-decompile --release --features smt --lib smt_verify ``` -------------------------------- ### Round 1: agent brief with limit Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/AGENTS-rsleigh.md Run this command to get an agent brief with a limit of 5 results. Choose at most three addresses from the returned map for further analysis. ```bash rsleigh FILE --agent-brief --limit 5 ``` -------------------------------- ### Run current workflow with full corpus and optional fixtures Source: https://github.com/shanebreazeale/rsleigh/blob/master/test-harness/fixtures/agent-re/corpus.md Builds the CLI and runs the agent_re_eval example for the current workflow, producing full-results.json. The --write-fixtures DIR option writes deterministic inputs; otherwise temporary inputs are removed after the JSON report is saved. ```bash cargo run --release -p rsleigh-cli --example agent_re_eval -- \ target/release/rsleigh full-results.json --full-corpus \ --write-fixtures fixture-output/ ``` -------------------------------- ### Build and run agent re-evaluation Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/agent-re-evaluation.md Builds the rsleigh-cli in release mode and runs the agent_re_eval example, passing the built executable and an output file for results. ```bash cargo build --release -p rsleigh-cli cargo run --release -p rsleigh-cli --example agent_re_eval -- \ target/release/rsleigh agent-re-results.json ``` -------------------------------- ### Analyze tdpServer with rsleigh agent brief and search Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/showcase/firmware-investigations.md Use these commands to start with a function map and network API search on an extracted ELF executable like tdpServer. The --agent-brief flag provides a brief, and --search --api recvfrom searches for the recvfrom API. This uses the normal ELF workflow and does not require raw-image load settings. ```bash rsleigh ./tdpServer --agent-brief rsleigh ./tdpServer --search --api recvfrom ``` -------------------------------- ### Run cache benchmark for current and baseline builds Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/agent-re-evaluation.md Run the agent_re_eval example to benchmark cache performance for the current build and a baseline build. The first command writes results to agent-re-cache-results.json, the second to agent-re-cache-baseline.json with the --baseline flag. ```bash cargo run --release -p rsleigh-cli --example agent_re_eval -- \ target/release/rsleigh agent-re-cache-results.json --cache-benchmark cargo run --release -p rsleigh-cli --example agent_re_eval -- \ /path/to/baseline/rsleigh agent-re-cache-baseline.json --cache-benchmark --baseline ``` -------------------------------- ### Run benchmark comparison script Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/features.md Use this command from a checkout to run the repository's comparison scripts with a locally configured Ghidra installation. The script takes an executable file and a sample size option. ```bash scripts/bench-compare.sh ./sample.exe --sample 50 ``` -------------------------------- ### Run baseline workflow with full corpus Source: https://github.com/shanebreazeale/rsleigh/blob/master/test-harness/fixtures/agent-re/corpus.md Builds the CLI and runs the agent_re_eval example for the baseline workflow, producing baseline-results.json. The baseline uses SSA JSON, selects a variable from the legacy terminator, and queries that variable when one exists. ```bash cargo run --release -p rsleigh-cli --example agent_re_eval -- \ /path/to/baseline/rsleigh baseline-results.json --full-corpus --baseline ``` -------------------------------- ### Raw firmware analysis with architecture and base Source: https://github.com/shanebreazeale/rsleigh/blob/master/README.md Use for raw firmware, supplying the architecture and image base on every command. The first example decodes the firmware; the second selects a Thumb function for pseudocode. ```bash rsleigh ./firmware.bin --raw arm32 --base 0x08000000 ``` ```bash rsleigh ./firmware.bin --raw arm32 --base 0x08000000 0x08001235 ``` -------------------------------- ### Run rsleigh SMT candidate analysis commands Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/smt-backend.md Run the built rsleigh binary to generate a brief, inspect a function with card and pcode, and produce SMT candidates. Replace the example address with one from the target's function map. The --smt-candidates-cap and --smt-candidates-top flags control the candidate analysis. ```bash target/release/rsleigh ./sample.exe --agent-brief --limit 5 > brief.json target/release/rsleigh ./sample.exe 0x140001000 --card --pcode target/release/rsleigh ./sample.exe --smt-candidates 0x140001000 \ --smt-candidates-cap 16 --smt-candidates-top 5 \ > candidates.ndjson 2> candidates.stderr ``` -------------------------------- ### Build rsleigh with SMT on macOS (Homebrew) Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/smt-backend.md Install Z3 via Homebrew and build the rsleigh CLI with the smt feature on macOS. The CPATH and LIBRARY_PATH environment variables point the build to the Homebrew Z3 headers and libraries. ```bash brew install z3 CPATH=$(brew --prefix z3)/include LIBRARY_PATH=$(brew --prefix z3)/lib \ cargo build -p rsleigh-cli --release --features smt ``` -------------------------------- ### Manually trace a loop function with Ghidra vs rsleigh Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-17-decompiler-compare-implementation.md Example workflow for tracing a loop function. Shows side-by-side Ghidra and rsleigh pseudocode for process_string, documents the trace and verdict that both loops produce equivalent semantics with a minor safety-check difference. ```markdown ### Function: process_string **Ghidra:** ```c void process_string(char *input) { int i = 0; while(input[i] != '\0') { printf("%c", input[i]); i++; } } ``` **rsleigh:** ```c void process_string(char *input) { int i = 0; while(i < 256) { if (input[i] == 0) break; printf("%c", input[i]); i++; } } ``` **Trace:** - Both loop over input until null terminator - rsleigh adds safety check (i < 256) — minor difference - Semantically equivalent ✓ **Verdict:** Correct ``` -------------------------------- ### Run agent re-evaluation with baseline executable Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/agent-re-evaluation.md Runs the agent_re_eval example with a baseline executable and a separate output file, using the --baseline flag to preserve baseline results. ```bash cargo run --release -p rsleigh-cli --example agent_re_eval -- \ /path/to/baseline/rsleigh agent-re-baseline.json --baseline ``` -------------------------------- ### rsleigh CLI Usage Examples Source: https://github.com/shanebreazeale/rsleigh/blob/master/CLAUDE.md Command-line invocations for the rsleigh binary covering function listing, decompilation, disassembly, analysis, and various specialized features. Each command shows a distinct use case with its options. ```bash rsleigh # list functions ``` ```bash rsleigh [func2..] # decompile (name or 0xAddr) ``` ```bash rsleigh --all # decompile all (two-pass type prop) ``` ```bash rsleigh --all --jobs N --fn-timeout S # threads (default: cores); per-fn limit (default 10 s, 0 = none) ``` ```bash rsleigh --disasm # disassembly + P-code ``` ```bash rsleigh --sigs extra.json # additional signatures ``` ```bash rsleigh --fid file.fidb # additional FID database (repeatable) ``` ```bash rsleigh --no-fid-auto # disable bundled glibc/musl/libstdc++ DBs ``` ```bash rsleigh --pcode-json # raw P-code (debug) ``` ```bash rsleigh --ssa-json # post-fold SSA (debug) ``` ```bash rsleigh --json # JSON ``` ```bash rsleigh --search # find by string/pattern ``` ```bash rsleigh --search --api # find by API call ``` ```bash rsleigh --search --const # find by constant ``` ```bash rsleigh --summary # one-line per function ``` ```bash rsleigh --xrefs # callers + callees ``` ```bash rsleigh --yara # generate YARA ``` ```bash rsleigh --diff # side-by-side diff ``` ```bash rsleigh --taint # taint analysis ``` ```bash rsleigh --vulnscan # 27 vuln patterns ``` ```bash rsleigh --imphash # Mandiant imphash for PE ``` ```bash rsleigh --hashes # sha256, md5, imphash, size ``` ```bash rsleigh --ioc [--json] # IOC extraction (URLs/IPs/paths/registry/mutexes/secrets); see docs/cli-triage.md ``` ```bash rsleigh --xor-strings [--json] # brute single-byte XOR string recovery ``` ```bash rsleigh --sigcheck [--json] # Authenticode signer/issuer/timestamp/chain; see docs/cli-triage.md ``` ```bash rsleigh --resources [--dump DIR] [--json] # PE resource walk + extraction; see docs/cli-triage.md ``` ```bash rsleigh --callgraph # JSON + behavioral tags ``` ```bash rsleigh --classes [--json] # C++ hierarchies ``` ```bash rsleigh --compact # -24% size ``` ```bash rsleigh --brief # calls + cflow only, -35% ``` ```bash rsleigh --min-complexity N # skip trivial funcs ``` ```bash rsleigh --annotate-crypto # rewrite crypto consts to symbolic names ``` ```bash rsleigh --vm-dispatch # extract VM dispatcher metadata ``` ```bash rsleigh --vm-classify-handlers # opcode handler classifier ``` ```bash rsleigh --tag-dispatch # CMP r8/JZ chain extractor ``` ```bash rsleigh --summarise-handlers # IAT-API + stack-pop signature ``` ```bash rsleigh --vm-bytecode : --vm-handlers # VM bytecode disasm ``` ```bash rsleigh --seh-fixpoint # SEH-driven SMC patch fixpoint ``` ```bash rsleigh --raw # raw firmware blob ``` ```bash rsleigh --capabilities [--json] # target-free agent operation catalog (+ --help, --version [--json]) ``` ```bash rsleigh --card --evidence-store S # content-addressed rsleigh.evidence/v1 record (also brief/slice/compare) ``` ```bash rsleigh --export-bundle B --evidence-store S # then [] --verify-bundle B / --import-bundle B ``` ```bash rsleigh --investigate D --question TEXT # then [] --investigation D [--handoff | --expect-revision N --ACTION] ``` ```bash rsleigh --compare [--pair A:B] --json # per-dimension function comparison (--diff renders same model) ``` ```bash rsleigh --mcp # MCP stdio server: capabilities, agent-brief, card, ssa-slice, verify-bundle ``` -------------------------------- ### Build and test commands for rsleigh Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/llm-re-completion-audit.md Commands to build the CLI, run tests for decompile and CLI libraries, check pcode-ir without default features, and run the agent_re_eval example with various arguments. These commands passed on the audited source tree. ```bash cargo build --release -p rsleigh-cli cargo test --release -p rsleigh-decompile --lib --tests cargo test --release -p rsleigh-cli --lib --tests cargo test --release -p test-harness cargo check -p pcode-ir --no-default-features cargo run --release -p rsleigh-cli --example agent_re_eval -- \ target/release/rsleigh seed-results.json cargo run --release -p rsleigh-cli --example agent_re_eval -- \ target/release/rsleigh full-results.json --full-corpus cargo run --release -p rsleigh-cli --example agent_re_eval -- \ target/release/rsleigh cache-results.json --cache-benchmark ``` -------------------------------- ### Extract-functions example for binary function discovery Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-17-decompiler-compare-implementation.md Extracts discoverable functions from a binary using goblin for ELF and PE formats. Filters global functions from ELF symbol table and PE exports, then selects 5-10 diverse functions by sorting by address and size. Outputs JSON with address, name, and size. ```rust /// Extract discoverable functions from a binary. /// Usage: cargo run -p test-harness --example extract-functions -- /// Outputs: JSON with [{"addr": 0x..., "name": "...", "complexity": N}, ...] use std::path::Path; fn main() { let binary_path = std::env::args().nth(1).unwrap_or_else(|| { eprintln!("Usage: extract-functions "); std::process::exit(1); }); let data = match std::fs::read(&binary_path) { Ok(d) => d, Err(e) => { eprintln!("Could not read {}: {}", binary_path, e); return; } }; let obj = match goblin::Object::parse(&data) { Ok(o) => o, Err(e) => { eprintln!("Failed to parse binary: {}", e); return; } }; let mut functions = Vec::new(); // Extract from symbol table match &obj { goblin::Object::Elf(elf) => { for sym in elf.syms.iter() { if sym.st_bind() == goblin::elf::sym::STB_GLOBAL && sym.st_type() == goblin::elf::sym::STT_FUNC && sym.st_value > 0 { if let Some(name) = elf.strtab.get_at(sym.st_name) { if !name.is_empty() && !name.starts_with("_") { functions.push(serde_json::json!({ "addr": format!("0x{:x}", sym.st_value), "name": name, "size": sym.st_size, })); } } } } } goblin::Object::PE(pe) => { for export in pe.export_table.iter().flat_map(|e| e.exports.iter()) { functions.push(serde_json::json!({ "addr": format!("0x{:x}", export.address as u64), "name": export.name.unwrap_or("unnamed"), "size": 0, })); } } _ => {} } // Sort by address functions.sort_by_key(|f| { u64::from_str_radix(f["addr"].as_str().unwrap().trim_start_matches("0x"), 16) .unwrap_or(0) }); // Pick 5-10 diverse functions: first, middle, complex ones by size let selected = if functions.len() > 10 { let mut picked = vec![functions[0].clone()]; picked.push(functions[functions.len() / 2].clone()); picked.push(functions[functions.len() - 1].clone()); // Add largest functions let mut by_size = functions.clone(); by_size.sort_by_key(|f| -(f["size"].as_u64().unwrap_or(0) as i64)); for i in 0..2.min(by_size.len()) { if !picked.contains(&by_size[i]) { picked.push(by_size[i].clone()); } } picked } else { functions }; println!("{}", serde_json::to_string_pretty(&selected).unwrap()); } ``` -------------------------------- ### Raw firmware commands with explicit architecture and base Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/AGENTS-rsleigh.md For raw firmware, keep the architecture and base explicit on every command. The example odd ARM32 address selects Thumb mode. Raw function output is pseudocode; --disasm does not currently change that renderer. ```bash rsleigh firmware.bin --raw arm32 --base 0x08000000 rsleigh firmware.bin --raw arm32 --base 0x08000000 0x08001235 ``` -------------------------------- ### main function Source: https://github.com/shanebreazeale/rsleigh/blob/master/test-harness/fixtures/ghidra_compare_output.txt Demonstrates the other functions with sample inputs and prints results. Uses stack canary for protection. ```c int main(int argc,char **argv) { long lVar1; uint uVar2; char *pcVar3; Point b; Point a; char **argv_local; int argc_local; int sorted [10]; int nums [5]; lVar1 = *(long *)PTR____stack_chk_guard_100001000; uVar2 = add(3,4); _printf("add(3,4) = %d\n",(ulong)uVar2); uVar2 = factorial(6); _printf("factorial(6) = %d\n",(ulong)uVar2); nums[0] = (int)DAT_100000a30; nums[1] = DAT_100000a30._4_4_; nums[2] = (int)DAT_100000a38; nums[3] = DAT_100000a38._4_4_; nums[4] = DAT_100000a40; uVar2 = sum_array(nums,5); _printf("sum = %d\n",(ulong)uVar2); uVar2 = string_length("hello world"); _printf("strlen = %d\n",(ulong)uVar2); a = DAT_100000a78; b = DAT_100000a80; uVar2 = manhattan_distance(&a,&b); _printf("manhattan = %d\n",(ulong)uVar2); pcVar3 = day_name(3); _printf("day = %s\n",pcVar3); uVar2 = apply(add,5,6); _printf("apply(add,5,6) = %d\n",(ulong)uVar2); _memcpy(sorted,&DAT_100000a50,0x28); uVar2 = binary_search(sorted,10,0x17); _printf("search(23) = %d\n",(ulong)uVar2); if (*(long *)PTR____stack_chk_guard_100001000 == lVar1) { return 0; } /* WARNING: Subroutine does not return */ ___stack_chk_fail(); } ``` -------------------------------- ### Raw firmware and WebAssembly frontend commands Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-reference.md These use separate frontends; do not carry native-container mode assumptions into them. Raw firmware starts with `--raw ARCH --base ADDR`, then add a function address. WebAssembly lists with `rsleigh FILE`, then select a listed name or `func_N`. ```bash rsleigh ./firmware.bin --raw arm32 --base 0x08000000 ``` ```bash rsleigh ./firmware.bin --raw arm32 --base 0x08000000 0x08001235 ``` ```bash rsleigh ./module.wasm ``` ```bash rsleigh ./module.wasm func_0 ``` -------------------------------- ### Spot-check main output Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-16-double-negation-condition-plan.md Runs the CLI in release mode on a specific binary and address, showing the first 30 lines. Confirm the double-negation is gone from the if condition. ```bash cargo run -p rsleigh-cli --release -- \ /Users/shane/Downloads/test_bin/cb_baristas_secret_x64.exe \ 0x140001e41 2>&1 | head -30 ``` -------------------------------- ### struct FieldBits Source: https://github.com/shanebreazeale/rsleigh Represents a half-open bit range wrapping `Range`. Provides methods to get the start, end, and length of the range. ```APIDOC ## struct FieldBits ### Description Represents a half-open bit range wrapping `Range`. Provides methods to get the start, end, and length of the range. ### Methods - `pub fn new(start: NumberUnsigned, end: NumberUnsigned) -> Self` - Creates a new `FieldBits` from the given start and end. Panics via `unreachable!()` if `start >= end`. - `pub fn len(&self) -> NumberNonZeroUnsigned` - Returns the length of the range. - `pub fn start(&self) -> NumberUnsigned` - Returns the start of the range. - `pub fn end(&self) -> NumberNonZeroUnsigned` - Returns the end of the range. - `pub fn field_min_len(&self) -> NumberNonZeroUnsigned` - Returns the minimum length of the field. ### Trait Implementations - `impl RangeBounds for FieldBits` - Implements the `RangeBounds` trait. - `TryFrom` / `TryFrom` - Returns `Err(SleighError::InvalidBitrange(span))` for empty ranges. ``` -------------------------------- ### Run decompiler-compare on an ARM binary (pick first) Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-17-decompiler-compare-implementation.md First list the ARM binaries, then run decompiler-compare on the first one (using ls and head -1 to select it). Expect results/arm*/ directory with comparison outputs. ```bash ls -lh ~/Downloads/test_bin/arm-binaries/ ``` ```bash cd /Users/shane/repos/rsleigh scripts/decompiler-compare.sh "$(ls ~/Downloads/test_bin/arm-binaries/* | head -1)" ``` -------------------------------- ### Feature Scoring Matrix Example Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/specs/2026-04-17-decompiler-quality-comparison-design.md Example comparison matrix showing rsleigh and Ghidra scores for features across functions. ```text Function | func_add | func_strlen | func_memcpy Strings | ✓ 2/2 | ✓ 1/1 | ✓ 3/3 Var names | ✓ Good | ✓ Good | ⚠ Partial Control flow | ✓ if | ✓ while | ✓ switch Type inference | ✓ Yes | ✓ Yes | ⚠ Partial Readability | ✓ Good | ✓ Good | ⚠ Some noise ``` -------------------------------- ### Install rsleigh v0.7.0 with Cargo Source: https://github.com/shanebreazeale/rsleigh/blob/master/README.md Install the rsleigh CLI v0.7.0 from crates.io using Cargo. Requires a Rust toolchain. ```bash cargo install rsleigh --version 0.7.0 --locked ``` -------------------------------- ### Usage Example: Matching a stripped function Source: https://github.com/shanebreazeale/rsleigh Example showing how to match a stripped function against the bundled databases using bundled_dbs and identify. ```APIDOC ## Usage Example: Matching a stripped function ### Description Matching a stripped function against the bundled databases. ### Example ```rust use rsleigh_fid::{bundled_dbs, identify}; use rsleigh_api::Architecture; let body = /* decoded function body bytes */; for (lib, db) in bundled_dbs(Architecture::X86_64) { if let Some(name) = identify(Architecture::X86_64, body, 0x140001000, &db) { println!("{lib}: {name}"); } } ``` ``` -------------------------------- ### Usage Example: Building a database Source: https://github.com/shanebreazeale/rsleigh Example showing how to build a database (ingest side, like rsleigh-fid-gen) using FidDb, FidEntry, fingerprint, and FidHashQuad. ```APIDOC ## Usage Example: Building a database ### Description Building a database (ingest side, like `rsleigh-fid-gen`). ### Example ```rust use rsleigh_fid::db::{FidDb, FidEntry}; use rsleigh_fid::ingest::fingerprint; use rsleigh_fid::hash::FidHashQuad; use rsleigh_api::Architecture; let mut db = FidDb::new(); let lib_id = db.add_lib("myapp"); // (addr, body) pairs from a symbol table or disassembly for (addr, body) in functions { if let Some(hash) = fingerprint(Architecture::X86_64, body, addr, |target| { callee_index.get(&target).copied() // callee addr → full hash }) { db.insert(FidEntry { hash, lib_id, name: "my_func".into() }); } } // Round-trip through the on-disk format: db.write(std::fs::File::create("myapp-x86_64.fidb")?)?; let loaded = FidDb::read(std::fs::File::open("myapp-x86_64.fidb")?)?; ``` ``` -------------------------------- ### Example finding record in rsleigh.finding/v1 schema Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/findings-ndjson.md Shows a single finding record with required fields like schema, kind, producer, confidence, stage, severity, function, address, summary, source, sink, and verdict. The confidence 'proved' is an evidence label, not a positive result; check verdict for reachability. ```json { "schema": "rsleigh.finding/v1", "kind": "vulnerability.taint_flow", "producer": "smt-candidates", "confidence": "proved", "stage": "prove", "severity": "HIGH", "function": "main", "address": "0x401000", "summary": "Command flow from recv to system (Reachable)", "source": "recv", "sink": "system", "verdict": "Reachable" } ``` -------------------------------- ### Ensure float-typed vars get correct local declaration types Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-15-float-xmm-type-recovery.md Existing code maps variable name prefixes to types, but may need a size-based override for float-sized XMM vars to get fVar prefix. ```rust } else if name.starts_with("fVar") { "float" } else if name.starts_with("dVar") { "double" ``` ```rust // XMM register with float-sized (4-byte) result → fVar prefix if name.starts_with("dVar") && vdef.size == 4 && vdef.inferred_type == InferredType::Float { // Rename to fVar name = name.replace("dVar", "fVar"); } ``` -------------------------------- ### FieldBits struct definition Source: https://github.com/shanebreazeale/rsleigh A half-open bit range wrapping Range. new() panics via unreachable!() if start >= end. Provides len(), start(), end(), and field_min_len() methods. ```rust pub struct FieldBits(pub(crate) std::ops::Range); impl FieldBits { pub fn new(start: NumberUnsigned, end: NumberUnsigned) -> Self // panics via unreachable!() if start >= end pub fn len(&self) -> NumberNonZeroUnsigned pub fn start(&self) -> NumberUnsigned pub fn end(&self) -> NumberNonZeroUnsigned pub fn field_min_len(&self) -> NumberNonZeroUnsigned } impl RangeBounds for FieldBits { ... } ``` -------------------------------- ### Run full test-harness suite Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-16-rsp-local-naming-plan.md Command to run the full test-harness suite and show the last 30 lines of output. ```bash cargo test -p test-harness 2>&1 | tail -30 ``` -------------------------------- ### define_signatures! macro with usage example Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-12-function-signatures.md Declarative macro for defining signatures concisely. The usage example shows the syntax for declaring functions with parameters, variadic ellipsis, and optional return type. The macro expands to an array of FuncSig entries, defaulting return type to Void and detecting variadic presence. ```rust /// Declarative macro for defining signatures concisely. /// /// Usage: /// ```ignore /// define_signatures! { /// fn printf(format: ConstCharPtr, ...) -> Int; /// fn malloc(size: SizeT) -> VoidPtr; /// fn free(ptr: VoidPtr); /// } /// ``` macro_rules! define_signatures { ($(fn $name:ident( $($pname:ident : $pty:ident),* $(, ...)? ) $(-> $ret:ident)?;)*) => { &[ $( FuncSig { name: stringify!($name), ret: define_signatures!(@ret $($ret)?), params: &[ $(SigParam { name: stringify!($pname), ty: SigType::$pty }),* ], variadic: define_signatures!(@variadic $($name)* $(...)? ), }, )* ] }; // Return type: default to Void if omitted (@ret) => { SigType::Void }; (@ret $ret:ident) => { SigType::$ret }; // Variadic detection: if `...` is present after params (@variadic $($name:ident)* ...) => { true }; (@variadic $($name:ident)*) => { false }; } // Re-export the macro for use in sub-modules pub(crate) use define_signatures; ``` -------------------------------- ### Run full test-harness suite Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-17-string-false-positive-plan.md Run the full test-harness suite and show the last 10 lines. Expected: 9 passed; 0 failed. ```bash cd /Users/shane/repos/rsleigh cargo test -p test-harness 2>&1 | tail -10 ``` ```text test result: ok. 9 passed; 0 failed ``` -------------------------------- ### sub function Source: https://github.com/shanebreazeale/rsleigh/blob/master/test-harness/fixtures/rsleigh_compare_output.txt Subtracts b from a and returns the result. Simple arithmetic function example. ```assembly return a - b; ``` -------------------------------- ### Regenerate Ghidra Oracles Source: https://github.com/shanebreazeale/rsleigh/blob/master/test-harness/fixtures/oracle/README.md Commands to refresh all oracle fixtures or a specific fixture using the Ghidra installation directory. ```bash GHIDRA_INSTALL_DIR=/opt/ghidra scripts/ghidra-refresh-oracles.sh # Or refresh one fixture directly: GHIDRA_INSTALL_DIR=/opt/ghidra \ scripts/ghidra-export-oracle.sh \ test-harness/fixtures/oracle/x86_64/ret_imm16.bin \ x86:LE:64:default \ test-harness/fixtures/oracle/x86_64/ret_imm16.ghidra.json ``` -------------------------------- ### Save spot-checks.md using heredoc Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-17-decompiler-compare-implementation.md Creates the spot-checks.md file with a heredoc, writing a summary template for 12 functions across 4 binaries, with placeholders for per-binary findings and an overall verdict. ```bash cat > /Users/shane/repos/rsleigh/results/spot-checks.md << 'EOF' # Spot-Checks for Semantic Correctness ## Summary Spot-check review of 2-3 complex functions per binary (12 functions total) for semantic correctness. ### main.exe [Document spot-checks for main.exe functions here] ### crackme_bobgambling.exe [Document spot-checks for crackme functions here] ### elf-Linux-x64-bash [Document spot-checks for bash functions here] ### ARM Binary [Document spot-checks for ARM functions here] --- **Overall:** [X] functions correct, [Y] minor differences, [Z] major differences. EOF ``` -------------------------------- ### FUNCTION Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-reference.md Get the full pseudocode for a function. Outputs text with no card output cap. ```APIDOC ## FUNCTION ### Description Get the full pseudocode for a function. Outputs text with no card output cap. ### Method CLI ### Endpoint `rsleigh FILE FUNCTION` ### Parameters #### Path Parameters - `FILE` (string) - Required - Path to the binary file to analyze. - `FUNCTION` (string) - Required - Name or address of the function to decompile. ### Response #### Success Response (0) - Text output with full pseudocode. #### Partial Evidence (2) - Partial evidence produced. #### Failure (1) - Command failed. ``` -------------------------------- ### FILE --investigate DIR --question TEXT Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-reference.md Start a durable investigation with a question. ```APIDOC ## FILE --investigate DIR --question TEXT ### Description Start a durable investigation with a question. ### Method CLI ### Endpoint `rsleigh FILE --investigate DIR --question TEXT` ### Parameters #### Path Parameters - `FILE` (string) - Required - Path to the binary file to analyze. - `DIR` (string) - Required - Directory to store the investigation. - `TEXT` (string) - Required - Question to investigate. ### Response #### Success Response (0) - Investigation started. #### Partial Evidence (2) - Partial evidence produced. #### Failure (1) - Command failed. ``` -------------------------------- ### Run full test suite Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/specs/2026-04-16-ssa-call-clobber-design.md Run the full test suite for the test-harness package; all 240 tests and 7200+ asserts must pass. ```bash cargo test -p test-harness ``` -------------------------------- ### add function Source: https://github.com/shanebreazeale/rsleigh/blob/master/test-harness/fixtures/rsleigh_compare_output.txt Adds two integer arguments and returns the result. Used as a simple function example in the rsleigh test harness. ```assembly return a + b; ``` -------------------------------- ### cli::entrypoint() Source: https://github.com/shanebreazeale/rsleigh Entry point for CLI dispatch, usable by embedding tools. ```APIDOC ## [Rust] cli::entrypoint() ### Description Public function invoked by main.rs; used by embedding tools that want CLI dispatch in-process. ### Function - `pub fn entrypoint()` ``` -------------------------------- ### --disasm FUNCTION Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-reference.md Get the decoded instructions for a function. Outputs assembly text without P-code. ```APIDOC ## --disasm FUNCTION ### Description Get the decoded instructions for a function. Outputs assembly text without P-code. ### Method CLI ### Endpoint `rsleigh FILE --disasm FUNCTION` ### Parameters #### Path Parameters - `FILE` (string) - Required - Path to the binary file to analyze. - `FUNCTION` (string) - Required - Name or address of the function to disassemble. ### Response #### Success Response (0) - Assembly text output. #### Partial Evidence (2) - Partial evidence produced. #### Failure (1) - Command failed. ``` -------------------------------- ### Add serde_json dependency to test-harness Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-17-decompiler-compare-implementation.md Adds serde_json as a dependency to the test-harness Cargo.toml. Required for the extract-functions example to serialize function data to JSON. ```toml serde_json = "1.0" ``` -------------------------------- ### Recommended sequence commands Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/agent-workflow.md Run these commands in order to build a capped map, inspect xrefs, view a bounded disassembly/P-code card, and request pseudocode after the lift looks coherent. ```bash rsleigh sample.exe --agent-brief rsleigh sample.exe --xrefs 0x140001000 --json rsleigh sample.exe 0x140001000 --card --pcode rsleigh sample.exe 0x140001000 --card --pcode --decompile ``` -------------------------------- ### --ssa-slice FUNCTION --condition 0xADDRESS Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-reference.md Get a bounded backward slice for a condition at a specific address. ```APIDOC ## --ssa-slice FUNCTION --condition 0xADDRESS ### Description Get a bounded backward slice for a condition at a specific address. ### Method CLI ### Endpoint `rsleigh FILE --ssa-slice FUNCTION --condition 0xADDRESS [--max-nodes N] [--max-depth N]` ### Parameters #### Path Parameters - `FILE` (string) - Required - Path to the binary file to analyze. - `FUNCTION` (string) - Required - Name or address of the function to slice. #### Query Parameters - `--condition 0xADDRESS` (string) - Required - Address of the condition. - `--max-nodes N` (integer) - Optional - Maximum number of nodes to include. - `--max-depth N` (integer) - Optional - Maximum depth to traverse. ### Response #### Success Response (0) - Bounded backward slice for the condition. #### Partial Evidence (2) - Partial evidence produced. #### Failure (1) - Command failed. ``` -------------------------------- ### Test on a real-world binary Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-15-float-xmm-type-recovery.md Decompiles a test binary with all functions and shows the first 100 lines. Verifies no panics and that non-float functions are unchanged. ```bash cargo run -p rsleigh-cli --release -- test-harness/test_bin/ --all 2>/dev/null | head -100 ``` -------------------------------- ### --pcode-json FUNCTION Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/cli-reference.md Get the lifted semantics for a function. Outputs `rsleigh.pcode/v2` with raw typed operations and readable text. ```APIDOC ## --pcode-json FUNCTION ### Description Get the lifted semantics for a function. Outputs `rsleigh.pcode/v2` with raw typed operations and readable text. ### Method CLI ### Endpoint `rsleigh FILE --pcode-json FUNCTION` ### Parameters #### Path Parameters - `FILE` (string) - Required - Path to the binary file to analyze. - `FUNCTION` (string) - Required - Name or address of the function to inspect. ### Response #### Success Response (0) - JSON output in `rsleigh.pcode/v2` format. #### Partial Evidence (2) - Partial evidence produced. #### Failure (1) - Command failed. ``` -------------------------------- ### Basic decode (x86-64) Source: https://github.com/shanebreazeale/rsleigh Decodes a single instruction on the x86-64 architecture and asserts the disassembly and length. Uses the crate's own doc example. ```rust use rsleigh_api::{Decoder, Architecture}; let mut decoder = Decoder::new(Architecture::X86_64); let inst = decoder.decode(&[0x48, 0x89, 0xd8], 0x1000).unwrap(); assert_eq!(inst.disassembly, "MOV RAX,RBX"); assert_eq!(inst.len, 3); ``` -------------------------------- ### Run full decompile test suite Source: https://github.com/shanebreazeale/rsleigh/blob/master/docs/superpowers/plans/2026-04-16-rsp-local-naming-plan.md Command to run the full decompile test suite and show the last 20 lines of output. ```bash cargo test -p rsleigh-decompile 2>&1 | tail -20 ```