A Graph-Based ROP Gadget Finder for RISC-V architectures
Project description
LCSAJdump
Universal Graph-Based Framework for Automated Gadget Discovery
LCSAJdump is a static analysis framework designed to discover Return-Oriented Programming (ROP) and Jump-Oriented Programming (JOP) gadgets. Unlike traditional scanners, LCSAJdump is architecture-agnostic and employs a graph-based approach to uncover vulnerabilities invisible to common linear tools.
Why LCSAJdump?
Common ROP scanners use a linear "sliding-window" approach over the binary's executable bytes. This method systematically fails to identify Shadow Gadgets: execution chains that traverse non-contiguous memory blocks connected by unconditional jumps or conditional branches.
LCSAJdump overcomes this limitation by reconstructing the Control-Flow Graph (CFG) through LCSAJ (Linear Code Sequence and Jump) analysis. By modeling the binary as a directed graph of basic blocks, the tool identifies:
- Contiguous Gadgets: Standard linear sequences terminating in a control-flow transfer.
- Shadow Gadgets (Non-Contiguous): Complex chains that bypass "bad bytes" (e.g., null bytes) by utilizing instructions that would otherwise be unreachable via linear scanning.
Key Features
- Multi-Architecture Support: Native support for RISC-V (64GC), x86-64, and ARM64, easily extendable to other architectures via modular profiles.
- Graph-Based Analysis: Segments the
.textsection into LCSAJ basic blocks and reconstructs flow relationships usingNetworkX. - Rainbow BFS Algorithm: Proprietary backward Breadth-First Search starting from control-flow sinks. Now features an O(1) Early-Drop Uniqueness Filter and Hard-Cap Instruction Limits to prevent state explosion and ensure ultra-fast analysis even on dense CISC binaries.
- Architecture-Specific Heuristic Scoring: Dynamic ranking system that evaluates gadgets based on architecture-specific traits (e.g., heavy length penalties for x86_64/ARM, dynamic bonuses for critical argument registers like
rdiorx0). - Pruning Parameters: Configurable "Darkness" factor to balance analysis depth and performance, preventing infinite loops in cyclic graphs.
Supported Architectures
(see Benchmarks).
LCSAJdump is designed to be universal. Currently supported:
- RISC-V 64-bit (RV64GC): Full support for compressed 16-bit instructions.
- x86-64: Handles variable-length overlapping instructions. Safely navigates dense graphs without memory explosion.
- ARM64: Handles 32-bit instructions and deeply filters out bloated gadgets via strict heuristic penalties.
- Other Architectures: Can be easily implemented by defining new profiles in
config.py.
Installation
Via Pip (Recommended)
pip install lcsajdump
From Source (Development)
git clone [https://github.com/Chris1sFlaggin/LCSAJdump.git](https://github.com/Chris1sFlaggin/LCSAJdump.git)
cd LCSAJdump
pip install -r requirements.txt
Usage
LCSAJdump offers a powerful CLI for precise binary analysis:
Standard Analysis (Default RISC-V):
python LCSAJdump.py <path_to_binary>
Advanced Analysis (Specifying Architecture):
python LCSAJdump.py -a riscv64 -d 15 -k 100 -l 20 --verbose <path_to_binary>
CLI Options:
Output Example
https://asciinema.org/a/n1UDtLoqeX3paHt7
Contributing (Open for Forks!)
The framework is open to new implementations. To add a new architecture:
- Fork the repository.
- Open
lcsajdump/core/config.py. - Add a new profile to the
ARCH_PROFILESdictionary, defining jump mnemonics, return mnemonics, and registers for the desired architecture (e.g., x86_64). - Submit a Pull Request.
License
This project is released under the MIT license. See the LICENSE file for details.
Project Link
Visit the project web page: LCSAJdump web page
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lcsajdump-1.1.2-py3-none-any.whl.
File metadata
- Download URL: lcsajdump-1.1.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a2dd82d3bb182c74ddd182dba2de29a56745358abe5a487fe9bdb0c973a0da5
|
|
| MD5 |
937c02e680a4ab7826147e85ba2a0ca3
|
|
| BLAKE2b-256 |
3d6f0b39f69d0d3b289b55948941850d006731417c477962bc197946f6507457
|