I have a myetherwallet. I have my keystore file but I lost my password? Is there any solution to recover my assets?
1 Answer
The only realistic way to restore your access to your keystone file is to guess your password.
I have had the same issue some years ago and was able to find the correct password. It was quite long, but I knew that just the last 3 characters changed. So, I wrote a small javascript program to try all combinations.
In principle it works as:
- Create file (./local.txt) with all password candidates
test345678
test234567
test123456
test012345
- Create file (./package.json)
{
"name": "decoder",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"ethereumjs-util": "^7.1.4",
"express": "^4.17.1",
"fs": "0.0.1-security",
"keythereum": "^1.0.4",
"web3": "^1.7.3"
},
"scripts": {
"start": "node local-decrypt.js"
}
}
- Copy your key file (./key-c.json)
{
"address": "ed8e3df78753f626870f26102b288d113b34b18a",
"crypto": {
"cipher": "aes-128-ctr",
"ciphertext": "6c9ff087c32ba02d744897135553a2b5cf9eace5ef8b9376adc135c0f7e53343",
"cipherparams": {
"iv": "5dcc018af32e6f352563dd25bd345bcd"
},
"kdf": "scrypt",
"kdfparams": {
"dklen": 32,
"n": 262144,
"p": 1,
"r": 8,
"salt": "0dbab215a3e456c81f582645466dfb8742f05c1f65956fa57e9c584f3efdb4fd"
},
"mac": "58ce3874ad4b0210a03ab015db6bcf1480d8a96ece3cbfa33507cf1df80b50c8"
},
"id": "dd16d7de-2759-4bab-b481-a2a8d4713024",
"version": 3
}
- Create file (./local-decrypt.js)
path = require("path");
const keythereum = require("keythereum");
fs = require("fs");
const readline = require('readline');
const readInterface = readline.createInterface({
input: fs.createReadStream('./local.txt'),
console: false
});
const json_c = path.normalize("./key-c.json");
const content_c = JSON.parse(fs.readFileSync(json_c));
//
let count = 1;
readInterface.on('line', function (line) {
if (line.length > 2) {
console.log(count + ": " + line);
count++;
try {
const privateKey = keythereum.recover(line, content_c);
console.log(" => SUCCESS key-c.json PK=" + privateKey.toString('hex'));
process.exit()
} catch (e) {
}
}
});
- Run:
$ npm install
$ npm run start
- Expected output
$ npm run start
> [email protected] start
> node local-decrypt.js
1: test345678
2: test234567
3: test123456
=> SUCCESS key-c.json PK=8daeb7273c1361b006af0cabd960628f57f3c2d5160037c356367fba1d7729e1
Good Luck!