I am in the process of analysing a large web assembly. I have the compiled .wasm file and using the tools available I can convert this to a .wat text representation. Currently, I am doing the following to convert each function within the wasm into its jit-ed assembly code:

// wasm is the binary; loaded from file
var module = new WebAssembly.Module(wasm);
var code = wasmExtractCode(module);
var regions = code.segments.filter(s => s.kind === 0);
regions.map(function(seg) {
      var segmentcode = code.code.subarray(seg.funcBodyBegin, seg.funcBodyEnd);
      // segmentcode contains the assembly code

Is there a way of using the code extracted in this way? Ideally, I'd like to generate a PE or some type of file I can drop in Ida and explore and analyse. I understand though that the format of wasm and PE files are fundamentally different and so this is a pretty big ask. If I dump the code from each function into a file and align each function properly, I can open the file in Ida and manually mark the function start and end, and I am then able to analyse it nicely. Doing this for over 27000 functions is a bit of an ask, though...

Any ideas? TIA

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.