Reverse Engineering
Table of Content
NRO
- nxtool to parse file headers and transform the NRO files into ELF.
WASM (Web Assembly)
Docs and tools
First the mandatory references and tools:
- WebAssembly Specification.
- WebAssembly Binary Toolkit (wabt): Set of tools to interpret, decompile (to C and wat) and more.
- JEB has a free demo of its WASM decompiler.
Decompilation
wasm2c can produce some decompiled C source, but it is pretty unreadable. Static analysis can be made much easier by retrieving the wasm-rt.h header file and simply compiling to an object file. Which can then be loaded into Ghidra for example for further analysis.
wasm2c -o index.c index.wasm # C source is _very_ verbose! curl -OL https://raw.githubusercontent.com/WebAssembly/wabt/main/wasm2c/wasm-rt.h cc -c index.c index.o
Debugging
If the application is running in the browser, you can use the JS console to access its internal variables. Look for: wasmMemory and wasmTable.
// Read/Write internal memory as byte array or (u)int32 array var mem = new Uint8Array(wasmMemory.buffer, 0, wasmMemory.buffer.bytelength); var mem = new Uint32Array(wasmMemory.buffer, 0, wasmMemory.buffer.bytelength / 4); var mem = new Int32Array(wasmMemory.buffer, 0, wasmMemory.buffer.bytelength / 4);