Created
May 10, 2013 02:05
-
-
Save bored-engineer/5551947 to your computer and use it in GitHub Desktop.
picoCTF
This file contains hidden or 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
| //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