Skip to content

Instantly share code, notes, and snippets.

@bored-engineer
Created May 10, 2013 02:05
Show Gist options
  • Select an option

  • Save bored-engineer/5551947 to your computer and use it in GitHub Desktop.

Select an option

Save bored-engineer/5551947 to your computer and use it in GitHub Desktop.
picoCTF
//Import the request module, used to pull the manual from pico's site
var request = require('request');
//Request the manual
request('https://picoctf.com/problems/manual.txt', function (error, response, body) {
//Make sure we were actaully successful
if (!error && response.statusCode == 200) {
console.log(crypt(body, parseInt(process.argv[2])));
}
});
//Encrypt or Decrypt a input given a key
function crypt(input, key) {
var output = "";
for (var i = 0; i < input.length; i++) {
var c = input.charCodeAt(i);
if (c >= 65 && c <= 90) output += String.fromCharCode((c - 65 + key) % 26 + 65); // Uppercase
else if (c >= 97 && c <= 122) output += String.fromCharCode((c - 97 + key) % 26 + 97); // Lowercase
else output += input.charAt(i); // Copy
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment