Advertisement
Pxndaaa

Ownh autoclaimer

Mar 16th, 2020
4,824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.01 KB | None | 0 0
  1. from time import sleep
  2. from threading import Thread
  3. from colorama import Fore, init
  4.  
  5. import requests
  6. import atexit, hashlib, random
  7. import readchar, hmac, uuid, os, string
  8.  
  9. targets = [i.strip() for i in open("targets.txt", "r") if i]
  10.  
  11. BREAK = 3
  12. LINE_FEED = 13
  13. BACK_SPACE = 127 if os.name == "posix" else 8
  14.  
  15. ERROR = "[\x1b[31m-\x1b[39m]"
  16. SUCCESS = "[\x1b[32m+\x1b[39m]"
  17. INPUT = "[\x1b[33m?\x1b[39m]"
  18. INFO = "[\x1b[35m*\x1b[39m]"
  19.  
  20. IG_EDIT_PROFILE = "{{\"username\":\"{}\",\"first_name\":\"{}\",\"email\":\"{}\"}}"
  21. IG_LOGIN_ACTUAL = "{{\"username\":\"{}\",\"device_id\":\"{}\",\"password\":\"{}\",\"login_attempt_count\":\"0\"}}"
  22.  
  23. IG_API_CONTENT_TYPE = "application/x-www-form-urlencoded; charset=UTF-8"
  24. IG_API_USER_AGENT = "Instagram 84.0.0.21.105 Android (24/7.0; 380dpi; 1080x1920; OnePlus; ONEPLUS A3010; OnePlus3T; qcom; en_US; 145652094)"
  25.  
  26. class Signatures(object):
  27. def __init__(self):
  28. super(Signatures, self).__init__()
  29. self.key = b"02271fcedc24c5849a7505120650925e2b4c5b041e0a0bb0f82f4d41cfcdc944"
  30.  
  31. def gen_uuid(self):
  32. return str(uuid.uuid4())
  33.  
  34. def gen_device_id(self):
  35. return "android-{}".format(hashlib.md5(self.gen_uuid().encode("utf-8")).hexdigest()[:16])
  36.  
  37. def gen_signature(self, data):
  38. return hmac.new(self.key, str.encode(data), hashlib.sha256).hexdigest()
  39.  
  40. def sign_post_data(self, data):
  41. return "signed_body={}.{}&ig_sig_key_version=4".format(self.gen_signature(data), data)
  42.  
  43. class Device(object):
  44. def __init__(self):
  45. super(Device, self).__init__()
  46. self.filepath = os.path.expanduser("~/.madara-turbo.ini")
  47.  
  48. if os.path.isfile(self.filepath):
  49. if self.read_ini(self.filepath):
  50. return
  51.  
  52. self.create_device_ini()
  53. self.write_ini(self.filepath)
  54.  
  55. def create_device_ini(self):
  56. self.adid = Signatures().gen_uuid()
  57. self.uuid = Signatures().gen_uuid()
  58. self.phone_id = Signatures().gen_uuid()
  59. self.device_id = Signatures().gen_device_id()
  60.  
  61. def read_ini(self, filename):
  62. lines = [line.strip() for line in open(filename, "r")]
  63.  
  64. for line in lines:
  65. if line.startswith("adid="):
  66. self.adid = line.split("=")[1]
  67. elif line.startswith("uuid="):
  68. self.uuid = line.split("=")[1]
  69. elif line.startswith("phoneid="):
  70. self.phone_id = line.split("=")[1]
  71. elif line.startswith("deviceid="):
  72. self.device_id = line.split("=")[1]
  73.  
  74. return None not in (self.adid, self.uuid, self.phone_id, self.device_id)
  75.  
  76. def write_ini(self, filename):
  77. print("; Madara's Instagram Turbo", file=open(filename, "w"))
  78. print("; Information used for device identification\n", file=open(filename, "a"))
  79. print("[Device]\nadid={}\nuuid={}".format(self.adid, self.uuid), file=open(filename, "a"))
  80. print("phoneid={}\ndeviceid={}".format(self.phone_id, self.device_id), file=open(filename, "a"))
  81.  
  82. class Instagram(object):
  83. def __init__(self):
  84. super(Instagram, self).__init__()
  85. self.device = Device()
  86. self.sigs = Signatures()
  87. self.url = "https://i.instagram.com/api/v1"
  88.  
  89. self.attempts = 0
  90. self.rs = 0
  91. self.running = True
  92. self.logged_in = False
  93. self.session_id = None
  94.  
  95. self.email = None
  96. self.username = None
  97. self.spam_blocked = False
  98. self.rate_limited = False
  99. self.missed_swap = False
  100. self.claimed = False
  101.  
  102. def login(self, username, password):
  103. response = requests.post(self.url + "/accounts/login/", headers={
  104. "Accept": "*/*",
  105. "Accept-Encoding": "gzip, deflate",
  106. "Accept-Language": "en-US",
  107. "User-Agent": IG_API_USER_AGENT,
  108. "Content-Type": IG_API_CONTENT_TYPE,
  109. "X-IG-Capabilities": "3brTvw==",
  110. "X-IG-Connection-Type": "WIFI"
  111. }, data=Signatures().sign_post_data(IG_LOGIN_ACTUAL.format(
  112. username, self.device.device_id, password
  113. )))
  114.  
  115. if response.status_code == 200:
  116. self.session_id = response.cookies["sessionid"]
  117.  
  118. response = response.json()
  119.  
  120. if response["status"] == "fail":
  121. if response["message"] == "challenge_required":
  122. print("{} Please verify this login and make sure 2FA is disabled".format(ERROR))
  123. else:
  124. print("{} {}".format(ERROR, response["message"]))
  125. elif response["status"] == "ok":
  126. self.logged_in = True
  127.  
  128. if self.get_profile_info():
  129. print("{} Successfully logged into: {}".format(SUCCESS, username))
  130. return self.logged_in
  131. else:
  132. print("{} Successfully logged in but failed to fetch profile information, this may be due to a rate limit".format(ERROR))
  133. else:
  134. print("{} An unknown login error occured".format(ERROR))
  135.  
  136. return False
  137.  
  138. def logout(self):
  139. if not self.logged_in:
  140. return False
  141.  
  142. return "\"status\": \"ok\"" in requests.post(self.url + "/accounts/logout/", headers={
  143. "Accept": "*/*",
  144. "Accept-Encoding": "gzip, deflate",
  145. "Accept-Language": "en-US",
  146. "User-Agent": IG_API_USER_AGENT,
  147. "Content-Type": IG_API_CONTENT_TYPE,
  148. "X-IG-Capabilities": "3brTvw==",
  149. "X-IG-Connection-Type": "WIFI"
  150. }, cookies={
  151. "sessionid": self.session_id
  152. }).text
  153.  
  154. def update_consent(self):
  155. response = requests.post(self.url + "/consent/update_dob/", headers={
  156. "Accept": "*/*",
  157. "Accept-Encoding": "gzip, deflate",
  158. "Accept-Language": "en-US",
  159. "User-Agent": IG_API_USER_AGENT,
  160. "Content-Type": IG_API_CONTENT_TYPE,
  161. "X-IG-Capabilities": "3brTvw==",
  162. "X-IG-Connection-Type": "WIFI"
  163. }, data=Signatures().sign_post_data(
  164. "{\"current_screen_key\":\"dob\",\"day\":\"1\",\"year\":\"1998\",\"month\":\"1\"}"
  165. ), cookies={
  166. "sessionid": self.session_id
  167. })
  168.  
  169. if "\"status\": \"ok\"" in response.text:
  170. print("{} Successfully updated consent to GDPR".format(SUCCESS))
  171. return self.get_profile_info()
  172.  
  173. print("{} Failed to consent to GDPR, use an IP that is not from Europe".format(ERROR))
  174. return False
  175.  
  176. def get_profile_info(self):
  177. response = requests.get(self.url + "/accounts/current_user/?edit=true", headers={
  178. "Accept": "*/*",
  179. "Accept-Encoding": "gzip, deflate",
  180. "Accept-Language": "en-US",
  181. "User-Agent": IG_API_USER_AGENT,
  182. "X-IG-Capabilities": "3brTvw==",
  183. "X-IG-Connection-Type": "WIFI"
  184. }, cookies={
  185. "sessionid": self.session_id
  186. })
  187.  
  188. if "\"consent_required\"" in response.text:
  189. return self.update_consent()
  190. elif "few minutes" in response.text:
  191. return False
  192.  
  193. response = response.json()
  194. self.email = response["user"]["email"]
  195. self.username = response["user"]["username"]
  196.  
  197. return self.email is not None and self.username is not None
  198.  
  199. def target_available(self, username):
  200. response = requests.get(self.url + "/usertags/{}/feed/username/".format(username), headers={
  201. "Accept": "*/*",
  202. "Accept-Encoding": "gzip, deflate",
  203. "Accept-Language": "en-US",
  204. "User-Agent": IG_API_USER_AGENT,
  205. "X-IG-Capabilities": "3brTvw==",
  206. "X-IG-Connection-Type": "WIFI"
  207. }, cookies={
  208. "sessionid": self.session_id,
  209. "ds_user_id": random_id(random.choice([9, 10, 11, 12]))
  210. }, timeout=1).text
  211.  
  212. if "few minutes" in response:
  213. self.rate_limited = True
  214. self.running = False
  215.  
  216. return "valid username" in response
  217.  
  218. def claim_target(self, username):
  219. response = requests.post(self.url + "/accounts/edit_profile/", headers={
  220. "Accept": "*/*",
  221. "Accept-Encoding": "gzip, deflate",
  222. "Accept-Language": "en-US",
  223. "User-Agent": IG_API_USER_AGENT,
  224. "Content-Type": IG_API_CONTENT_TYPE,
  225. "X-IG-Capabilities": "3brTvw==",
  226. "X-IG-Connection-Type": "WIFI"
  227. }, cookies={
  228. "sessionid": self.session_id
  229. }, data=self.sigs.sign_post_data(
  230. IG_EDIT_PROFILE.format(username, self.claim_name, self.email)
  231. ))
  232.  
  233. if "feedback_required" in response.text:
  234. self.spam_blocked = True
  235. self.running = True
  236.  
  237. return "\"status\": \"ok\"" in response.text
  238.  
  239. class Turbo(Thread):
  240. def __init__(self, instagram):
  241. super(Turbo, self).__init__()
  242. self.instagram = instagram
  243. self.targets = targets.copy()
  244.  
  245. def run(self):
  246. random.shuffle(self.targets)
  247.  
  248. while self.instagram.running:
  249. try:
  250. for target in self.targets:
  251. if self.instagram.target_available(target):
  252. if self.instagram.claim_target(target):
  253. print("{} Claimed @{} after {:,} attempts".format(SUCCESS, target, self.instagram.attempts))
  254. else:
  255. print("{} Missed @{} after {:,} attempts".format(ERROR, target, self.instagram.attempts))
  256.  
  257. self.instagram.running = False
  258.  
  259. self.instagram.attempts += 1
  260. print("{} Attempt #{:,} - @{}".format(INFO, self.instagram.attempts, target))
  261. except:
  262. continue
  263.  
  264. class RequestsPS(Thread):
  265. def __init__(self, instagram):
  266. super(RequestsPS, self).__init__()
  267. self.instagram = instagram
  268.  
  269. def run(self):
  270. while self.instagram.running:
  271. before = self.instagram.attempts
  272. sleep(1) # Wait 1 second and calculate the difference
  273. self.instagram.rs = self.instagram.attempts - before
  274.  
  275. def random_id(length):
  276. return "".join(random.choice(string.digits) for _ in range(length))
  277.  
  278. def get_input(prompt, mask=False):
  279. ret_str = b""
  280. print(prompt, end="", flush=True)
  281.  
  282. while True:
  283. ch = readchar.readchar()
  284.  
  285. if os.name == "posix":
  286. ch = str.encode(ch)
  287.  
  288. code_point = ord(ch)
  289.  
  290. if code_point == BREAK: # Ctrl-C
  291. if os.name == "posix":
  292. print("\n", end="", flush=True)
  293.  
  294. exit(0)
  295. elif code_point == LINE_FEED: # Linefeed
  296. break
  297. elif code_point == BACK_SPACE: # Backspace
  298. if len(ret_str) > 0:
  299. ret_str = ret_str[:-1]
  300. print("\b \b", end="", flush=True)
  301. else:
  302. ret_str += ch
  303. print("*" if mask else ch.decode("utf-8"), end="", flush=True)
  304.  
  305. print("\n", end="", flush=True)
  306. return ret_str.decode("utf-8")
  307.  
  308. def on_exit(instagram):
  309. if instagram.logged_in:
  310. if instagram.logout():
  311. print("{} Successfully logged out".format(SUCCESS))
  312. else:
  313. print("{} Failed to logout :/".format(ERROR))
  314.  
  315. if __name__ == "__main__":
  316. instagram = Instagram()
  317. atexit.register(on_exit, instagram)
  318.  
  319. init() # Use Colorama to make Termcolor work on Windows too
  320. print("["+Fore.GREEN+"+"+Fore.WHITE+"]"+Fore.RED+" F"+Fore.BLUE+"r"+Fore.CYAN+"e"+Fore.MAGENTA+"d"+Fore.GREEN+"o"+Fore.RED+"2"+Fore.CYAN+"S"+Fore.YELLOW+"l"+Fore.BLUE+"o"+Fore.MAGENTA+"w"+Fore.RED+"!"+Fore.WHITE+"\n".format(Fore))
  321.  
  322. username = get_input("{} Username: ".format(INPUT)).strip()
  323. password = get_input("{} Password: ".format(INPUT), True)
  324.  
  325. print("\n{} Attempting to login...".format(INFO))
  326.  
  327. if not instagram.login(username, password):
  328. print("{} Failed to login into: {} - Check your password/account".format(ERROR, email))
  329. exit(1)
  330.  
  331. threads = get_input("\n{} Threads: ".format(INPUT)).strip()
  332. instagram.claim_name = get_input("{} Name: ".format(INPUT)).strip()
  333.  
  334. get_input("{} Ready. Press ENTER to start turbo!".format(SUCCESS))
  335. print("\x1b[A{}\x1b[A".format(" " * 38))
  336.  
  337. for i in range(int(threads)):
  338. thread = Turbo(instagram)
  339. thread.setDaemon(True)
  340. thread.start()
  341.  
  342. rs_thread = RequestsPS(instagram)
  343. rs_thread.setDaemon(True)
  344. rs_thread.start()
  345.  
  346. try:
  347. while instagram.running:
  348. sleep(0.1)
  349. except KeyboardInterrupt:
  350. print("{} Turbo stopped, exiting after {:,} attempts...\n".format(ERROR, instagram.attempts))
  351.  
  352. if instagram.rate_limited:
  353. print("{} Rate limited after {:,} attempts lmfao!".format(ERROR, instagram.attempts))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement