A Fuel VM bytecode disassembler.

Overview

Fuel Disassembler

A disassembler for the Fuel VM byte code.

Nice Colours

About

The forc utility provides a parse-bytecode command which will print a bare-bones disassembly with the raw values decoded from a contract's binary bytecode. It is limited by assuming that every 32-bit word is an executable instruction, although it does attempt to output some helpful comments where it can. But generally it is quite hard to read.

forc-dis attempts to produces a far more readable disassembly. It will follow the control flow from the entry point, making no assumptions about whether decoded bytes are instructions or data. It also gives readable names to registers, annotates locations which are read by memory instructions and names known constant values used by the VM.

It also syntax highlights the listing in a fairly pleasing colour scheme.

Installation

Via crates.io

cargo install forc-dis

Via source

Clone this repository and build with Cargo as usual.

git clone https://github.com/otrho/fuel-dis.git
cd fuel-dis
cargo build --release

It can then be run in place using cargo run --release. Or it can be installed using cargo install --path ..

Use

forc-dis will take the path to the bytecode binary as a command line argument.

Alternatively, if forc-dis is in your path it may be used as a Forc plugin. From within a Forc project it can be invoked using forc dis, in which case it will attempt to find the bytecode binary automatically.

Example

$ forc new example

To compile, use `forc build`, and to run tests use `forc test`

----

Read the Docs:
- Sway Book: https://fuellabs.github.io/sway/latest
- Rust SDK Book: https://fuellabs.github.io/fuels-rs/latest
- TypeScript SDK: https://github.com/FuelLabs/fuels-ts

Join the Community:
- Follow us @SwayLang: https://twitter.com/SwayLang
- Ask questions in dev-chat on Discord: https://discord.com/invite/xfpK4Pe

Report Bugs:
- Sway Issues: https://github.com/FuelLabs/sway/issues/new


$ cd example/
$ cat src/main.sw
contract;

abi MyContract {
    fn test_function() -> bool;
}

impl MyContract for Contract {
    fn test_function() -> bool {
        true
    }
}

$ forc build
  Creating a new `Forc.lock` file. (Cause: lock file did not exist)
    Adding core
    Adding std git+https://github.com/fuellabs/sway...
   Created new lock file at...
  Compiled library "core".
  Compiled library "std".
  Compiled contract "example".
  Bytecode size is 60 bytes.

$ forc dis
00000000      ji      block_0010

00000004  47 00 00 00                                      G...

00000008      WORD        0000000000000034h       ; load @ 00000010

00000010  block_0010:                             ; from 00000000
00000010      lw      $ds $is 1                   ; $ds = 0000000000000034h
00000014      add     $ds $ds $is
00000018      lw      $r0 $fp 73
0000001c      lw      $r1 $ds 0                   ; $r1 = 000000002151bd4bh
00000020      eq      $r2 $r0 $r1
00000024      jnzi    $r2 block_0030
00000028      movi    $tmp 123
0000002c      rvrt    $tmp

00000030  block_0030:                             ; from 00000024
00000030      ret     $one

00000034  DATA SECTION:
00000034      WORD        000000002151bd4bh       ; load @ 0000001c
You might also like...
Derive macro for encoding/decoding instructions and operands as bytecode

bytecoding Derive macro for encoding and decoding instructions and operands as bytecode. Documentation License Licensed under either of Apache License

⚙️ Experimental JVM bytecode to WebAssembly compiler

⚙️ montera Final year university project: a highly experimental JVM bytecode to WebAssembly compiler ⚠️ Do NOT use this for serious projects yet! It's

Nederlandse programmeertaal. Geinterpreteerd en met dynamische types. Met bytecode compiler en virtual machine, in Rust.

Nederlang Nederlang is een geinterpreteerde programmeertaal, in het Nederlands! Met als bestandsnaam extensie.... .nl! Het maakt gebruik van dynamisch

A Huff <> bytecode transpiler
A Huff bytecode transpiler

Murph - Transpile EVM bytecode into huff Murph can transpile this: 60003560e01c8063552410771461001c5780632096525514610023575b6004356000555b60005460005

Lua bytecode parser written in Rust using nom, part of metaworm's lua decompiler

luac-parser (中文) lua字节码解析器, 目前支持 lua51, lua53, lua54 这是目前效果最好的lua反编译器 metaworm's luadec 的一部分 可以基于此代码定制你所需的lua字节码解析器,编译成WASM,让metaworm's luadec加载使用,来反编

A Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code.

