How to decode a .wasm code? Is it possible?

7.3k views Asked by At

Just curious to know what the code is doing in a computer, I would like to decode a .wasm code - available at https://lifeinspace.org/main.wasm. Basically, from what I found in internet, .wasm is a web assembly code, which could have been:

However, since I now have the .wasm code, Is there a way or technique to figure out what the high-level code was?

Its just that I want to know what this .wasm code does. When I open this code in notepad++, its full of symbols and assembly instructions, which does not make any sense.

The main reason that I want to know is whether this code does any illegal stuffs like DDoS.

I scanned the file using different antivirus tools but could not spot any bad stuffs.

A quick background: lifeinspace.org is a website where on the outside it claims to rent our computing power for scientific calculations. (more info at https://money.stackexchange.com/questions/115754/lease-computing-power-to-earn-money-lifeinspace-org). However, its runs a browser code behind (lifeinspace.org/main.wasm) does some other process in background which we don't know. The only way to know what it does is to decode the main.wasm code above. Hence I am curious about it.

2

There are 2 answers

0
Mubelotix On

Your wasm compiled file can be converted into a wasm text format see mdn page. You can use the wast2wasm tool
However you can't get the more high level source (depends to the the langage, the compiler and there is a lost of information).
There is no antivirus wich can scan a wasm file. Wasm is executed by your browser and he protects you very well.
The simplest way to spy what the program do is to watch the logs and the requests with your browser.

2
The Wayward Developer On

WebAssembly is a binary format, but as Mubelotix’s answer says, you can convert it to the standard text format to inspect it (or you can use a tool like the graphical viewer I developed). You can also convert it to equivalent code in the high-level language it was written in given a decompiler, and it may help understanding it, but it is unlikely to be anywhere close to the original source code.

However, a WebAssembly module has no direct access to the outside world, only through the functions and objects the calling JavaScript code explicitly passes to it as imports. This means that if by inspecting the definitions made available to it at instantiation you can determine it has no access to e.g. the network, you can be sure it cannot be part of a DDoS attack, without the need to look at the WebAssembly code itself.