sleighcraft
1.0.0
Sleighcraft是Bincraft项目之一。
SleighCraft是基于Ghidra的分解器实现的解码器(或线性拆卸器)。 Sleighcraft可用于Rust或Python,具有高级和低级API。
总的来说, sleighcraft就像Capstone一样,但带有IR和更多的拱门。
特征:
目标:提供
:未提供
?:在建筑中
?:不确定,也许不是
与Capstone的比较:
| 特征 | 雪橇 | 顶峰发动机 |
|---|---|---|
| 拆卸 | ✔️ | ✔️ |
| ir | ✔️️ | |
| C API | ? | ✔️ |
| 自定义体系结构 | 目标 |
与Capstone的体系结构比较(根据Capstone Arch列表):
| 拱名 | 雪橇 | 顶峰发动机 |
|---|---|---|
| 6502 | ✔️ | ? |
| 6805 | ✔️ | ? |
| 8051 | ✔️ | ? |
| 8048 | ✔️ | ? |
| 8085 | ✔️ | ? |
| 68000 | ✔️ | ? |
| AARCH64(ARMV8) | ✔️ | 配秀 |
| 手臂 | ✔️ | 配秀 |
| CP1600 | ✔️ | ? |
| CR16 | ✔️ | ? |
| AVR8 | ✔️ | 配话? |
| 达尔维克 | ✔️ | ? |
| JVM | ✔️ | ? |
| mips | ✔️ | 配秀 |
| PowerPC | ✔️ | 配秀 |
| Sparc | ✔️ | 配秀 |
| Tricore | ✔️ | ? |
| Riscv | ✔️ | ? |
| Z80 | ✔️ | ? |
| 系统z | ✔️ | |
| xcore | ✔️ |
锈
使用货物:
sleighcraft = { git = " https://github.com/StarCrossPortal/sleighcraft " }在Crates-io上提交的存储库有点大(由于预定义的SLA文件),但请您自行保存编译雪橇文件的综合体。
Python:
# quick install it with pip
$ pip3 install bincraft
# or download binaries than choose the corresponding architecture
$ pip3 install bincraft-0.1.0-cp39-cp39-Arch.whl
# or manual, to do this, you need to have rust compiler installed and maturin
# better with rustup.
$ pip3 install maturin
$ maturin build
$ pip3 install bincraft-0.1.0-cp39-cp39-Arch.whlnodejs:
# quick install it with npm
$ npm i bincraft
# or manual, to do this, you need to have rust compiler installed, nodejs and neon
# better with rustup.
$ npm install -g neon-cli
$ neon build可以参考doc.rs查看如何使用生锈绑定。
Python结合:
from bincraft import Sleigh
code = [ 0x90 , 0x31 , 0x32 ] # code to disassemble
# init the sleigh engine Sleigh(arch, code)
sleigh = Sleigh ( "x86" , code )
# now we are prepared to disassemble!
# disasm(start_addr)
for asm in sleigh . disasm ( 0 ):
addr = asm . addr ()
mnem = asm . mnemonic ()
body = asm . body ()
# quite like capstone, right?
print ( f'Addr: { addr } t mnemonic: { mnem } t body: { body } ' )
# but! we also have the IR!
pcodes = asm . pcodes ()
for pcode in pcodes :
opcode = pcode . opcode ()
vars = pcode . vars ()
print ( f'opcode: { opcode } t vars: { vars } t ' )
print ()nodejs绑定:
const Sleigh = require ( 'bincraft' ) ;
//or const Sleigh = require('.');
// init the sleigh engine Sleigh(arch, code) like python
const sleigh = new Sleigh ( "x86" , [ 0x90 , 90 ] ) ;
// disasm(start_addr)
// - start: Default is 0
const asms = sleigh . disasm ( ) ;
asms . forEach ( asm => {
let addr = asm . addr ( ) ;
let mnemonic = asm . mnemonic ( ) ;
let body = asm . body ( ) ;
// dump instruction
console . log ( `addr: ${ addr } t mnemonic: ${ mnemonic } t body: ${ body } ` ) ;
// And we have IR!
let pcodes = asm . pcodes ( ) ;
pcodes . forEach ( pcode => {
opcode = pcode . opcode ( ) ;
vars = pcode . vars ( ) ;
console . log ( `opcode: ${ opcode } t vars: ${ vars } ` ) ;
} ) ;
} ) ;锈(有点低水平):
// Overall procedure:
// 1. get the spec, this is where we know how to decode anything
// 2. get a loader, this is where we fill the input bytes to the engine.
// A predefined loader is provided: `PlainLoadImage`, which sets
// the things to decode by using a single buf.
// 3. set the AssemblyEmit and PcodeEmit instance, these are two
// traits that defines the callback at the decode time.
// 4. do the decode
use sleighcraft :: * ;
let mut sleigh_builder = SleighBuilder :: default ( ) ;
let spec = arch ( "x86" ) . unwrap ( ) ;
let buf = [ 0x90 , 0x32 , 0x31 ] ;
let mut loader = PlainLoadImage :: from_buf ( & buf , 0 ) ;
sleigh_builder . loader ( & mut loader ) ;
sleigh_builder . spec ( spec ) ;
let mut asm_emit = CollectingAssemblyEmit :: default ( ) ;
let mut pcode_emit = CollectingPcodeEmit :: default ( ) ;
sleigh_builder . asm_emit ( & mut asm_emit ) ;
sleigh_builder . pcode_emit ( & mut pcode_emit ) ;
let mut sleigh = sleigh_builder . try_build ( ) . unwrap ( ) ;
sleigh . decode ( 0 ) . unwrap ( ) ;
println ! ( "{:?}" , asm_emit . asms ) ;
println ! ( "{:?}" , pcode_emit . pcode_asms ) ;Rust API的更详细的文档仍在开发中。
这是由Starcrosstech Portallab创立的项目。
欢迎通过拉拉请求进行任何贡献。 ✌️