Skip to content

Instantly share code, notes, and snippets.

@frozeman
Last active March 28, 2017 05:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frozeman/26510d02af674abd4b39 to your computer and use it in GitHub Desktop.
Save frozeman/26510d02af674abd4b39 to your computer and use it in GitHub Desktop.
Presale wallet file brute force tools. This is to help people who don't exactly remember their passwords
const spawn = require('child_process').spawn;
var bruteForce = function(path, pw, callback) {
var error = false;
// start import process
var nodeProcess = spawn(nodeBinary, ['wallet', 'import', path]);
nodeProcess.once('error',function(){
error = true;
callback('Couldn\'t start the "geth wallet import <file.json>" process.');
});
nodeProcess.stdout.on('data', function(data) {
var data = data.toString();
if(data.indexOf('Decryption failed:') !== -1 || data.indexOf('not equal to expected addr') !== -1) {
callback(data);
// if imported, return the address
} else if(data.indexOf('Address:') !== -1) {
var find = data.match(/\{([a-f0-9]+)\}/i);
if(find.length && find[1])
callback(null, '0x'+ find[1]);
else
callback(data);
// if not stop, so we don't kill the process
} else {
return;
}
nodeProcess.stdout.removeAllListeners('data');
nodeProcess.removeAllListeners('error');
nodeProcess.kill('SIGINT');
});
// file password
setTimeout(function(){
if(!error && nodeProcess.stdin.writable) {
nodeProcess.stdin.write(pw +"\n");
pw = null;
}
}, 500);
};
count = 0;
var id = setInterval(function(){
var pw = passwords[count++];
console.log('Password:', pw);
bruteForce(path, pw, function(e, result){
if(e) {
console.log('ERROR:', e);
} else {
console.log('FOUND!:', result, ' Password: "'+ pw +'"');
clearInterval(id);
}
});
if(count === passwords.length)
clearInterval(id);
}, 1000);
// ----------------------------------------------------------------------------------
var nodeBinary = 'geth';
var path = './ethereum-wallet-xxxxxxxxxxxxxxxxxxxxxx.json';
var passwords = [
'AddPasswords',
'Here',
'WhichYouThinkMightBeIt'
];
// add lower and uppercase versions
passwords.forEach(function(pw){
passwords.push(pw.toLowerCase());
passwords.push(pw.toUpperCase());
});
@frozeman
Copy link
Author

Change the last variables:

var path = './ethereum-wallet-xxxxxxxxxxxxxxxxxxxxxx.json';
var passwords = [
'AddPasswords',
'Here',
'WhichYouThinkMightBeIt'
];

And run using node bruteforce-presale.js.

NOTE, you need to have geth installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment