Instantly share code, notes, and snippets.

Embed
What would you like to do?
const util = require('ethereumjs-util')
const Wallet = require('ethereumjs-wallet')
var possible = 'abcdef1234567890'
var basePrivateKey = '1cd3b30424316919712c48359829787eefa0d724a78274a506530dbb72'
var charsMissing = 64 - basePrivateKey.length
var targetPublicAddress = ' 0xe8Ca70C909905Ebbbe6a49c34797beF31d895241'
var missingPart = '';
for (var i = 0; i < charsMissing; i++) {
missingPart = missingPart.concat('f');
}
var maxVal = parseInt(missingPart, 16);
console.log(" \n " +
"searching for address : " + targetPublicAddress + " \n " +
"base private key : " + basePrivateKey + " \n " +
"missing chars : " + charsMissing + " \n " +
"it will be quiet now. if you don't see anything below me, it's working on finding your key." + " \n " +
"If you see something below that doesn't say 'FOUND KEY!', you have an error" + " \n " )
function makeHexString(numb) {
var hex = numb.toString(16);
for (var i = 0; i < charsMissing - hex.length; i++)
hex = '0' + hex
return hex
}
for(var i = 0; i <= maxVal; i++){
try{
var endPrivateKey = makeHexString(i)
var privateKeyGuess = basePrivateKey + endPrivateKey
var wallet = Wallet.fromPrivateKey(new Buffer(privateKeyGuess, "hex"))
var publicAddress = util.bufferToHex(wallet.getAddress())
// console.log(i + ": " + endPrivateKey)
if(publicAddress.toLowerCase() == targetPublicAddress.toLowerCase()){
console.log('\n \n \n \n ********************************** FOUND PRIVATE KEY: ' + privateKeyGuess + " \n matching address " + targetPublicAddress + " \n \n \n \n ");
process.exit();
}
}catch(e){
null;
}
if (i % 100000 === 0) {
console.log('checked', i, 'keys');
}
}
/*
Credit goes to Bahk (https://github.com/domalak) for making the best helper tools ever!
How to Use (for noobs)
- Click "Raw" on https://gist.github.com/tayvano/7755e3e8d8b64581d5ff2865087b93f8
- Right click, select "Save As"
- Click "Save"
- Install Node.js: https://nodejs.org/en/
- Open the .js file you saved earlier in a text editor (NOT WORD!!!!!!!!!!) like Notepad (PC) or Text Edit (Mac)
- Change the stuff between the ' ' characters to the characters you have of your private key. Check it 5 times to be sure you got the correct characters in there:
var basePrivateKey = 'afdfd9c3d2095ef696594f6cedcae59e72dcd697e2a7521b15781404'
- Change the stuff between the ' ' characters to your address:
var targetPublicAddress = '0x06A85356DCb5b307096726FB86A78c59D38e08ee';
- Open command line / terminal
- Type "cd" into the command line (w/o quotes: just cd) and then hit the spacebar and then drag and drop the FOLDER that contains the .js file into command line window
- It should look like /Users/tayvano/Downloads/7755e3e8d8b64581d5ff2865087b93f8-653a14e63b9ccefb5a8ddfdb14bd7066b4fd4c6f (or something like that).
- Hit enter.
- Copy & paste the following into command line and hit enter:
npm install ethereumjs-wallet ethereumjs-util
- Wait until it installs
- Type "node" into the command line (w/o quotes: just cd) and then hit the spacebar and then drag and drop the brute_force_end_of_private_key.js FILE into the command line window
- Hit enter.
You should see the following:
$ node /Users/tay/Desktop/brute_force_8_char.js
searching for address : 0x06A85356DCb5b307096726FB86A78c59D38e08ee
base private key : afdfd9c3d2095ef696594f6cedcae59e72dcd697e2a7521b15781404
missing chars : 8
it will be quiet now. if you don't see anything below me, it's working on finding your key.
If you see something below that doesn't say 'FOUND KEY!', you have an error
When it's done it will show:
********************************** FOUND PRIVATE KEY: afdfd9c3d2095ef696594f6cedcae59e72dcd697e2a7521b1578140422a4f890
matching address 0x06A85356DCb5b307096726FB86A78c59D38e08ee
If you see anything besides that, you have an error and it's not longer searching for your key.
If the error says, "Invalid private key", the key snippet your provided is invalid. It must be hex characters.
If you get an "out of memory" error, have to go to work, or your computer turns off, no worries. Just run it again.
If your command line is still open, hit the up arrow key and then enter to quickly run it again.
On a macbook pro, it will take seconds to find 1, 2, 3, or 4 missing characters.
It takes ~15mins to find 6 digits.
It will ~3 days to find 8
*/
@invisideath

This comment has been minimized.

invisideath commented Feb 16, 2018

hoping this will work out for me... currently working on errors when executing "npm install ethereumjs-wallet ethereumjs-util" from this tutorial https://myetherwallet.github.io/knowledge-base/private-keys-passwords/missing-characters-of-private-key.html

so far i got a "directory names are too long" error, and currently getting "Failed to locate CL.exe"

GOT IT! here is how i did it https://www.reddit.com/r/MyEtherWallet/comments/7y1xxf/private_key_missing_4_characters_when_issued/

https://archive.fo/yUIDP

thanks so much! how can i repay you?

@Albatroz4402

This comment has been minimized.

Albatroz4402 commented May 12, 2018

I'm trying to restore a private key from a Bitcoin wallet, would that algorithm work? I have only 47 characters of the private key that is made up of 51.

@robimage

This comment has been minimized.

robimage commented May 21, 2018

You can send mail to keychainx@protonmail.com and get help to bruteforce crack the key. We have helped others.

@GreenAsGrass

This comment has been minimized.

GreenAsGrass commented Jun 24, 2018

Hi thank you so much for coming up with the code for this program, im sure it has helped a lot of people! However I appear to be having some issue using it. Am missing 3 characters from my ethereum private key, so it shouldn't take very long for this code to work.

May I send you a screenshot of the issue in my commandprompt?

@GreenAsGrass

This comment has been minimized.

GreenAsGrass commented Jun 24, 2018

I'm quite new to using javascript and running command prompts.would really appreciate any help thanks so much! Been trying for half a day already haha

@GreenAsGrass

This comment has been minimized.

GreenAsGrass commented Jun 24, 2018

image

This is the issue I am having at the moment. Please any help is greatly appreciated :)

@GreenAsGrass

This comment has been minimized.

GreenAsGrass commented Jun 24, 2018

That issue disappeared after I replaced all "Buffer" with "Buffer.alloc". However, still does not worked. After checked 0 keys, it stops. This is what it looks like (using an ethereum wallet with no value)

image

@SteliosIoannou

This comment has been minimized.

SteliosIoannou commented Oct 3, 2018

The script assumes that the missing characters are at the end of the string. For me this wasn't the case I forgot to write a digit for my private key in the middle of the text, so I modified the script to match my needs.

Here is the modification that I made if anyone wants to use it.

image

`for(var i = 0; i = maxVal; i++){
try{
for(var j =0; j = basePrivateKey.length ; j++){
var endPrivateKey = makeHexString(i)
var privateKeyGuess = basePrivateKey.substring(0,j) + endPrivateKey + basePrivateKey.substring(j,basePrivateKey.length)
var wallet = Wallet.fromPrivateKey(new Buffer(privateKeyGuess, hex))
var publicAddress = util.bufferToHex(wallet.getAddress())

if(publicAddress.toLowerCase() == targetPublicAddress.toLowerCase()){
  console.log('Found Private Key: ' + privateKeyGuess +  n n n n );
  process.exit();
}

}
}catch(e){
console.log(e);
}
}
`

@SkAlauddin66

This comment has been minimized.

SkAlauddin66 commented Nov 10, 2018

Myetherwallet password keystore files my address 0xf0a29AB8A50F9bA8bAC94343Bc225cbD59D493a5

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