-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
231 lines (188 loc) · 7.29 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
package main
import (
"bufio"
"context"
"errors"
"fmt"
"log"
"math/rand"
"os"
"strconv"
"strings"
"sync"
"time"
chromedp "github.com/chromedp/chromedp"
"github.com/joho/godotenv"
api2captcha "github.com/kpabellan/2captcha-go"
)
var waitGroup sync.WaitGroup
var captchaClientKey string = goDotEnvVariable("CAPTCHACLIENTKEY")
var catchall string = goDotEnvVariable("CATCHALL")
var seededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))
var userAgents = []string{"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240", "Mozilla/5.0 (iPad; CPU OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1)", "Mozilla/5.0 (Linux; Android 7.1; vivo 1716 Build/N2G47H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.98 Mobile Safari/537.36"}
func goDotEnvVariable(key string) string {
err := godotenv.Load(".env")
if err != nil {
log.Fatalf("Error loading .env file")
}
return os.Getenv(key)
}
func randomCharNumerals(length int) string {
const charset = "0123456789"
b := make([]byte, length)
for i := range b {
b[i] = charset[seededRand.Intn(len(charset))]
}
return string(b)
}
func readLines(path string) ([]string, error) {
file, err := os.Open(path)
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()
}
func formatProxy(proxy string) string {
parts := strings.Split(proxy, ":")
if len(parts) != 4 {
if len(parts) == 2 {
ip := parts[0]
port := parts[1]
return fmt.Sprintf("http://%s:%s", ip, port)
}
fmt.Println("Invalid proxy format:", proxy)
return ""
}
ip := parts[0]
port := parts[1]
username := parts[2]
password := parts[3]
return fmt.Sprintf("http://%s:%s@%s:%s", username, password, ip, port)
}
func runFunc(timeout time.Duration, task chromedp.ActionFunc) chromedp.ActionFunc {
return func(ctx context.Context) error {
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
return task.Do(ctx)
}
}
func runTask(timeout time.Duration, tasks chromedp.Tasks) chromedp.ActionFunc {
return func(ctx context.Context) error {
timeoutContext, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
return tasks.Do(timeoutContext)
}
}
func solveReCaptcha(client *api2captcha.Client, kkUrl, dataSiteKey string) (string, error) {
c := api2captcha.ReCaptcha{
SiteKey: dataSiteKey,
Url: kkUrl,
Invisible: true,
Action: "verify",
}
return client.Solve(c.ToRequest())
}
func generateKK(proxy string) {
defer waitGroup.Done()
os.Setenv("HTTP_PROXY", proxy)
client := api2captcha.NewClient(captchaClientKey)
kkUrl := "https://www.krispykreme.com/account/create-account"
tomorrow := time.Now().AddDate(0, 0, 1)
tomorrowDay := strconv.Itoa(tomorrow.Day())
tomorrowMonth := strconv.Itoa(int(tomorrow.Month()))
catchallEmail := "kp" + randomCharNumerals(5) + "@" + catchall
password := "Donuttime123"
var siteKey string
var siteKeyOk bool
if len(tomorrowDay) == 1 {
tomorrowDay = "0" + tomorrowDay
}
if len(tomorrowMonth) == 1 {
tomorrowMonth = "0" + tomorrowMonth
}
opts := append(chromedp.DefaultExecAllocatorOptions[:],
chromedp.UserAgent(userAgents[seededRand.Intn(len(userAgents))]),
)
cx, cancel := chromedp.NewExecAllocator(context.Background(), opts...)
defer cancel()
ctx, cancel := chromedp.NewContext(cx)
defer cancel()
delay := func(min, max time.Duration) {
time.Sleep(min + time.Duration(seededRand.Int63n(int64(max-min))))
}
typeAction := func(selector, text string) chromedp.ActionFunc {
return func(ctx context.Context) error {
for _, r := range text {
chromedp.SendKeys(selector, string(r)).Do(ctx)
delay(50*time.Millisecond, 200*time.Millisecond)
}
return nil
}
}
var tasks []chromedp.Action
tasks = append(tasks,
chromedp.Navigate(kkUrl),
chromedp.AttributeValue(`[data-sitekey]`, "data-sitekey", &siteKey, &siteKeyOk),
chromedp.Click("#ctl00_plcMain_cbTermsOfUse"), // Click terms of use
chromedp.Evaluate(`document.querySelector("#btnSubmit").removeAttribute("disabled")`, nil), // Enable the submit button
chromedp.SetAttributeValue("#btnSubmit", "class", "btn", chromedp.ByQuery), // Change submit button class to btn
chromedp.ActionFunc(typeAction("#ctl00_plcMain_txtFirstName", "Krispy")), // Input first name
chromedp.ActionFunc(typeAction("#ctl00_plcMain_txtLastName", "Kreme")), // Input last name
chromedp.ActionFunc(typeAction("#ctl00_plcMain_ddlBirthdayMM", tomorrowMonth)), // Input birthday month
chromedp.ActionFunc(typeAction("#ctl00_plcMain_ddlBirthdayDD", tomorrowDay)), // Input birthday day
chromedp.ActionFunc(typeAction("#ctl00_plcMain_txtZipCode", "90001")), // Input zipcode
chromedp.ActionFunc(typeAction("#ctl00_plcMain_ucPhoneNumber_txt1st", randomCharNumerals(3))), // Input phone number area code
chromedp.ActionFunc(typeAction("#ctl00_plcMain_ucPhoneNumber_txt2nd", randomCharNumerals(3))), // Input phone number first 3 digits
chromedp.ActionFunc(typeAction("#ctl00_plcMain_ucPhoneNumber_txt3rd", randomCharNumerals(4))), // Input phone number last 4 digits
chromedp.ActionFunc(typeAction("#ctl00_plcMain_txtEmail", catchallEmail)), // Input email
chromedp.ActionFunc(typeAction("#ctl00_plcMain_txtPassword", password)), // Input password
chromedp.ActionFunc(typeAction("#ctl00_plcMain_confirmPasswordTxt", password)), // Input confirm password
runFunc(5*time.Minute, func(ctx context.Context) error {
if !siteKeyOk {
return errors.New("missing data-sitekey")
}
token, err := solveReCaptcha(client, kkUrl, siteKey)
if err != nil {
return err
}
return chromedp.SetJavascriptAttribute(`#g-recaptcha-response`, "innerText", token).Do(ctx)
}),
chromedp.Click("#btnSubmit", chromedp.ByQuery), // Submit form
runTask(3*time.Minute, chromedp.Tasks{
chromedp.WaitVisible(`a[href*="twitter"]`, chromedp.ByQuery),
}),
)
if err := chromedp.Run(ctx, tasks...); err != nil {
fmt.Printf("Krispy Kreme Generation Failed. (%s)\n", err)
} else {
fmt.Printf("Krispy Kreme Generation Success!\n")
fmt.Printf("Email: %s\nPassword: %s\n", catchallEmail, password)
}
}
func main() {
lines, err := readLines("proxylist.txt")
if err != nil {
log.Fatalf("readLines: %s", err)
}
var genAmount int
fmt.Print("Enter amount to generate: ")
fmt.Scanf("%d", &genAmount)
fmt.Printf("Generating %d Krispy Kreme accounts...\n", genAmount)
for i := 0; i < genAmount; i++ {
if i != 0 && i%3 == 0 {
time.Sleep(150 * time.Second)
}
proxy := lines[seededRand.Intn(len(lines))]
formattedProxy := formatProxy(proxy)
go generateKK(formattedProxy)
time.Sleep(1 * time.Second)
waitGroup.Add(1)
}
waitGroup.Wait()
}