https://github.com/matrixeditor/dexrs
Dalvik Executable (DEX) parser, disassembler and (partial) decompiler with a Python binding.
https://github.com/matrixeditor/dexrs
art dalvik dalvik-parser dex pyo3 smali
Last synced: about 1 month ago
JSON representation
Dalvik Executable (DEX) parser, disassembler and (partial) decompiler with a Python binding.
- Host: GitHub
- URL: https://github.com/matrixeditor/dexrs
- Owner: MatrixEditor
- License: mit
- Created: 2024-06-30T07:31:39.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-15T06:42:24.000Z (7 months ago)
- Last Synced: 2025-04-02T11:51:34.299Z (6 months ago)
- Topics: art, dalvik, dalvik-parser, dex, pyo3, smali
- Language: Rust
- Homepage:
- Size: 188 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DEXrs
> [!IMPORTANT]
> Branch `v2-rewrite` contains a complete rewrite of this library including a Python binding. Installation is as follows:
>
> Crate:
> ```bash
> # add to project
> cargo add --git https://github.com/MatrixEditor/dexrs --branch dev/v2-rewrite
> # install lib
> cargo install --git https://github.com/MatrixEditor/dexrs --branch dev/v2-rewrite
> ```
>
> Python Binding
> ```bash
> pip install -v git+https://github.com/MatrixEditor/dexrs@dev/v2-rewrite
> ```**DEXrs** is an exploratory project in Rust aimed at developing a decompiler for Android executable files (DEX files).
#### What this project already covers:
- [x] A (*blazingly fast*) DEX file parser using lazy parsing
- [x] A simple disassembler for Dalvik byte code
- [x] A simplistic Smali decompiler#### Roadmap
- [ ] Basic Java decompiler
- [ ] Bytecode modification and DEX rebuild## Installation
Install DEXrs using Cargo:
```bash
cargo install --git https://github.com/MatrixEditor/dexrs dexrs
```## Usage
### Disassembling DEX files
Here’s a quick example of how to disassemble a DEX file:
```rust
let mut f = File::open("classes.dex").expect("file not found");
// parse DEX input and verify its contents
let mut dex = Dex::read(&mut f, true)?;let class = dex.get_class_def(0)?;
if let Some(method) = class.get_direct_method(0) {
for insn in method.disasm(&mut dex)? {
println!(" {:#06x}: {:?}", insn.range.start, insn);
}
}
```## Decompilation to Smali
```rust
use dexrs::smali::SmaliWrite;let mut f = File::open("classes.dex").expect("file not found");
let mut dex = Dex::read(&mut f, true)?;let class = dex.get_class_def(0)?;
let mut stdout = std::io::stdout();
stdout.write_class(&class, &mut dex)?;
```## License
This project is licensed under the [MIT license](LICENSE)