sleighcraft
1.0.0
SelighcraftはBincraftプロジェクトの1つです。
SleighCraft 、Ghidraの逆コンパイラの実装に基づいたデコーダー(または線形分解者)です。 Selighcraftは、高レベルと低レベルのAPIの両方で、RustまたはPythonで使用できます。
一般に、 sleighcraftキャップストーンのようなものですが、IRとより多くのアーチがあります。
特徴:
§収列✔き:提供されています
:提供されていません
?:建設中
?:わからない、多分そうではない
Capstoneとの比較:
| 特徴 | Selighcraft | キャップストーンエンジン |
|---|---|---|
| 分解 | ✔✔️ | ✔✔️ |
| ir | ✔✔️です | |
| C API | ? | ✔✔️ |
| カスタムアーキテクチャ | §収〜いくつか |
アーキテクチャとキャップストーンとの比較(Capstone Archリストによる):
| アーチ名 | Selighcraft | キャップストーンエンジン |
|---|---|---|
| 6502 | ✔✔️ | ? |
| 6805 | ✔✔️ | ? |
| 8051 | ✔✔️ | ? |
| 8048 | ✔✔️ | ? |
| 8085 | ✔✔️ | ? |
| 68000 | ✔✔️ | ? |
| aarch64(armv8) | ✔✔️ | ピオンデ |
| アーム | ✔✔️ | ピオンデ |
| CP1600 | ✔✔️ | ? |
| CR16 | ✔✔️ | ? |
| AVR8 | ✔✔️ | ピオン |
| ダルヴィク | ✔✔️ | ? |
| JVM | ✔✔️ | ? |
| ミップ | ✔✔️ | ピオンデ |
| PowerPc | ✔✔️ | ピオンデ |
| Sparc | ✔✔️ | ピオンデ |
| トリコア | ✔✔️ | ? |
| RISCV | ✔✔️ | ? |
| Z80 | ✔✔️ | ? |
| システムZ | ✔✔️ | |
| Xcore | ✔✔️ |
さび
貨物を使用してください:
sleighcraft = { git = " https://github.com/StarCrossPortal/sleighcraft " }リポジトリは、(事前に定義されたSLAファイルのため)Crates-IOで送信するために少し大きいですが、Shay Filesを自分でコンパイルする複雑なものを保存します。
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 builddoc.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によって開始されたプロジェクトです。
プルリクエストによる貢献は大歓迎です。 ✌✌️