Currently most programming languages, can compile to WebAssembly (officially or through an external package).
So I'm wondering... is it possible to decompile the web assembly file? So we can have the code written in one language that can compile to .wasm
, and decompile it using another language? And then, generate .java
, .js
, .py
, .go
and etc, from the .wasm
file. Is it possible?
The WASM files can be decompiled using the WebAssembly-to-C decompiler.
Conclusion. We have now successfully reverse engineered our first simple Wasm program. The example was extremely simplistic, but we have to start with the basics. In the process of reversing we learned how Wasm interacts with the outside environment by calling imported functions that are declared in JavaScript.
The State of WebAssembly 2022 survey of Wasm developers shows Rust on top, with Blazor and Python on the rise. The Rust programming language is the most frequently used language for developing WebAssembly applications, according to a recent survey.
Since it's a well-defined format, any language can have Wasm as a compilation target. Consequently, there are now around 40 high-level programming languages that support WebAssembly, including C and C++, Python, Go, Rust, Java, and PHP.
There is a converter from webassembly binaries to C.
https://github.com/WebAssembly/wabt/tree/master/wasm2c
As written in the other answer it will not look anything of the original source file, but at least it should be able to transfer the logic to C which then again also could be used with other languages by wrapping it into a library.
There are no WebAssembly disassemblers that I am aware of at the moment. One significant obstacle to this is that a great deal of information is discarded in the compilation process. The languages you are interested in (JavaScript, Java, Python, Go) have constructs like strings, classes, structs, etc ... none of which exist at the WebAssembly level. Furthermore, function and variables names are not (typically) present in the resulting WebAssembly module.
While you could create a tool that would 'translate' a WebAssembly module into a Java, Python, Go or JavaScript program that when executed it exhibited the correct behaviour, it would look nothing like the original program that was compiled to WebAssembly.
@KadoBOT you can use wasm-decompile.exe to decompile your wasm file https://github.com/WebAssembly/wabt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With