├── README.md ├── generator.py └── results.txt /README.md: -------------------------------------------------------------------------------- 1 | # instagram-generator 2 | Instagram account generator in Python code, using proxy and sms-activate.org API. 3 | 4 | * Generated accounts should be in *results.txt* 5 | 6 | **Note:** 7 | * Change https://github.com/zile42O/instagram-generator/blob/bcd341d4181c83965c75613cb22c309e3ef8fa3c/generator.py#L13 To your sms-activate.org KEY 8 | * Update your residential proxy auth: https://github.com/zile42O/instagram-generator/blob/bcd341d4181c83965c75613cb22c309e3ef8fa3c/generator.py#L96-L99 9 | * Use exactly country for generating account which is based on your proxies: https://github.com/zile42O/instagram-generator/blob/bcd341d4181c83965c75613cb22c309e3ef8fa3c/generator.py#L359 10 | 11 | ### Disclaimer 12 | Any form of automation is strictly prohibited by Instagram's ToS, use the code for educational purposes. 13 | -------------------------------------------------------------------------------- /generator.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import threading 3 | import names 4 | from secrets import randbelow, choice 5 | import random 6 | import time 7 | import json 8 | from termcolor import colored 9 | import colorama 10 | 11 | colorama.init() 12 | 13 | SMS_API_KEY = "" #sms activate 14 | 15 | # generate random password 16 | def gen_ran_passw(): 17 | 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"] 18 | chars = ["!","?","=","&","$","#"] 19 | random_password = "" 20 | oldvalue = "" 21 | choicelist = [0,1,2] 22 | for x in range(14): 23 | if oldvalue: 24 | choicelist.remove(oldvalue) 25 | value = choice(choicelist) 26 | choicelist.append(oldvalue) 27 | else: 28 | value = randbelow(3) 29 | if value == 0: 30 | if randbelow(2) == 0: 31 | random_password += letters[randbelow(len(letters))].upper() 32 | else: 33 | random_password += letters[randbelow(len(letters))] 34 | elif value == 1: 35 | random_password += chars[randbelow(len(chars))] 36 | elif value == 2: 37 | random_password += str(randbelow(10)) 38 | oldvalue = value 39 | 40 | random_password += letters[randbelow(len(letters))].upper() + letters[randbelow(len(letters))] 41 | random_password += chars[randbelow(len(chars))] + str(randbelow(10)) 42 | 43 | return random_password 44 | 45 | # generates random client id 46 | def gen_client_id(): 47 | 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"] 48 | ran4letters = "" 49 | for _ in range(4): 50 | if random.randint(0,1) == 0: 51 | ran4letters += letters[random.randrange(0,len(letters))] 52 | else: 53 | ran4letters += letters[random.randrange(0,len(letters))].upper() 54 | ran15chars = "" 55 | for _ in range(15): 56 | if random.randint(0,1) == 0: 57 | if random.randint(0,1) == 0: 58 | ran15chars += letters[random.randrange(0,len(letters))] 59 | else: 60 | ran15chars += letters[random.randrange(0,len(letters))].upper() 61 | else: 62 | ran15chars += str(random.randint(0,9)) 63 | 64 | client_id = f'Yf{ran4letters}ALAAG{letters[random.randrange(0,len(letters))].upper() + ran15chars}' 65 | return client_id 66 | 67 | # setup login headers 68 | def setup_login_headers(csrf, claim): 69 | headers = { 70 | 'accept': '*/*', 71 | 'accept-encoding': 'gzip, deflate, br', 72 | 'accept-language': 'q=0.9,en-US;q=0.8,en;q=0.7', 73 | 'content-length': '0', 74 | 'content-type': 'application/x-www-form-urlencoded', 75 | 'origin': 'https://www.instagram.com', 76 | 'referer': 'https://www.instagram.com/', 77 | 'sec-ch-ua':'" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"', 78 | 'sec-ch-ua-mobile': '?0', 79 | 'sec-ch-ua-platform': '"Windows"', 80 | 'sec-fetch-dest': 'empty', 81 | 'sec-fetch-mode': 'cors', 82 | 'sec-fetch-site': 'same-origin', 83 | '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', 84 | 'x-asbd-id': '198387', 85 | 'x-csrftoken': csrf, 86 | 'x-ig-app-id': '936619743392459', 87 | 'x-ig-www-claim': claim, 88 | 'x-instagram-ajax': 'cc6f59f85f33', 89 | 'x-requested-with': 'XMLHttpRequest' 90 | } 91 | return headers 92 | 93 | # main function 94 | def instagram_generate(thread_id, smsapi=None, country_code=None): 95 | 96 | PROXY_HOST = '' 97 | PROXY_PORT = 40000 98 | PROXY_USER = '' 99 | PROXY_PASS = '' 100 | 101 | proxy_rotate = { 102 | "http": f"http://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}", 103 | "https": f"http://{PROXY_USER}:{PROXY_PASS}@{PROXY_HOST}:{PROXY_PORT}" 104 | } 105 | s = requests.Session() 106 | try: 107 | s.proxies = proxy_rotate 108 | except ValueError as err: 109 | print(err) 110 | return 111 | 112 | while True: 113 | try: 114 | headers = { 115 | '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', 116 | 'accept-encoding': 'gzip, deflate, br', 117 | 'accept-language': 'en-US,en;q=0.9', 118 | 'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"', 119 | 'sec-ch-ua-mobile': '?0', 120 | 'sec-ch-ua-platform': '"Windows"', 121 | 'sec-fetch-dest': 'document', 122 | 'sec-fetch-mode': 'navigate', 123 | 'sec-fetch-site': 'none', 124 | 'sec-fetch-user': '?1', 125 | 'upgrade-insecure-requests': '1', 126 | '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' 127 | } 128 | res = s.get('https://www.instagram.com/data/shared_data/', headers=headers) 129 | device_id = res.text.split('"device_id":"')[1].split('"')[0] 130 | csrf = res.text.split('csrf_token":"')[1].split('"')[0] 131 | break 132 | except: 133 | s = requests.Session() 134 | try: 135 | s.proxies = proxy_rotate 136 | except ValueError as err: 137 | print(err) 138 | return 139 | time.sleep(2) 140 | 141 | time.sleep(0.2) 142 | 143 | password = gen_ran_passw() 144 | client_id = gen_client_id() 145 | name = names.get_full_name() 146 | month = str(random.randint(1,12)) 147 | day = str(random.randint(10,25)) 148 | year = str(random.randint(1960,2000)) 149 | username = name.split()[0] + str(random.randint(111,999)) + '_' + name.split()[1] 150 | 151 | headers = { 152 | 'accept': '*/*', 153 | 'accept-encoding': 'gzip, deflate, br', 154 | 'accept-language': 'en-US,en;q=0.9', 155 | 'content-type': 'application/x-www-form-urlencoded', 156 | 'origin': 'https://www.instagram.com', 157 | 'referer': 'https://www.instagram.com/accounts/emailsignup', 158 | 'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"', 159 | 'sec-ch-ua-mobile': '?0', 160 | 'sec-ch-ua-platform': '"Windows"', 161 | 'sec-fetch-dest': 'empty', 162 | 'sec-fetch-mode': 'cors', 163 | 'sec-fetch-site': 'same-origin', 164 | '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', 165 | 'x-asbd-id': '198387', 166 | 'x-csrftoken': csrf, 167 | 'x-ig-app-id': '936619743392459', 168 | 'x-ig-www-claim': '0', 169 | 'x-instagram-ajax': 'c35f58698901', 170 | 'x-requested-with': 'XMLHttpRequest', 171 | 'x-web-device-id': device_id 172 | } 173 | 174 | for x in range(3): 175 | 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]}') 176 | try: 177 | phonenum = res.text.split(':')[2] 178 | phone_id = res.text.split(':')[1] 179 | except: 180 | print(colored(f"Process [{thread_id}] - Account can't find number for usage", "red")) 181 | return 182 | 183 | while True: 184 | body = { 185 | 'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{int(time.time())}:{password}', 186 | 'phone_number': phonenum, 187 | 'client_id': client_id, 188 | 'username': username, 189 | 'first_name': name, 190 | 'stopDeletionNonce': '', 191 | 'trustedDeviceRecords': '{}', 192 | 'queryParams': '{}', 193 | 'seamless_login_enabled': '1', 194 | 'opt_into_one_tap': 'false' 195 | } 196 | res = s.post('https://www.instagram.com/accounts/web_create_ajax/attempt/', headers=headers, data=body) 197 | if res.json().get("spam", False) == True: 198 | print(colored(f"Process [{thread_id}] - Account creation failed SPAM detected", "red")) 199 | return 200 | try: 201 | if not res.json()["status"]: 202 | print(colored(f"Process [{thread_id}] - Account creation failed code: 1", "red")) 203 | return 204 | except: 205 | print(colored(f"Process [{thread_id}] - Account creation failed code: 2", "red")) 206 | return 207 | if "errors" in res.json() and "username" in res.json()["errors"]: 208 | print(colored(f"Process [{thread_id}] - Username is taken, choosing new one", "red")) 209 | username = res.json()["username_suggestions"][0] 210 | break 211 | time.sleep(1) 212 | 213 | body = { 214 | 'client_id': client_id, 215 | 'phone_number': phonenum, 216 | "phone_id": phone_id, 217 | "big_blue_token": "" 218 | } 219 | res = s.post('https://www.instagram.com/accounts/send_signup_sms_code_ajax/', headers=headers, data=body) 220 | if res.json().get("sms_sent", True) == False: 221 | print(colored(f"Process [{thread_id}] - Account sms is not sent to instagram", "red")) 222 | return 223 | else: 224 | if res.json()['status'] == 'fail': 225 | print(colored(f"Process [{thread_id}] - Account can't send SMS because rate limited captcha", "red")) 226 | return 227 | print(colored(f"Process [{thread_id}] - Account waiting for sms code", "yellow")) 228 | 229 | sms_code = False 230 | while True: 231 | url = f'https://api.sms-activate.org/stubs/handler_api.php?api_key={smsapi}&action=getStatus&id={phone_id}' 232 | try: 233 | res = requests.get(url) 234 | status = res.text 235 | 236 | if status == "STATUS_WAIT_CODE": 237 | time.sleep(3) 238 | else: 239 | try: 240 | sms_code = res.text.split(':')[1] 241 | print(colored(f"Process [{thread_id}] - Account received sms code", "green")) 242 | break 243 | except: 244 | print(colored(f"Process [{thread_id}] - Account getting sms code status is not good, status: {status}", "red")) 245 | break 246 | except Exception as e: 247 | time.sleep(3) 248 | break 249 | 250 | if sms_code: 251 | res = requests.get(f'https://api.sms-activate.org/stubs/handler_api.php?api_key={smsapi}&action=setStatus&status=6&id={phone_id}') 252 | body = { 253 | 'client_id': client_id, 254 | 'phone_number': phonenum, 255 | 'sms_code': sms_code 256 | } 257 | res = s.post('https://www.instagram.com/accounts/validate_signup_sms_code_ajax/', headers=headers, data=body) 258 | print(colored(f"Process [{thread_id}] - Account activated sms code", "green")) 259 | break 260 | 261 | else: 262 | requests.get(f'https://api.sms-activate.org/stubs/handler_api.php?api_key={smsapi}&action=setStatus&status=8&id={phone_id}') 263 | time.sleep(1) 264 | return 265 | 266 | body = { 267 | 'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{int(time.time())}:{password}', 268 | 'phone_number': phonenum, 269 | 'client_id': client_id, 270 | 'username': username, 271 | 'first_name': name, 272 | 'sms_code': sms_code, 273 | 'seamless_login_enabled': '1' 274 | } 275 | res = s.post('https://www.instagram.com/accounts/web_create_ajax/attempt/', headers=headers, data=body) 276 | time.sleep(0.5) 277 | 278 | body["month"] = month 279 | body["day"] = day 280 | body["year"] = year 281 | body["tos_version"] = 'eu' 282 | res = s.post('https://www.instagram.com/accounts/web_create_ajax/', headers=headers, data=body) 283 | if res.status_code == 200: 284 | print(colored(f"Process [{thread_id}] - Account creation success", "green")) 285 | else: 286 | print(colored(f"Process [{thread_id}] - Account creation failed", "red")) 287 | return 288 | 289 | time.sleep(15) # waiting for clipping 290 | 291 | for retries in range(3): 292 | res = s.get('https://www.instagram.com/accounts/login/') 293 | csrf = res.text.split('csrf_token":"')[1].split('"')[0] 294 | insta_claim = "0" 295 | payload = { 296 | 'username': username, 297 | 'enc_password': f'#PWD_INSTAGRAM_BROWSER:0:{int(time.time())}:{password}', 298 | 'optIntoOneTap': 'false' 299 | } 300 | 301 | headers = setup_login_headers(csrf, insta_claim) 302 | res = s.post('https://www.instagram.com/accounts/login/ajax/', headers=headers, data=payload) 303 | try: 304 | if res.json()["authenticated"]: 305 | print(colored(f"Process [{thread_id}] - Account is logged in", "green")) 306 | with open('results.txt', 'a') as acc_file: 307 | acc_file.write(f'{username}:{password}\n') 308 | print(colored(f"Process [{thread_id}] - Account is saved", "green")) 309 | break 310 | else: 311 | #login failed 312 | if retries < 2: 313 | s = requests.Session() 314 | try: 315 | s.proxies = proxy_rotate 316 | except ValueError as err: 317 | print(err) 318 | return 319 | time.sleep(15) 320 | else: 321 | print(colored(f"Process [{thread_id}] - Account saving failed, could't login", "red")) 322 | return 323 | 324 | except Exception as e: 325 | if retries < 2: 326 | s = requests.Session() 327 | try: 328 | s.proxies = proxy_rotate 329 | except ValueError as err: 330 | print(err) 331 | return 332 | time.sleep(15) 333 | else: 334 | print(colored(f"Process [{thread_id}] - Account auth failed, could't login", "red")) 335 | return 336 | 337 | print(colored("Instagram Account Generator", "cyan")) 338 | print(colored("Author: ", "cyan") + "Zile42O") 339 | print("\n\n") 340 | 341 | # currently supported countries 342 | # to add more please check on sms-activate org 343 | 344 | country_to_phone = { 345 | "DE": "43", # Germany 346 | "IT": "86", # Italy 347 | "ES": "56", # Spain 348 | "RU": "0", # Russia 349 | "CA": "36", # Canada 350 | "MN": "171", # Montenegro 351 | "RS": "29" # Serbia 352 | } 353 | 354 | print(colored("How much accounts you need?", "cyan")) 355 | ts = int(input('=> ')) 356 | 357 | threadlist = [] 358 | for i in range(ts): 359 | t = threading.Thread(target=lambda h=i:instagram_generate(h, smsapi=SMS_API_KEY, country_code="DE")) 360 | threadlist.append(t) 361 | t.start() 362 | time.sleep(0.3) 363 | 364 | # wait till all tasks finished 365 | for thread in threadlist: 366 | thread.join() 367 | 368 | input(colored("Generator is finished. Press enter to exit...", "cyan")) 369 | 370 | colorama.deinit() -------------------------------------------------------------------------------- /results.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zile42O/instagram-generator/f68bfda0a1038c8a80dc84a18f568b95052e1e6d/results.txt --------------------------------------------------------------------------------