-
-
Save DaniloNC/2b4babe72ee8481563a09ed3bbd8943e to your computer and use it in GitHub Desktop.
WebAssembly helper functions CTF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function download(data, filename, type) { | |
var file = new Blob([data], {type: type}); | |
if (window.navigator.msSaveOrOpenBlob) // IE10+ | |
window.navigator.msSaveOrOpenBlob(file, filename); | |
else { // Others | |
var a = document.createElement("a"), | |
url = URL.createObjectURL(file); | |
a.href = url; | |
a.download = filename; | |
document.body.appendChild(a); | |
a.click(); | |
setTimeout(function() { | |
document.body.removeChild(a); | |
window.URL.revokeObjectURL(url); | |
}, 0); | |
} | |
} | |
function dump_memory() { | |
let mem = new Uint8Array(memory0.buffer) | |
let out = ""; | |
mem.forEach( b => { | |
let hb = b.toString(16); | |
if (hb.length == 1) { | |
hb = "0" + hb | |
} | |
out = out + hb; | |
}) | |
download(out, "memory.hex", "text"); | |
} | |
function toHex(b){ | |
let hb = b.toString(16); | |
if (hb.length == 1) { | |
hb = "0" + hb | |
} | |
return hb; | |
} | |
function hexdump(init, end){ | |
let mem = new Uint8Array(memory0.buffer) | |
let out = ""; | |
mem.slice(init,end).forEach( b => { | |
let hb = b.toString(16); | |
if (hb.length == 1) { | |
hb = "0" + hb | |
} | |
out = out + hb; | |
}) | |
return out; | |
} | |
let s = 71124 | |
let l = 8 | |
hexdump(s,s+l) | |
toHex(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment