GithubHelp home page GithubHelp logo

donfanning / wasmdec Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wwwg/wasmdec

0.0 1.0 0.0 7.91 MB

WebAssembly to C decompiler

Home Page: https://wwwg.github.io/web-wasmdec/

License: MIT License

Makefile 3.04% Shell 1.81% C++ 59.54% C 19.70% WebAssembly 14.33% JavaScript 1.59%

wasmdec's Introduction

wasmdec

wasmdec is a program that converts WebAssembly binaries to C.

Demo

An online real-time WebAssembly decompiler utilizing wasmdec is avalible here

Simple Example

wasmdec will translate this WebAssembly binary:

(module
	(func $addTwo (param i32 i32) (result i32)
		(return
			(i32.add (get_local 0) (get_local 1))
		)
	)
	(export "addTwo" $addTwo)
)

To the following pseudo-C code:

int fn_addTwo(int arg0, int arg1) {
	return arg0 + arg1;
}

More practical examples

Diep.io (HTML5 web game written in C++ and compiled to WASM)

Diep.io is a real time web game written in C++ and compiled to WebAssembly via Emscripten.

wasmdec

wasmdec is capable of decompiling itself back to C.

WebDSP (a signal processing library compiled to WASM)

From the WebDSP repository:

WebDSP is a collection of highly performant algorithms, which are designed to be building blocks for web applications that aim to operate on media data. The methods are written in C++ and compiled to WASM, and exposed as simple vanilla Javascript functions developers can run on the client side.

Applications

A CTF write-up which uses wasmdec to reverse engineer a WASM binary

Installing with release

  • Grab a release on the releases page and select the correct tarball for your OS and arch.
  • Extract and run install.sh as root.

Installing manually

Getting the code

Clone the repository with

git clone https://github.com/wwwg/wasmdec.git --recursive

Make sure the recursive flag is set to clone all the submodules.

Building

To build wasmdec and install all of it's dependencies, run sudo make all in the wasmdec directory. GCC 7 or higher is reccomended.

Usage

wasmdec -o (output file) (options) [input files]

Where options is one of:

  • -e or --extra : Emits extra function information as comments:
    • Raw WebAssembly names of functions
    • Number of local variables and parameters of functions
  • -m or --memdump :
    • Dumps the binary's memory and table to disk
    • NOTE : memdump ONLY dumps memory and doesn't actually do any decompilation
  • -d or --debug : Print extra debug information to stdout
  • If no output file is specified, the default is out.c
  • When more than one input file is provided, wasmdec will decompile each WebAssembly to the same output file. Functions from more than one file are prefixed by their module name in order to prevent ambiguous function definitions.

wasmdec's People

Contributors

wwwg avatar ultratype avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.