-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
144 lines (120 loc) · 2.96 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
package main
import (
"./service"
"encoding/hex"
"encoding/json"
"fmt"
"github.com/PuerkitoBio/goquery"
"github.com/ethereum/go-ethereum/crypto"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
"time"
)
var eth map[string]string
var btc map[string]string
type Wallet struct {
publicKey, privateKey string
}
var tlBot = service.NewTelegramBot("523919774:AAEL5bsetD3yhIMpjgiQSvWFY9dfvs1ibAQ", -1001341233186)
func main() {
//"https://etherscan.io/accounts"
//"https://99bitcoins.com/bitcoin-rich-list-top1000/"
eth = make(map[string]string)
btc = make(map[string]string)
readFile("eth")
fmt.Println(len(eth))
if len(eth) <= 0 {
getEthWallets(1)
writeFile("eth")
}
//readFile("btc")
//fmt.Println(len(btc))
//if len(btc) <= 0{
// getBtcWallets()
// writeFile("btc")
//}
for i := 0; i < 4; i++ {
go func() {
for {
ethWallet := generateEthWallet()
if eth[ethWallet.publicKey] == "1" {
//log.Println(ethWallet)
fmt.Println(ethWallet)
//log.Println("public: " + ethWallet.publicKey +
// " private: " + ethWallet.privateKey)
tlBot.SendMessage("public: " + ethWallet.publicKey +
" private: " + ethWallet.privateKey)
}
}
}()
}
for {
fmt.Println("scan richest wallets Ping!")
//tlBot.SendMessage("scan richest wallets Ping!")
time.Sleep(30 * time.Minute)
}
}
func generateEthWallet() Wallet {
key, _ := crypto.GenerateKey()
address := crypto.PubkeyToAddress(key.PublicKey).Hex()
privateKey := hex.EncodeToString(key.D.Bytes())
return Wallet{strings.ToLower(address), privateKey}
}
func getEthWallets(page int) {
fmt.Println(page)
res, err := http.Get(fmt.Sprintf("https://etherscan.io/accounts/%d?", page))
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
doc, err := goquery.NewDocumentFromReader(res.Body)
if err != nil {
log.Fatal("Error loading HTTP response body. ", err)
}
doc.Find(`.table tbody tr`).Each(func(i int, selection *goquery.Selection) {
walletAddr := selection.Find(`td`).Eq(1).Text()
eth[strings.ToLower(walletAddr)] = "1"
})
_, bool := doc.Find(`.pagination [title='Go to Next'] a`).First().Attr("href")
if bool {
getEthWallets(page + 1)
}
}
func writeFile(name string) {
var jsonData []byte
var err error
if name == "eth" {
jsonData, err = json.Marshal(eth)
} else {
jsonData, err = json.Marshal(btc)
}
if err != nil {
panic(err)
}
fmt.Println(string(jsonData))
jsonFile, err := os.Create(fmt.Sprintf("./%s.json", name))
if err != nil {
panic(err)
}
defer jsonFile.Close()
jsonFile.Write(jsonData)
jsonFile.Close()
fmt.Println("JSON data written to ", jsonFile.Name())
}
func readFile(name string) {
jsonFile, err := os.Open(fmt.Sprintf("./%s.json", name))
if err != nil {
fmt.Println(err)
}
fmt.Println(fmt.Sprintf("Successfully Opened %s.json", name))
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
if name == "eth" {
json.Unmarshal([]byte(byteValue), ð)
} else {
json.Unmarshal([]byte(byteValue), &btc)
}
}