Created
December 6, 2017 14:34
-
-
Save Saturate/2b048ac843a7a1bba6a302fa2ec426dd to your computer and use it in GitHub Desktop.
NC3 Jule CTF - Convert (quick hack)
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
const fs = require('fs'); | |
function hex2a(hexx) { | |
var hex = hexx.toString(); | |
var str = ''; | |
for (var i = 0; i < hex.length; i += 2) | |
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); | |
return str; | |
} | |
console.time('Generate'); | |
fs.readFile('secret', { encoding: 'utf8' }, function(err, data) { | |
const hexArray = data.split( /(?=(?:...)*$)/ ); | |
let stringArray = hexArray.map(function(code) { | |
let hexCode = code.replace('x',''); | |
return hex2a(hexCode); | |
}); | |
var str = stringArray.join(''); | |
var last = 0; | |
let painting = []; | |
for(let nu = 0; nu < str.length / 299; nu++) { | |
painting.push(str.substring(last, last + 299 )); | |
last = last + 299 | |
} | |
var out = painting.join('\n'); | |
fs.writeFile('message-breaks-2.txt', out, (err) => { | |
if (err) throw err; | |
console.log('The file has been saved!'); | |
console.timeEnd('Generate'); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment