Skip to content

Instantly share code, notes, and snippets.

@Saturate
Created December 6, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saturate/2b048ac843a7a1bba6a302fa2ec426dd to your computer and use it in GitHub Desktop.
Save Saturate/2b048ac843a7a1bba6a302fa2ec426dd to your computer and use it in GitHub Desktop.
NC3 Jule CTF - Convert (quick hack)
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