EVM Hound A Minimalistic Rust library to extract all potential function selectors from EVM bytecode without source code. Installation $ cargo add evm_

Comments
  • Implement the rest of the opcode decoding and analysis.

    Implement the rest of the opcode decoding and analysis.

    As of writing:

    : rg todo\!
    asm.rs
    186:        ALOC(..) => todo!(),
    187:        AND(..) => todo!(),
    188:        ANDI(..) => todo!(),
    196:        BHSH(..) => todo!(),
    197:        BURN(..) => todo!(),
    205:        CB(..) => todo!(),
    206:        CCP(..) => todo!(),
    209:        CROO(..) => todo!(),
    210:        CSIZ(..) => todo!(),
    217:        DIVI(..) => todo!(),
    230:        EXP(..) => todo!(),
    231:        EXPI(..) => todo!(),
    232:        FLAG(..) => todo!(),
    332:        JNE(..) => todo!(),
    333:        JNEI(..) => todo!(),
    335:        K256(..) => todo!(),
    336:        LB(..) => todo!(),
    337:        LDC(..) => todo!(),
    338:        LOG(..) => todo!(),
    360:        MCL(..) => todo!(),
    361:        MCLI(..) => todo!(),
    378:        MINT(..) => todo!(),
    379:        MLOG(..) => todo!(),
    380:        MOD(..) => todo!(),
    381:        MODI(..) => todo!(),
    384:        MROO(..) => todo!(),
    395:        NOT(..) => todo!(),
    396:        OR(..) => todo!(),
    414:        SB(..) => todo!(),
    415:        SLL(..) => todo!(),
    417:        SMO(..) => todo!(),
    418:        SRL(..) => todo!(),
    419:        SRLI(..) => todo!(),
    432:        TIME(..) => todo!(),
    446:        XOR(..) => todo!(),
    456:        Undefined => todo!(),
    
    asm/analysis.rs
    184:            Undefined => todo!(),
    
    asm/disasm.rs
    77:        JNE(..) => todo!(),
    97:        Undefined => todo!(),
    
    opened by otrho 1
Owner
Toby Hutton
Toby Hutton
A Huff <> bytecode transpiler

Murph - Transpile EVM bytecode into huff Murph can transpile this: 60003560e01c8063552410771461001c5780632096525514610023575b6004356000555b60005460005

Franfran 53 Feb 17, 2023
🍄 A disassembler for the UEFI Bytecode Virtual Machine.

?? A disassembler for the UEFI Bytecode Virtual Machine.

Samuel Wilder 51 Dec 6, 2022
Hashlink bytecode disassembler, analyzer, decompiler and assembler.

Hashlink bytecode This repository contains a collection of Rust crates and cli tools to load, disassemble, decompile and analyze Hashlink bytecode. Re

Guillaume Anthouard 24 Dec 21, 2022
Fuel cryptographic primitives

Fuel Crypto Fuel cryptographic primitives. Compile features std: Unless set, the crate will link to the core-crate instead of the std-crate. More info

Fuel Labs 19 Sep 8, 2022
Binja Arm64 Disassembler

Binja Arm64 Disassembler These are bindings to the Binary Ninja arm64 architecture/disassembler plugin. Note that while Binary Ninja is an (excellent)

_yrp 60 Dec 18, 2022
An MVP stack based bytecode VM

TinyVM An MVP stack-based bytecode VM This VM runs a simplistic, Turing complete instruction set. In ~250 LOC with extensive comments, it's meant to b

Mikail Khan 77 Dec 27, 2022
unfuck is a utility and library for deobfuscating obfuscated Python 2.7 bytecode

unfuck is a utility and library for deobfuscating obfuscated Python 2.7 bytecode. It is essentially a reimplementation of the Python VM with taint tracking.

Lander Brandt 171 Dec 14, 2022
A forth-inspired, bytecode-compiled scripting language for Anachro Powerbus

Anachro Forth (core) Anachro Forth is a forth-inspired, bytecode-compiled scripting language for Anachro Powerbus platform. Use Case The intended use

null 14 May 27, 2022
A Rust proc-macro crate which derives functions to compile and parse back enums and structs to and from a bytecode representation

Bytecode A simple way to derive bytecode for you Enums and Structs. What is this This is a crate that provides a proc macro which will derive bytecode

null 4 Sep 3, 2022
A Rust implementation of the Lox programming language. Based on clox, the bytecode virtual machine.

A Rust implementation of the Lox programming language. Based on clox, the bytecode virtual machine.

Diego Freijo 23 Dec 26, 2022