Created
April 25, 2015 01:04
-
-
Save ajnadel/f3ae37f78ec51decb7c9 to your computer and use it in GitHub Desktop.
This file contains 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
/* 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