-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
173 lines (141 loc) · 3.61 KB
/
main.go
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package main
import (
"bufio"
"encoding/json"
"fmt"
"log"
"math/rand"
"net/http"
"net/url"
"os"
"strings"
"sync"
"time"
"github.com/FactomProject/go-bip32"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/tyler-smith/go-bip39"
)
const (
workerCount = 100
)
func worker(phraseChan chan string, wg *sync.WaitGroup) {
defer wg.Done()
for phrase := range phraseChan {
masterKey := getSeed(phrase)
if masterKey == nil {
continue
}
checkBitcoinBalance(masterKey, phrase)
}
}
func getSeed(phrase string) *bip32.Key {
seed := bip39.NewSeed(phrase, "")
masterKey, err := bip32.NewMasterKey(seed)
if err != nil {
log.Printf("Failed to generate master key: %v", err)
return nil
}
return masterKey
}
func main() {
fmt.Println("Starting...")
file, err := os.Open("wordlist.txt")
if err != nil {
panic(err)
}
defer file.Close()
var words []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
words = append(words, scanner.Text())
}
if err := scanner.Err(); err != nil {
panic(err)
}
if len(words) < 12 {
panic("Wordlist too small")
}
rand.Seed(time.Now().UnixNano())
phraseChan := make(chan string)
var wg sync.WaitGroup
for i := 0; i < workerCount; i++ {
wg.Add(1)
go worker(phraseChan, &wg)
}
for {
selectedWords := make([]string, 12)
for i := 0; i < 12; i++ {
selectedWords[i] = words[rand.Intn(len(words))]
}
phrase := strings.Join(selectedWords, " ")
if bip39.IsMnemonicValid(phrase) {
phraseChan <- phrase
}
}
}
func checkBitcoinBalance(masterKey *bip32.Key, phrase string) {
// Derive the Bitcoin address
pubKey := masterKey.PublicKey()
pubKeyHash := btcutil.Hash160(pubKey.Key)
addr, err := btcutil.NewAddressPubKeyHash(pubKeyHash, &chaincfg.MainNetParams)
if err != nil {
log.Printf("Failed to derive Bitcoin address: %v", err)
return
}
parts := strings.SplitN("residential.flashproxy.io:8082:7vBuJyvpSY8WxSRqm3VYOCCFhBdkxW:KuLAef8BDAOFKnbP_country-DE", ":", 4) // Split into maximum 4 parts
if len(parts) < 4 {
log.Printf("Invalid proxy format\n")
return
}
username := parts[2]
password := parts[3]
proxyURL := fmt.Sprintf("http://%s:%s@%s:%s", username, password, parts[0], parts[1])
urlParsed, err := url.Parse(proxyURL)
if err != nil {
log.Printf("Error parsing proxy URL: %v\n", err)
return
}
client := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(urlParsed),
},
Timeout: 5 * time.Second,
}
// Check balance using Blockstream API
url := fmt.Sprintf("https://blockstream.info/api/address/%s", addr.EncodeAddress())
resp, err := client.Get(url)
if err != nil {
//log.Printf("Failed to retrieve balance: %v", err)
return
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
//log.Printf("Error getting balance: %v", resp.Status)
return
}
var balance struct {
ChainStats struct {
FundedTxoSum int64 `json:"funded_txo_sum"`
} `json:"chain_stats"`
}
if err := json.NewDecoder(resp.Body).Decode(&balance); err != nil {
log.Printf("Failed to decode balance: %v", err)
return
}
if float64(balance.ChainStats.FundedTxoSum)/1e8 > 0.0000001 {
file, err := os.Create("goods.txt")
if err != nil {
log.Printf("Failed to create file: %v", err)
return
}
defer file.Close()
// write the data to the file
stringToWrite := fmt.Sprintf("Bitcoin address: %s\n, Master key: %s\n Balance: %f BTC\n Phrase: %s\n", addr.EncodeAddress(), masterKey.String(), float64(balance.ChainStats.FundedTxoSum)/1e8, phrase)
_, err = file.WriteString(stringToWrite)
if err != nil {
log.Printf("Failed to write to file: %v", err)
return
}
}
}