<p>Doing this requires three things:</p>

<ol>
<li>Permutations of the seed words</li>
<li>The address you're trying to locate</li>
<li>The derivation path for that address.</li>
</ol>

<p>In this specific case, the address is the one <a href="https://old.reddit.com/r/Bitcoin/comments/8kk0pa/1_btc_is_hidden_in_this_puzzle_good_luck/" rel="noreferrer">this</a> puzzle on reddit leads to, so we will assume the derivation path is <code>m/49'/0'/0'/0/0</code></p>

<p>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.</p>

<p>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.</p>

<pre><code>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 &lt; 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++;
});
</code></pre>

<p>You will need to install nodejs, and bitcoinjs-lib for this.</p>

CC BY-SA 4.0
2018-05-19T19:06:42.537Z
Thanks, I'm trying that now. What's the for loop for?
code511788465541441
CC BY-SA 4.0
2018-05-19T19:10:54.263Z
It'll check the first three addresses on every seed, just in case we're wrong about it being the first address.
Raghav Sood
CC BY-SA 4.0
2018-05-19T19:22:45.163Z
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
CC BY-SA 4.0
2018-05-19T19:26:19.403Z
Because 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
CC BY-SA 4.0
2018-05-19T19:58:58.497Z
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
CC BY-SA 4.0
2018-05-19T18:12:17.483Z
2018-05-19T18:12:17.483Z
Raghav Sood
<p>I have a long list of 1million+ permutations of a 12 word BIP39 seed. How can I try them all on a bitcoin address?</p>

<p>edit: I know the address and the 12 words but i don't know the order of the words</p>

CC BY-SA 4.0
2018-05-19T17:49:09.147Z
Possible duplicate of [Is it possible to brute force bitcoin address creation in order to steal money?](https://bitcoin.stackexchange.com/questions/22/is-it-possible-to-brute-force-bitcoin-address-creation-in-order-to-steal-money)
Junaid Shaikh
CC BY-SA 4.0
2018-05-19T17:51:55.367Z
@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
CC BY-SA 4.0
2018-05-19T17:52:29.853Z
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
CC BY-SA 4.0
2018-05-19T17:52:47.083Z
@code511788465541441 Do you know the address you are looking for, and the derivation path which would lead to it?
Raghav Sood
CC BY-SA 4.0
2018-05-19T17:53:47.753Z
@RaghavSood yes i know the address and the words
code511788465541441
CC BY-SA 4.0
2018-05-19T17:55:49.823Z
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
CC BY-SA 4.0
2018-05-19T17:57:29.467Z
@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
CC BY-SA 4.0
2018-05-19T17:59:18.313Z
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
CC BY-SA 4.0
2018-05-19T18:01:37.430Z
@RaghavSood the address is 3CcxyPhyvyc3S9UuPfu42GNZLvVVV11Uk8
code511788465541441
CC BY-SA 4.0
2018-05-19T18:04:38.833Z
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
CC BY-SA 4.0
2018-05-20T19:44:04.593Z
@code511788465541441 , I misunderstood the use-case over here, sincere apologies.
Junaid Shaikh
<bitcoin-core><java><javascript><mnemonic-seed>
Bruteforce bitcoin address - I know the words + public address but not the order
code511788465541441
# Bruteforce bitcoin address - I know the words + public address but not the order

(Asked by: username_0 on 2018-05-19)

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

**Tags:** bitcoin-core, java, javascript, mnemonic-seed

> **Comments:**
> **username_1**: Possible duplicate of [Is it possible to brute force bitcoin address creation in order to steal money?](https://bitcoin.stackexchange.com/questions/22/is-it-possible-to-brute-force-bitcoin-address-creation-in-order-to-steal-money)  
> **username_0**: @username_1 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  
> **username_2**: 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).  
> **username_2**: @username_0 Do you know the address you are looking for, and the derivation path which would lead to it?  
> **username_0**: @username_2 yes i know the address and the words  
> **username_2**: 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).  
> **username_0**: @username_2 I'm not sure what derivation path is but i know its BIP39 word list with 12 words and what the words are  
> **username_2**: 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)  
> **username_0**: @username_2 the address is 3CcxyPhyvyc3S9UuPfu42GNZLvVVV11Uk8  
> **username_2**: 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  
> **username_1**: @username_0 , I misunderstood the use-case over here, sincere apologies.  

---

## 1 answers

### Answer by username_2 on 2018-05-19. Score: 7 | Accepted answer

Doing this requires three things:

1. Permutations of the seed words
2. The address you're trying to locate
3. The derivation path for that address.

In this specific case, the address is the one [this](https://old.reddit.com/r/Bitcoin/comments/8kk0pa/1_btc_is_hidden_in_this_puzzle_good_luck/) 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.

> **Comments:**
> **username_0**: Thanks, I'm trying that now. What's the for loop for?  
> **username_2**: It'll check the first three addresses on every seed, just in case we're wrong about it being the first address.  
> **username_0**: 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`  
> **username_2**: Because 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.  
> **username_0**: 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 :)  

---

