-
Notifications
You must be signed in to change notification settings - Fork 2
/
generator.py
370 lines (334 loc) · 11.7 KB
/
generator.py
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
import requests
import threading
import names
from secrets import randbelow, choice
import random
import time
import json
from termcolor import colored
import colorama
colorama.init()
SMS_API_KEY = "" #sms activate
# generate random password
def gen_ran_passw():
letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
chars = ["!","?","=","&","$","#"]
random_password = ""
oldvalue = ""
choicelist = [0,1,2]
for x in range(14):
if oldvalue:
choicelist.remove(oldvalue)
value = choice(choicelist)
choicelist.append(oldvalue)
else:
value = randbelow(3)
if value == 0:
if randbelow(2) == 0:
random_password += letters[randbelow(len(letters))].upper()
else:
random_password += letters[randbelow(len(letters))]
elif value == 1:
random_password += chars[randbelow(len(chars))]
elif value == 2:
random_password += str(randbelow(10))
oldvalue = value
random_password += letters[randbelow(len(letters))].upper() + letters[randbelow(len(letters))]
random_password += chars[randbelow(len(chars))] + str(randbelow(10))
return random_password
# generates random client id
def gen_client_id():
letters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
ran4letters = ""
for _ in range(4):
if random.randint(0,1) == 0:
ran4letters += letters[random.randrange(0,len(letters))]
else:
ran4letters += letters[random.randrange(0,len(letters))].upper()
ran15chars = ""
for _ in range(15):
if random.randint(0,1) == 0:
if random.randint(0,1) == 0:
ran15chars += letters[random.randrange(0,len(letters))]
else:
ran15chars += letters[random.randrange(0,len(letters))].upper()
else:
ran15chars += str(random.randint(0,9))
client_id = f'Yf{ran4letters}ALAAG{letters[random.randrange(0,len(letters))].upper() + ran15chars}'
return client_id
# setup login headers
def setup_login_headers(csrf, claim):
headers = {
'accept': '*/*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'q=0.9,en-US;q=0.8,en;q=0.7',
'content-length': '0',
'content-type': 'application/x-www-form-urlencoded',
'origin': 'https://www.instagram.com',
'referer': 'https://www.instagram.com/',
'sec-ch-ua':'" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
'x-asbd-id': '198387',
'x-csrftoken': csrf,
'x-ig-app-id': '936619743392459',
'x-ig-www-claim': claim,
'x-instagram-ajax': 'cc6f59f85f33',
'x-requested-with': 'XMLHttpRequest'
}
return headers
# main function
def instagram_generate(thread_id, smsapi=None, country_code=None):
PROXY_HOST = ''
PROXY_PORT = 40000
PROXY_USER = ''
PROXY_PASS = ''
proxy_rotate = {
"http": f"http://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}",
"https": f"http://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}"
}
s = requests.Session()
try:
s.proxies = proxy_rotate
except ValueError as err:
print(err)
return
while True:
try:
headers = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'none',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36'
}
res = s.get('https://www.instagram.com/data/shared_data/', headers=headers)
device_id = res.text.split('"device_id":"')[1].split('"')[0]
csrf = res.text.split('csrf_token":"')[1].split('"')[0]
break
except:
s = requests.Session()
try:
s.proxies = proxy_rotate
except ValueError as err:
print(err)
return
time.sleep(2)
time.sleep(0.2)
password = gen_ran_passw()
client_id = gen_client_id()
name = names.get_full_name()
month = str(random.randint(1,12))
day = str(random.randint(10,25))
year = str(random.randint(1960,2000))
username = name.split()[0] + str(random.randint(111,999)) + '_' + name.split()[1]
headers = {
'accept': '*/*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9',
'content-type': 'application/x-www-form-urlencoded',
'origin': 'https://www.instagram.com',
'referer': 'https://www.instagram.com/accounts/emailsignup',
'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36',
'x-asbd-id': '198387',
'x-csrftoken': csrf,
'x-ig-app-id': '936619743392459',
'x-ig-www-claim': '0',
'x-instagram-ajax': 'c35f58698901',
'x-requested-with': 'XMLHttpRequest',
'x-web-device-id': device_id
}
for x in range(3):
res = s.get(f'https://sms-activate.org/stubs/handler_api.php?api_key={smsapi}&action=getNumber&service=ig&country={country_to_phone[country_code]}')
try:
phonenum = res.text.split(':')[2]
phone_id = res.text.split(':')[1]
except:
print(colored(f"Process [{thread_id}] - Account can't find number for usage", "red"))
return
while True:
body = {
'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{int(time.time())}:{password}',
'phone_number': phonenum,
'client_id': client_id,
'username': username,
'first_name': name,
'stopDeletionNonce': '',
'trustedDeviceRecords': '{}',
'queryParams': '{}',
'seamless_login_enabled': '1',
'opt_into_one_tap': 'false'
}
res = s.post('https://www.instagram.com/accounts/web_create_ajax/attempt/', headers=headers, data=body)
if res.json().get("spam", False) == True:
print(colored(f"Process [{thread_id}] - Account creation failed SPAM detected", "red"))
return
try:
if not res.json()["status"]:
print(colored(f"Process [{thread_id}] - Account creation failed code: 1", "red"))
return
except:
print(colored(f"Process [{thread_id}] - Account creation failed code: 2", "red"))
return
if "errors" in res.json() and "username" in res.json()["errors"]:
print(colored(f"Process [{thread_id}] - Username is taken, choosing new one", "red"))
username = res.json()["username_suggestions"][0]
break
time.sleep(1)
body = {
'client_id': client_id,
'phone_number': phonenum,
"phone_id": phone_id,
"big_blue_token": ""
}
res = s.post('https://www.instagram.com/accounts/send_signup_sms_code_ajax/', headers=headers, data=body)
if res.json().get("sms_sent", True) == False:
print(colored(f"Process [{thread_id}] - Account sms is not sent to instagram", "red"))
return
else:
if res.json()['status'] == 'fail':
print(colored(f"Process [{thread_id}] - Account can't send SMS because rate limited captcha", "red"))
return
print(colored(f"Process [{thread_id}] - Account waiting for sms code", "yellow"))
sms_code = False
while True:
url = f'https://api.sms-activate.org/stubs/handler_api.php?api_key={smsapi}&action=getStatus&id={phone_id}'
try:
res = requests.get(url)
status = res.text
if status == "STATUS_WAIT_CODE":
time.sleep(3)
else:
try:
sms_code = res.text.split(':')[1]
print(colored(f"Process [{thread_id}] - Account received sms code", "green"))
break
except:
print(colored(f"Process [{thread_id}] - Account getting sms code status is not good, status: {status}", "red"))
break
except Exception as e:
time.sleep(3)
break
if sms_code:
res = requests.get(f'https://api.sms-activate.org/stubs/handler_api.php?api_key={smsapi}&action=setStatus&status=6&id={phone_id}')
body = {
'client_id': client_id,
'phone_number': phonenum,
'sms_code': sms_code
}
res = s.post('https://www.instagram.com/accounts/validate_signup_sms_code_ajax/', headers=headers, data=body)
print(colored(f"Process [{thread_id}] - Account activated sms code", "green"))
break
else:
requests.get(f'https://api.sms-activate.org/stubs/handler_api.php?api_key={smsapi}&action=setStatus&status=8&id={phone_id}')
time.sleep(1)
return
body = {
'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{int(time.time())}:{password}',
'phone_number': phonenum,
'client_id': client_id,
'username': username,
'first_name': name,
'sms_code': sms_code,
'seamless_login_enabled': '1'
}
res = s.post('https://www.instagram.com/accounts/web_create_ajax/attempt/', headers=headers, data=body)
time.sleep(0.5)
body["month"] = month
body["day"] = day
body["year"] = year
body["tos_version"] = 'eu'
res = s.post('https://www.instagram.com/accounts/web_create_ajax/', headers=headers, data=body)
if res.status_code == 200:
print(colored(f"Process [{thread_id}] - Account creation success", "green"))
else:
print(colored(f"Process [{thread_id}] - Account creation failed", "red"))
return
time.sleep(15) # waiting for clipping
for retries in range(3):
res = s.get('https://www.instagram.com/accounts/login/')
csrf = res.text.split('csrf_token":"')[1].split('"')[0]
insta_claim = "0"
payload = {
'username': username,
'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{int(time.time())}:{password}',
'optIntoOneTap': 'false'
}
headers = setup_login_headers(csrf, insta_claim)
res = s.post('https://www.instagram.com/accounts/login/ajax/', headers=headers, data=payload)
try:
if res.json()["authenticated"]:
print(colored(f"Process [{thread_id}] - Account is logged in", "green"))
with open('results.txt', 'a') as acc_file:
acc_file.write(f'{username}:{password}\n')
print(colored(f"Process [{thread_id}] - Account is saved", "green"))
break
else:
#login failed
if retries < 2:
s = requests.Session()
try:
s.proxies = proxy_rotate
except ValueError as err:
print(err)
return
time.sleep(15)
else:
print(colored(f"Process [{thread_id}] - Account saving failed, could't login", "red"))
return
except Exception as e:
if retries < 2:
s = requests.Session()
try:
s.proxies = proxy_rotate
except ValueError as err:
print(err)
return
time.sleep(15)
else:
print(colored(f"Process [{thread_id}] - Account auth failed, could't login", "red"))
return
print(colored("Instagram Account Generator", "cyan"))
print(colored("Author: ", "cyan") + "Zile42O")
print("\n\n")
# currently supported countries
# to add more please check on sms-activate org
country_to_phone = {
"DE": "43", # Germany
"IT": "86", # Italy
"ES": "56", # Spain
"RU": "0", # Russia
"CA": "36", # Canada
"MN": "171", # Montenegro
"RS": "29" # Serbia
}
print(colored("How much accounts you need?", "cyan"))
ts = int(input('=> '))
threadlist = []
for i in range(ts):
t = threading.Thread(target=lambda h=i:instagram_generate(h, smsapi=SMS_API_KEY, country_code="DE"))
threadlist.append(t)
t.start()
time.sleep(0.3)
# wait till all tasks finished
for thread in threadlist:
thread.join()
input(colored("Generator is finished. Press enter to exit...", "cyan"))
colorama.deinit()