3
I have a long list of 1million+ permutations of a 12 word BIP39 seed. How can I try them all on a bitcoin address?
edit: I know the address and the 12 words but i don't know the order of the words
3
I have a long list of 1million+ permutations of a 12 word BIP39 seed. How can I try them all on a bitcoin address?
edit: I know the address and the 12 words but i don't know the order of the words
7
Doing this requires three things:
In this specific case, the address is the one this puzzle on reddit leads to, so we will assume the derivation path is m/49'/0'/0'/0/0
This is a simple nodejs script using bitcoinjs-lib to read seeds from a file, validate them, and then try the first address against the one you are searching for. You can parallelize it by splitting the input file into pieces and running it once per file.
Do note that 12 words means roughly half a billion combinations. While this is doable with today's computing power, it is still going to take you a very long time. Some quick tests show it would take about 4 days on my laptop, although you may be able to speed it up by using a faster language, or parallelization.
var bip39 = require('bip39');
var bitcoin = require('bitcoinjs-lib')
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream('addresses.txt')
});
var ctr = 1;
lineReader.on('line', function (line) {
if (ctr%100 == 0) {
console.log("Processing #" + ctr);
}
if (bip39.validateMnemonic(line)) {
var roothex = bip39.mnemonicToSeedHex(line);
var rootnode = bitcoin.HDNode.fromSeedHex(roothex);
var basechild = rootnode.deriveHardened(49)
.deriveHardened(0)
.deriveHardened(0)
.derive(0);
for (var i = 0; i < 3; i++) {
var child = basechild.derive(i);
var keyhash = bitcoin.crypto.hash160(child.getPublicKeyBuffer())
var scriptSig = bitcoin.script.witnessPubKeyHash.output.encode(keyhash)
var addressBytes = bitcoin.crypto.hash160(scriptSig)
var outputScript = bitcoin.script.scriptHash.output.encode(addressBytes)
var address = bitcoin.address.fromOutputScript(outputScript)
if (address == "3CcxyPhyvyc3S9UuPfu42GNZLvVVV11Uk8") {
console.log("Found seed! " + line)
}
}
}
ctr++;
});
You will need to install nodejs, and bitcoinjs-lib for this.
Thanks, I'm trying that now. What's the for loop for? – code511788465541441 – 2018-05-19T19:06:42.537
It'll check the first three addresses on every seed, just in case we're wrong about it being the first address. – Raghav Sood – 2018-05-19T19:10:54.263
Any idea why validateMnemonic() returns false for this example 12 word seed string? proof know able order problem end just zero run air agree next – code511788465541441 – 2018-05-19T19:22:45.163
1Because it's an invalid mnemonic. The last word is a checksum. Not all combinations of BIP39 words are valid seeds. The valid mnemonic check will skip a seed if it is invalid, so you don't needlessly process it for addresses. – Raghav Sood – 2018-05-19T19:26:19.403
Thanks a lot. It is a bit slow as you said so I am trying to write it to run in parallel. If I do find the key i'll get in touch :) – code511788465541441 – 2018-05-19T19:58:58.497
Possible duplicate of Is it possible to brute force bitcoin address creation in order to steal money?
– Junaid Shaikh – 2018-05-19T17:49:09.147@JunaidShaikh I'm not asking if it is possible. I am asking for a specific tool to do it. And I only need to try 12 words not 1024 different words – code511788465541441 – 2018-05-19T17:51:55.367
This isn't an exact duplicate - It's a lot more feasible to try all combinations of words if you know they are all in the seed (although this breaks down for 24+ words). – Raghav Sood – 2018-05-19T17:52:29.853
@code511788465541441 Do you know the address you are looking for, and the derivation path which would lead to it? – Raghav Sood – 2018-05-19T17:52:47.083
@RaghavSood yes i know the address and the words – code511788465541441 – 2018-05-19T17:53:47.753
Do you know the derivation path? This is infeasible unless you know the exact derivation path that leads to the address (or any address in the wallet). – Raghav Sood – 2018-05-19T17:55:49.823
@RaghavSood I'm not sure what derivation path is but i know its BIP39 word list with 12 words and what the words are – code511788465541441 – 2018-05-19T17:57:29.467
Since a seed leads to billions of addresses, each address has a path within the seed (something like
m/44'/0'/0'/0/i, where i is increasing for every new address). Unless you know which path and index the address is at, it is impossible to check if a seed contains it. Which wallet is the address from? Most wallets publish their derivation path, so you should be able to find it. Then you just need the index (or an approximate) – Raghav Sood – 2018-05-19T17:59:18.313@RaghavSood the address is 3CcxyPhyvyc3S9UuPfu42GNZLvVVV11Uk8 – code511788465541441 – 2018-05-19T18:01:37.430
Ah, you're trying the reddit puzzle. If you assume that the derivation path is
m/49'/0'/0'/0/0, which is the first segwit address (I'm assuming the creator sent it to the first address on the seed), this is technically feasible. I'll post a script as an answer – Raghav Sood – 2018-05-19T18:04:38.833@code511788465541441 , I misunderstood the use-case over here, sincere apologies. – Junaid Shaikh – 2018-05-20T19:44:04.593