Skip to content

benediktwerner/rewasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Re:Wasm

rewasm is a decompiler for WebAssembly binaries. It can decompile all WASM binaries from the MVP version 1, however it's still under development so some features, like proper type recovery, are still missing and some binaries still produce pretty unreadable output.

Requirements

Running rewasm requires libz3 (version 4.8.6 or 4.8.7 should work).

Installation

You can find prebuilt binaries for 64-bit Linux here.

Building from source

Building or installing rewasm from source requires a working Rust Installation (probably at least version 1.37.0).

To build and install rewasm (this will place the binary in ~/.cargo/bin which should be in your $PATH):

$ git clone https://github.com/benediktwerner/rewasm
$ cargo install --path rewasm
$ rewasm --version

To just build rewasm from source:

$ git clone https://github.com/benediktwerner/rewasm
$ cd rewasm
$ cargo build --release
$ ./target/release/rewasm --version

Usage

Decompile whole file:

$ rewasm example.wasm > example.dec

Decompile a single function (with index 42):

$ rewasm example.wasm 42

Example

Convert examples/loop.wat to a .wasm file using WABT's wat2wasm and decompile it:

$ wat2wasm examples/loop.wat
$ rewasm loop.wasm

Output:

fn func_0(i32 arg_0, i32 arg_1) -> i32 {
    i32 var_2;
    i32 var_3;

    var_2 = 0;
    for ; arg_0 >s 0; arg_0-- {
        for var_3 = arg_1; var_3 >s 0; var_3-- {
            var_2++;
        }
    }
    return var_2;
}

About

Decompiler for WebAssembly binaries

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages