This repository has been archived by the owner on Nov 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
148 lines (121 loc) · 5.51 KB
/
main.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
import os
import requests
import random
import string
import time
from datetime import datetime
from concurrent.futures import ThreadPoolExecutor
from rich.console import Console
import threading
import sys
import json
console = Console(highlight=False)
# dont worry got fix to prevent underscore at end or start
def generate_username(length, use_numbers, use_underscores):
characters = string.ascii_letters
if use_numbers:
characters += string.digits
if use_underscores:
characters += "_"
while True:
username = ''.join(random.choice(characters) for _ in range(length))
if use_underscores and username.count("_") > 1:
continue
if use_underscores and (username.startswith("_") or username.endswith("_")):
continue
yield username
def check_username(username):
url = f"https://auth.roblox.com/v2/usernames/validate?request.username={username}&request.birthday=04%2F15%2F02&request.context=Signup" # yeah it is that simple
try:
response = requests.get(url)
data = response.json()
if 'message' in data:
return data["message"] == "Username is valid"
else:
cprint("red", f"Error: Invalid API response for {username}")
return False
except json.decoder.JSONDecodeError:
cprint("red", f"Error: Invalid JSON response for {username}")
return False
except Exception as e:
cprint("red", f"Error: Unable to connect to API for {username}")
return False
def cprint(color: str, content: str) -> None:
console.print(f"[bold {color}]{content}[/bold {color}]")
def main():
#custom_file_check = input("Do you want to check a custom filename for valid usernames? (y/n): ")
if False:#custom_file_check.lower() == "y":
custom_filename = input("Enter a custom filename for valid usernames (without extension): ")
valid_username_file = f"valids/{custom_filename}_valid.txt"
if not os.path.exists(valid_username_file):
with open(valid_username_file, "w") as file:
pass
else:
length = int(input("Enter the desired username length: "))
valid_username_file = f"valids/{length}_valid.txt"
if not os.path.exists(valid_username_file):
with open(valid_username_file, "w") as file:
pass
use_numbers = input("Do you want to use numbers in the username? (y/n): ").lower() == "y"
use_underscores = input("Do you want to use underscores in the username? (y/n): ").lower() == "y"
num_valid_usernames = int(input("Enter the number of valid usernames to generate: "))
username_generator = generate_username(length, use_numbers, use_underscores)
existing_usernames = set() # Use a set to track existing usernames
max_iterations = 1000 # Number of iterations before clearing the set
current_iterations = 0
valid_count = 0
num_threads = int(input("Enter the number of threads to use: "))
def input_thread():
#nonlocal custom_file_check
while True:
key = input()
if key.lower() == 'q':
print("Program canceled by user.")
os._exit(0)
else:
main() # Restart the program
input_thread = threading.Thread(target=input_thread)
input_thread.daemon = True
input_thread.start()
with ThreadPoolExecutor(max_workers=num_threads) as executor:
while valid_count < num_valid_usernames:
try:
new_username = next(username_generator)
is_valid = check_username(new_username)
if executor.submit(check_and_print, new_username, valid_username_file, existing_usernames, is_valid, valid_count, num_valid_usernames):
if is_valid:
valid_count += 1 # Only increment for valid usernames
current_iterations += 1
if current_iterations >= max_iterations:
existing_usernames.clear()
current_iterations = 0
except KeyboardInterrupt:
print("Program canceled by user.")
os._exit(0)
print("Generating finished! Press enter to go again.")
key = input()
if key.lower() == 'q':
print("Exiting the program.")
os._exit(0)
else:
os.system('cls') # Clear the console
main()
def check_and_print(new_username, valid_username_file, existing_usernames, is_valid, valid_count, num_valid_usernames):
timestamp = datetime.now().strftime("[%H:%M:%S]")
if is_valid:
with open(valid_username_file, "a") as file:
#if custom_file_check.lower() != "y" and new_username in existing_usernames:
# return False
progress = f"[{valid_count + 1}/{num_valid_usernames}]"
if new_username in existing_usernames:
cprint("orange", f"{timestamp} Username found but is a duplicate! - {new_username}")
else:
existing_usernames.add(new_username)
file.write(new_username + "\n")
cprint("green", f"{timestamp} {progress} Username found! - {new_username}")
return True
else:
cprint("red", f"{timestamp} Username taken! - {new_username}")
return False
if __name__ == "__main__":
main()