Skip to content

Instantly share code, notes, and snippets.

@remasis
Created April 22, 2013 05:20
Show Gist options
  • Save remasis/5432583 to your computer and use it in GitHub Desktop.
Save remasis/5432583 to your computer and use it in GitHub Desktop.
javascript strace parser for plaidctf three_eyed_fish: "three_eyed_fish 100 binary This binary is totally legit we promise" .- -. -.. ----- ..- ----- -.. .. -.. -. - ----- . ...- . -. ----- -. . . -.. ----- .- -. ----- .- .-. -.. ..- .. -. ---
var fs = require('fs'),
readline = require('readline');
var rd = readline.createInterface({
input: fs.createReadStream('strace.log'),
output: process.stdout,
terminal: false
});
var morse = "";
var on = false;
var length = 0;
rd.on('line', function(line) {
if (line === "ioctl(3, KDSETLED, 0x4)") {
on = true;
if (length === 1) {
console.log("short off");
} else {
console.log("long off");
morse += " ";
}
length = 0;
}
if (line === "nanosleep({0, 250000000}, 0x4b32)") {
length += 1;
}
if (line === "ioctl(3, KDSETLED, 0)") {
on = false;
if (length === 1) {
console.log("short on");
morse += ".";
} else {
console.log("long on");
morse += "-";
}
length = 0;
}
});
rd.on('close', function(){
console.log(morse);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment