-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
102 lines (88 loc) · 2.36 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
package main
import (
"bufio"
"fmt"
"io"
"math/rand"
"net/http"
"net/url"
"os"
"strings"
"time"
)
func main() {
addresses, err := readLines("addresses.txt")
if err != nil {
fmt.Println("Error reading addresses:", err)
return
}
proxies, err := readLines("proxy.txt")
if err != nil {
fmt.Println("Error reading proxies:", err)
return
}
rand.New(rand.NewSource(time.Now().UnixNano())) // Create a new random generator
userAgents, err := readLines("useragents.txt")
if err != nil {
fmt.Println("Error reading user agents:", err)
return
}
if len(addresses) != len(proxies) {
fmt.Println("Error: the number of addresses must match the number of proxies.")
return
}
for i, address := range addresses {
proxy := proxies[i]
var httpClient *http.Client
if strings.Contains(proxy, "http://") {
proxyURL, err := url.Parse(proxy)
if err != nil {
fmt.Println("Error parsing proxy URL:", err)
continue
}
httpClient = &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
} else if strings.Contains(proxy, "https://") {
proxyURL, err := url.Parse(proxy)
if err != nil {
fmt.Println("Error parsing proxy URL:", err)
continue
}
httpClient = &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
} else {
httpClient = &http.Client{}
}
reqBody := fmt.Sprintf(`{"address": "%s", "coins": ["1000000000unibi","1000000000000unusd"]}`, address)
req, err := http.NewRequest("POST", "https://faucet.itn-1.nibiru.fi/", strings.NewReader(reqBody))
if err != nil {
fmt.Println("Error creating request:", err)
continue
}
// Set a random user agent in the headers
req.Header.Set("User-Agent", userAgents[rand.Intn(len(userAgents))])
resp, err := httpClient.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
continue
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
continue
}
fmt.Printf("Response for address %s through proxy %s: %s\n", address, proxy, string(body))
}
}
func readLines(filename string) ([]string, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
return lines, scanner.Err()
}