potent_pwnables

cookies.js

Dec 27th, 2017
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var aes256 = require('aes256');
  2. var global_key = 'santa';
  3.  
  4. function cookie_maker(username) {
  5.   var key = global_key;
  6.   var plaintext = process.argv[2];
  7.   var ciphertext = aes256.encrypt(key, plaintext).replace(/\=/g,'');
  8.   var acookie = JSON.stringify({"name":username, "plaintext":plaintext,  "ciphertext":ciphertext});
  9.   return acookie;
  10. };
  11.  
  12.  
  13. function cookie_checker(req) {
  14.   try{
  15.       //var key = 'somestupidfuckingkey';
  16.       var key = global_key;
  17.       var thecookie = JSON.parse(req);
  18.       var ciphertext = thecookie.ciphertext;
  19.       var plaintext = aes256.decrypt(key, ciphertext);
  20.       var username = thecookie.name
  21.       var ciphertext2 = process.argv[3];
  22.       var plaintext2 = aes256.decrypt(key, ciphertext2);
  23.       console.log('MANUALLY ENTERED VALUES');
  24.       console.log('  Name: ' + username);
  25.       console.log('  Cipher: ' + ciphertext2);
  26.       console.log('  Decrypted: ' + plaintext2);
  27.       console.log('  Plaintext: ' + thecookie.plaintext);
  28.       console.log('');
  29.       console.log('');
  30.       console.log('ALGORITHMICALLY DERIVED VALUES');
  31.       console.log('  Name: ' + username);
  32.       console.log('  Cipher: ' + ciphertext);
  33.       console.log('  Decrypted: ' + plaintext);
  34.       console.log('  Plaintext: ' + thecookie.plaintext);
  35.       if (plaintext2 === thecookie.plaintext) {
  36.         console.log('This should work!');
  37.       }
  38.   } catch (e) {
  39.       console.log(e);
  40.   }
  41. };
  42.  
  43. var req = cookie_maker('[email protected]');
  44. cookie_checker(req);
Advertisement
Add Comment
Please, Sign In to add comment