-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.js
57 lines (54 loc) · 2.14 KB
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const fs = require('fs')
const bip39 = require('bip39')
const bip32 = require('bip32')
const bitcoin = require('bitcoinjs-lib')
const wordList = fs.readFileSync('./english.txt').toString().split('\n')
const guessSeedMain = JSON.parse(fs.readFileSync('./guessSeed.json'))
for (const word of guessSeedMain) {
if (!word === '' && !wordList.includes(word)) {
throw new Error(word)
}
}
const config = JSON.parse(fs.readFileSync('./config.json'))
const skipIndexes = fs.existsSync('./skipIndexes.json') ? JSON.parse(fs.readFileSync('./skipIndexes.json')) : []
const addresses = config.addresses
const pwd = config.pwd
function bruteForce(startIndex) {
const guessSeed = [...guessSeedMain]
for (let w = startIndex; w < wordList.length; w++) {
const w1 = wordList[w]
console.log(`${w}-${w1}`)
if (skipIndexes.includes(w)) {
console.log(`Skipping ${w}`)
continue
}
guessSeed[2] = w1
for (const w2 of wordList) {
guessSeed[9] = w2
for (const w3 of wordList) {
guessSeed[10] = w3
const phrase = guessSeed.join(' ')
if (bip39.validateMnemonic(phrase)) {
const seed = bip39.mnemonicToSeedSync(phrase, pwd)
const hdnode = bip32.fromSeed(seed)
for (let i = 0; i <= 3; i++) {
const path = `m/44'/0'/0'/0/${i}`
const node = hdnode.derivePath(path)
const address = bitcoin.payments.p2pkh({pubkey: node.publicKey}).address
if (addresses.includes(address)) {
console.log('Success!')
console.log(path)
console.dir(phrase)
console.log(address)
fs.writeFileSync('success.json', JSON.stringify({
path, phrase, address
}))
return
}
}
}
}
}
}
}
bruteForce(parseInt(process.argv[2]))