forked from code-l0n3ly/instagram-auto-claimer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAutoClaimer.go
329 lines (296 loc) · 8.9 KB
/
AutoClaimer.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
package main
import (
"bufio"
"crypto/tls"
_ "crypto/tls"
_ "encoding/base64"
_ "fmt"
"github.com/DisgoOrg/disgohook"
"github.com/DisgoOrg/disgohook/api"
"github.com/fatih/color"
"github.com/gosuri/uilive"
"github.com/valyala/fasthttp"
"github.com/valyala/fasthttp/fasthttpproxy"
"log"
"net"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
_ "strings"
"sync"
"time"
)
// placeholder url. Change it to your base url.
const BASE_URL = "https://i.instagram.com/api/v1/accounts/set_username/"
var c *fasthttp.Client
// number of parallelism
var writer = uilive.New()
var counter = 0
var GoodAttempts = 0
var BadAttempts = 0
var Claimed string
var proxies []string
var proxiescount int = 1
var users []string
var userscount int = 1
var sessions []string
var sessionscount int = 1
var rateCount = 10
var threadsCount = 50
// Stream inputs to input channel
func sendDiscord(username string) {
webhook, _ := disgohook.NewWebhookClientByToken(nil, nil, "Discord Token Here")
_, _ = webhook.SendEmbeds(api.NewEmbedBuilder().
AddField("Username",username,true).
AddField("R/N", strconv.Itoa(counter),true).
SetAuthor("New Claim","","https://cdn.discordapp.com/avatars/225147959757635584/a_55374353240a1adca3d749c19bd1883a.gif?size=1024").
SetFooter("Coded With Luv , L0N3LY","").
SetThumbnail("https://cdn.discordapp.com/avatars/225147959757635584/a_55374353240a1adca3d749c19bd1883a.gif?size=1024").
Build(),
)
return
}
// Normal function for HTTP call, no knowledge of goroutine/channels
func sendUser(username,proxy,session string) (string, error) {
c = &fasthttp.Client{
Dial: fasthttpproxy.FasthttpHTTPDialer(proxy),
MaxConnsPerHost: 1000000,
ReadBufferSize: 8192000,
ReadTimeout: time.Duration(1) * time.Second,
MaxIdleConnDuration: time.Duration(1) * time.Second,
TLSConfig: &tls.Config{InsecureSkipVerify: true},
}
var jsonstring = []byte("username="+username)
var Body string
req := fasthttp.AcquireRequest()
req.SetBody(jsonstring)
req.Header.SetMethod("POST")
req.Header.Add("User-Agent", "Instagram 167.0.0.24.120 Android (25/7.1.2; 192dpi; 720x1280; google; G011A; G011A; intel; en_US; 256966583)")
req.Header.Add("Cookie", "sessionid="+session)
req.Header.Add("X-MID", "missing")
req.Header.SetContentType("application/x-www-form-urlencoded; charset=UTF-8")
req.SetRequestURI(BASE_URL)
res := fasthttp.AcquireResponse()
err := c.Do(req, res)
if err != nil {
//fmt.Println("h1")
counter += 1
BadAttempts+=1
fasthttp.ReleaseRequest(req)
fasthttp.ReleaseResponse(res)
if proxiescount == len(proxies)-1 || proxiescount > len(proxies) {
proxiescount = 1
} else if proxiescount < len(proxies)-1 {
proxiescount += 1
}
if sessionscount == len(sessions)-1 || sessionscount > len(sessions) {
sessionscount = 1
} else if sessionscount < len(sessions) {
sessionscount += 1
}
_, _ = sendUser(username, proxies[proxiescount], sessions[sessionscount])
return "",nil
} else {
Body = string(res.Body())
//fmt.Println("h2")
if strings.Contains(Body, "\""+username+"\"") {
if strings.Contains(Claimed,username) {
}else{
if Claimed == "" {
Claimed = username
} else {
Claimed = Claimed + "," + username
}
f, err := os.Create(username + ".txt")
if err != nil {
log.Fatal(err)
}
defer func(f *os.File) {
err := f.Close()
if err != nil {
}
}(f)
_, err2 := f.WriteString(username + ":" + session + "\n")
if err2 != nil {
log.Fatal(err2)
}
sendDiscord(username)
}
} else if Body == "" {
//fmt.Println("h3")
counter+=1
BadAttempts+=1
fasthttp.ReleaseRequest(req)
fasthttp.ReleaseResponse(res)
if proxiescount == len(proxies)-1 || proxiescount > len(proxies) {
proxiescount = 1
} else if proxiescount < len(proxies)-1 {
proxiescount += 1
}
if sessionscount == len(sessions)-1 || sessionscount > len(sessions) {
sessionscount = 1
} else if sessionscount < len(sessions) {
sessionscount += 1
}
_, _ = sendUser(username, proxies[proxiescount], sessions[sessionscount])
return "", nil
} else {
//fmt.Println("h4")
counter += 1
GoodAttempts+=1
}
}
jsonstring = nil
fasthttp.ReleaseRequest(req)
fasthttp.ReleaseResponse(res)
return Body, nil
}
// Wrapper for sendUser return value, used as result channel type
func AsyncHTTP(users []string) ([]string, error) {
// limit concurrency to 5
// have a max rate of 10/sec
rate := make(chan struct{}, rateCount)
for i := 0; i < cap(rate); i++ {
rate <- struct{}{}
}
// leaky bucket
var wg sync.WaitGroup
for i := 0; i <= threadsCount; i++ {
wg.Add(1)
go func() {
defer wg.Done()
// wait for the rate limiter
if userscount == len(users)-1 || userscount > len(users) {
userscount = 1
} else if userscount < len(users)-1 {
userscount += 1
}
if proxiescount == len(proxies)-1 || proxiescount > len(proxies) {
proxiescount = 1
} else if proxiescount < len(proxies)-1 {
proxiescount += 1
}
if sessionscount == len(sessions)-1 || sessionscount > len(sessions) {
sessionscount = 1
} else if sessionscount < len(sessions) {
sessionscount += 1
}
_, _ = sendUser(users[userscount], proxies[proxiescount], sessions[sessionscount])
d := color.New(color.FgCyan, color.Bold)
_, _ = d.Fprintf(writer, "[1] - Attempts := {%v}\n",counter)
_, _ = d.Fprintf(writer.Newline(), "[2] - Good := {%v}\n",GoodAttempts)
_, _ = d.Fprintf(writer.Newline(), "[3] - Error := {%v}\n",BadAttempts)
_, _ = d.Fprintf(writer.Newline(), "[4] - User := {%v}\n",users[userscount])
_, _ = d.Fprintf(writer.Newline(), "[5] - Proxy := {%v}\n",proxies[proxiescount])
_, _ = d.Fprintf(writer.Newline(), "[6] - Session := {%v}\n",sessions[sessionscount])
_, _ = d.Fprintf(writer.Newline(), "[7] - Claimed := {%v}\n",Claimed)
}()
}
wg.Wait()
close(rate)
return users, nil
}
func main() {
//resp, err := http.Get("https://pastebin.com/raw/gzDHSvN6")
//if err != nil {
// log.Fatalln(err)
//}
//We Read the response body on the line below.
//body, err := ioutil.ReadAll(resp.Body)
//if err != nil {
// log.Fatalln(err)
//}
//Convert the body to type string
//sb := string(body)
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
log.Fatal(err)
}
defer conn.Close()
//ipadd := conn.LocalAddr().(*net.UDPAddr)
//if strings.Contains(sb,ipadd.IP.String()){
scannert := bufio.NewScanner(os.Stdin)
d := color.New(color.BgHiRed, color.Bold)
d.Println("[1] - Enter Threads :")
scannert.Scan()
threadsCount, _ = strconv.Atoi(scannert.Text())
d.Println("[2] - Enter Rate :")
scannert.Scan()
rateCount, _ = strconv.Atoi(scannert.Text())
CallClear()
// populate users param
file, err := os.Open("list.txt")
if err != nil {
log.Fatal(err)
}
defer func() {
if err = file.Close(); err != nil {
log.Fatal(err)
}
}()
scanner := bufio.NewScanner(file)
for scanner.Scan() { // internally, it advances token based on sperator
users = append(users, scanner.Text())
}
file2, err2 := os.Open("proxy.txt")
if err2 != nil {
log.Fatal(err2)
}
defer func() {
if err2 = file2.Close(); err2 != nil {
log.Fatal(err2)
}
}()
scanner2 := bufio.NewScanner(file2)
for scanner2.Scan() { // internally, it advances token based on sperator
proxies = append(proxies, scanner2.Text())
}
file3, err3 := os.Open("session.txt")
if err3 != nil {
log.Fatal(err3)
}
defer func() {
if err3 = file3.Close(); err3 != nil {
log.Fatal(err3)
}
}()
scanner3 := bufio.NewScanner(file3)
for scanner3.Scan() { // internally, it advances token based on sperator
sessions = append(sessions, scanner3.Text())
}
color.Cyan("█████████████████████████████████████\n█▄─▄███─▄▄─█▄─▀█▄─▄█▄▄▄░█▄─▄███▄─█─▄█\n██─██▀█─██─██─█▄▀─███▄▄░██─██▀██▄─▄██\n▀▄▄▄▄▄▀▄▄▄▄▀▄▄▄▀▀▄▄▀▄▄▄▄▀▄▄▄▄▄▀▀▄▄▄▀▀")
writer.Start()
for{
_, err := AsyncHTTP(users)
if err != nil {
return
}
}
//}else{
// fmt.Println("Not Activated ...")
//}
}
var clear map[string]func()
func init() {
clear = make(map[string]func()) //Initialize it
clear["linux"] = func() {
cmd := exec.Command("clear") //Linux example, its tested
cmd.Stdout = os.Stdout
cmd.Run()
}
clear["windows"] = func() {
cmd := exec.Command("cmd", "/c", "cls") //Windows example, its tested
cmd.Stdout = os.Stdout
cmd.Run()
}
}
func CallClear() {
value, ok := clear[runtime.GOOS] //runtime.GOOS -> linux, windows, darwin etc.
if ok { //if we defined a clear func for that platform:
value() //we execute it
} else { //unsupported platform
panic("Your platform is unsupported! I can't clear terminal screen :(")
}
}