Skip to content

Instantly share code, notes, and snippets.

@ajnadel
Created April 25, 2015 01:04
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 ajnadel/f3ae37f78ec51decb7c9 to your computer and use it in GitHub Desktop.
Save ajnadel/f3ae37f78ec51decb7c9 to your computer and use it in GitHub Desktop.
/* USAGE:
node webD.js [dictionaryfile] [hashalgo]
*/
var crypto = require('crypto');
var fs = require('fs');
/* SETUP */
var target = 'xQj73CykeTXZoUXgeMxvh9IdBIk';
var header64 = 'eyJ1c2VyIjoiNDAwNDAwIn0';
var body64 = '1YljWG';
var encodeSecret = true;
var text = header64 + ':' + body64;
console.log("Text: "+text);
var b64 = function(s){
return new Buffer(s).toString('base64').replace(/=/g, '');
};
var cryptAlgo = process.argv[3];
var dictionary = fs.readFileSync(process.argv[2]).toString().split('\n');
var hashes = dictionary.map(function(word){
var word64 = (encodeSecret && b64(word)) || word;
var hash = crypto.createHmac(cryptAlgo, word64).update(text).digest('base64').replace(/=/g, '');
return (hash.slice(0, target.length) === target && hash) || false;
}).filter(Boolean);
console.log(hashes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment