Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, os, requests, math, concurrent.futures as cf, sys
- start_time = time.time()
- f = open(os.path.join("/storage/emulated/0/Download", "usernames.txt"), "a")
- #f = open("usernames.txt", "a")
- CONNECTIONS = 20
- def get_usernames():
- my_list = list()
- alphabet = "abcdefghijklmnopqrstuvwxyz1234567890-_"
- a = alphabet[0:26] # letters
- b = alphabet[36:38] # dash and underscore
- c = alphabet[26:36] # numbers
- for l1 in alphabet[14:38]: # opqrstuvwxyz1234567890-_
- for l2 in alphabet:
- for l3 in alphabet:
- user = l1 + l2 + l3
- cond1 = l1 in a and l2 in a and l3 in a
- cond2 = l1 in b and l2 in b and l3 in b
- cond3 = l1 in c and l2 in c and l3 in c
- if not cond1 and not cond2 and not cond3:
- my_list.append(user)
- return my_list
- def check_username(username):
- r = requests.get(f'https://api.scratch.mit.edu/accounts/checkusername/{username}/')
- return r.text != '{"username":"' + username + '","msg":"valid username"}'
- def write_to_file(list):
- for item in list:
- f.write(item.upper() + "\n")
- usernames = get_usernames()
- available_usernames = list()
- combinations = int(math.ceil(len(usernames) / 10.0)) * 10 # it's 25536 but we round it up to 25540 because we can divide 25540 by 10
- counter = 0
- with cf.ThreadPoolExecutor(max_workers = CONNECTIONS) as executor:
- future_to_url = {executor.submit(check_username, username): username for username in usernames}
- for future in cf.as_completed(future_to_url):
- counter += 1
- if counter % (combinations / 10) == 0.0:
- print(str(int((counter / combinations) * 100)) + " % Done")
- username = future_to_url[future]
- if not future.result():
- available_usernames.append(username)
- print("100 % Done")
- available_usernames = sorted(available_usernames, key = lambda src: ["abcdefghijklmnopqrstuvwxyz1234567890-_".index(char) for char in src])
- f.truncate(0) # clear file contents
- write_to_file(available_usernames)
- f.close()
- print("\n" + "Execution Time: " + str(round(((time.time() - start_time)/60), 3)) + " Minutes")
- sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement