paster442

Code (3-L)

Aug 15th, 2021 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.17 KB | None | 0 0
  1. import time, requests, math, concurrent.futures as cf, datetime
  2.  
  3. start_time = time.time()
  4.  
  5. f = open("usernames.txt", "a")
  6. p = open("pastebin-links.txt", "a")
  7.  
  8. CONNECTIONS = 20
  9.  
  10. def get_usernames():
  11.     my_list = list()
  12.  
  13.     alphabet = "abcdefghijklmnopqrstuvwxyz1234567890-_"
  14.  
  15.     a = alphabet[0:26] # letters
  16.     b = alphabet[36:] # dash and underscore
  17.     c = alphabet[26:36] # numbers
  18.    
  19.     for l1 in alphabet[14:]: # opqrstuvwxyz1234567890-_
  20.         for l2 in alphabet:
  21.             for l3 in alphabet:
  22.  
  23.                 condition1 = l1 in a and l2 in a and l3 in a
  24.                 condition2 = l1 in b and l2 in b and l3 in b
  25.                 condition3 = l1 in c and l2 in c and l3 in c
  26.  
  27.                 if not condition1 and not condition2 and not condition3:
  28.                     my_list.append(l1 + l2 + l3)
  29.     return my_list
  30.  
  31. def check_username(username):
  32.     r = requests.get(f"https://api.scratch.mit.edu/accounts/checkusername/{username}/")
  33.     good_response = '{"username":"' + username + '","msg":"valid username"}'
  34.     return r.text == good_response # example good response: {"username":"InsertUsernameHere","msg":"valid username"}
  35.  
  36. def write_to_file(list):
  37.     f.write("\n".join(item.upper() for item in list))
  38.  
  39. def round_to_the_nearest_ten(n):
  40.     return int(math.ceil(n / 10.0)) * 10
  41.  
  42. usernames = get_usernames()
  43.  
  44. available_usernames = list()
  45. combinations = round_to_the_nearest_ten(len(usernames)) # it's 25536 but we round it up to 25540 because we can divide 25540 by 10
  46. print("e")
  47. counter = 0
  48. with cf.ThreadPoolExecutor(max_workers = CONNECTIONS) as executor:
  49.     future_to_url = {executor.submit(check_username, username): username for username in usernames}
  50.     for future in cf.as_completed(future_to_url):
  51.         print(counter)
  52.         counter += 1
  53.         if counter % (combinations / 10) == 0.0:
  54.             print(str(int((counter / combinations) * 100)) + " % Done")
  55.  
  56.         username = future_to_url[future]
  57.         if future.result():
  58.             available_usernames.append(username)
  59.  
  60. print("100 % Done")
  61.  
  62. available_usernames = sorted(available_usernames, key = lambda src: ["abcdefghijklmnopqrstuvwxyz1234567890-_".index(char) for char in src])
  63.  
  64. f.truncate(0) # clear file contents
  65. write_to_file(available_usernames)
  66. f.close()
  67.  
  68.  
  69. key = 'KEY'
  70. text = "\n".join(item.upper() for item in available_usernames)
  71. t_title = 'All available 3-letter Scratch usernames (' + str(datetime.date.today()) + ')'
  72.  
  73. login_data = {
  74.     'api_dev_key': key,
  75.     'api_user_name': 'USERNAME',
  76.     'api_user_password': 'PASSWORD'
  77.     }
  78. data = {
  79.     'api_option': 'paste',
  80.     'api_dev_key':key,
  81.     'api_paste_code':text,
  82.     'api_paste_name':t_title,
  83.     'api_paste_expire_date': None,
  84.     'api_user_key': None,
  85.     'api_paste_format': None,
  86.     }
  87.  
  88. login = requests.post("https://pastebin.com/api/api_login.php", data=login_data)
  89.  
  90. data['api_user_key'] = login.text
  91.  
  92. r = requests.post("https://pastebin.com/api/api_post.php", data=data)
  93.  
  94. link = r.text
  95. print(link)
  96. p.write("\n" + "https://pastebin.com/raw/" + link[21:])
  97. p.close()
  98.  
  99. print("\n" + "Execution Time: " + str(round(((time.time() - start_time)/60), 3)) + " Minutes")
Add Comment
Please, Sign In to add comment