Rust Solana Opcode Extractor is a tool designed to decode, analyze, and extract BPF opcodes from Solana smart contracts. This utility leverages the solana_rbpf
library to map raw BPF instructions to human-readable operations, enabling developers to gain deeper insights into the structure and execution of Solana programs.
- Extract and decode BPF instructions from compiled Solana programs.
- Map raw opcodes to their corresponding operations using
solana_rbpf
. - Generate a detailed JSON output with decoded operations, operands, and metadata.
- Analyze program flow for debugging and optimization.
- Parses a JSON file (
output.json
) containing BPF instructions. - Uses the
solana_rbpf
library to decode the instructions. - Maps each instruction to its corresponding operation and extracts additional metadata.
- Outputs the decoded instructions into a JSON file (
bytecode.json
).
- Rust installed.
- Familiarity with Solana development and BPF opcodes.
Clone the repository and build the project:
git clone https://github.com/luishsr/rust-solana-opcode-extractor.git
cd rust-solana-opcode-extractor
cargo build --release
- Ensure you have a valid
output.json
file containing BPF instructions (generated by your Solana program analysis tool). - Run the executable:
./target/release/rust-solana-opcode-extractor path/to/output.json path/to/bytecode.json
- The decoded instructions will be saved to
bytecode.json
.
Input (output.json
):
{
"file": "example_program.so",
"instructions": [
"[95, 00, 00, 00, 00, 00, 00, 00]",
"[79, 12, 08, 00, 00, 00, 00, 00]"
],
"type": "BPFInstructions"
}
Output (bytecode.json
):
[
{
"opcode": "EXIT",
"operation": "Exit",
"operands": [],
"metadata": {}
},
{
"opcode": "MOV32_IMM",
"operation": "Move Immediate",
"operands": ["dst=1", "src=0", "imm=8"],
"metadata": {}
}
]
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Solana for the innovative blockchain platform.
- solana_rbpf for the BPF tools and utilities.
Happy decoding!