Javascript snippet for comments in the Matasano/Square CTF disassembler
/* | |
Running this javascript snippet on https://microcorruption.com/cpu/debugger | |
will allow you to add comments to the Disassembly window. It also backs up | |
every 10 seconds to local storage and will restore if a backup exists when | |
first run. | |
Needs to be run manually on pageload (paste into chrome console) and doesn't | |
preserve existing breakpoint highlights (so do it before setting them). | |
Will also wipe out the current PC highlight but this will return next step. | |
I found it particularly helpful for Chernobyl. | |
- @Sebbity | |
*/ | |
(function(){ | |
var a = document.getElementById('asmbox'); | |
a.contentEditable=true; | |
a.onkeydown = function(e) { | |
if (e.keyCode == 9) { | |
var range,sel = window.getSelection(); | |
if (sel.rangeCount) { | |
range = sel.getRangeAt(0); | |
range.insertNode(document.createTextNode('\t')); | |
range.collapse(false); | |
sel.removeAllRanges(); | |
sel.addRange(range); | |
e.preventDefault(); | |
} | |
} | |
}; | |
cpu.get("/whoami", function(t) { | |
var level = t.level; | |
var asmBackup = level + '_backup_asmbox'; | |
if (localStorage[asmBackup]) { | |
a.innerHTML = localStorage[asmBackup]; | |
}; | |
window.setInterval(function() { | |
console.log(level); | |
var asm = document.getElementById('asmbox').cloneNode(true); | |
var instructions = asm.getElementsByClassName('insn'); | |
for (i in instructions) { | |
if (instructions[i] && instructions[i].removeAttribute) { | |
instructions[i].removeAttribute('style'); | |
} | |
} | |
localStorage[asmBackup] = asm.innerHTML; | |
}, 10 * 1000); | |
}); | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Very cool!