-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.py
181 lines (144 loc) · 7.22 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import os
import requests
import time
import uuid
import random
import threading
import subprocess
from ctypes import windll
from queue import Queue
url = "https://api.gx.me/profile/token"
num_urls = int(input('Star https://github.com/TheCuteOwl/Discord-Nitro-Generator for making this script (If you skid, give credit ;)\nHow many nitros do you want to generate: '))
Session_ID = input('Enter account session ID (Check on https://github.com/TheCuteOwl/Discord-Nitro-Generator for more info )')
use_proxies = input('Do you want to use proxies? (yes/no): ').lower()
while use_proxies not in ['yes', 'no']:
use_proxies = input('Error! Do you want to use proxies? (yes/no): ').lower()
start_time = time.time()
deleted_proxies_count = 0
def read_proxies():
try:
with open("proxies.txt", "r") as file:
return file.read().splitlines()
except:
with open("proxies.txt", "w") as file:
return []
def write_proxies(proxies):
with open("proxies.txt", "w") as file:
for proxy in proxies:
file.write(f"{proxy}\n")
proxies = read_proxies() if use_proxies == 'yes' else [None] * num_urls
success_count = 0
lock = threading.Lock()
stop_event = threading.Event()
def generate_url(proxy):
try:
global success_count
global deleted_proxies_count
while success_count < num_urls and not stop_event.is_set():
start_request_time = time.time()
try:
headers = {
'Accept': 'application/json',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7',
'Cookie': f'SESSION_TYPE=user; SESSION={Session_ID}',
'Origin': 'https://www.opera.com',
'Referer': 'https://www.opera.com/',
'Sec-Ch-Ua': '"Not A(Brand";v="99", "Opera GX";v="107", "Chromium";v="121"',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': '"Windows"',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 OPR/107.0.0.0'
}
response = requests.get('https://api.gx.me/profile/token', headers=headers)
datas = response.json()
headers = {
"Content-Type": "application/json",
"Accept": "*/*",
"Origin": "https://www.opera.com",
"Referer": "https://www.opera.com/",
"Sec-Ch-Ua": '"Opera GX";v="105", "Chromium";v="119", "Not?A_Brand";v="24"',
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": '"Windows"',
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "cross-site",
"Authorization": f"{datas['data']}",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 OPR/105.0.0.0"
}
r = requests.post('https://discord.opr.gg/v2/direct-fulfillment', headers=headers)
data = r.json()
output_file_path = "output.txt"
if not os.path.exists(output_file_path):
with open(output_file_path, "w"):
pass
urls = 'https://discord.com/billing/partner-promotions/1180231712274387115/'
with open(output_file_path, "a") as file:
file.write(f"{urls}{data['token']}\n")
success_count += 1
print(f"URL generated and saved to {output_file_path}")
update_window_title(success_count, len(proxies))
if use_proxies == 'yes' and proxy is not None:
create_and_start_thread(proxy)
except requests.RequestException as e:
if use_proxies == 'yes' and proxy is not None and isinstance(e, requests.exceptions.ProxyError) and ("WinError 10061" in str(e) or "Cannot connect to proxy." in str(e) or "TLS/SSL connection has been closed (EOF)" in str(e) or "[SSL: UNEXPECTED_EOF_WHILE_READING]" in str(e) or "Max retries exceeded with url" in str(e)) or "timed out." in str(e) or "Connection aborted" in str(e) or "Too many requests" in str(e) or "EOF occurred in violation of protocol" in str(e) or "429" in str(e):
proxies.remove(proxy)
deleted_proxies_count += 1
print(f"Proxy {proxy} removed from the list. Deleted Proxies: {deleted_proxies_count} - {len(proxies)} left")
try:
write_proxies(proxies)
except:
pass
update_window_title(success_count, len(proxies))
except Exception as e:
print(e)
end_request_time = time.time()
request_time = end_request_time - start_request_time
except:
pass
def update_window_title(success_count, num_threads):
try:
with lock:
window_title = f"URLs Generated: {success_count} | Working Proxies: {num_threads} | Deleted Proxies: {deleted_proxies_count}"
if os.name == 'posix':
subprocess.run(["printf", f"\033]0;{window_title}\007"])
elif os.name == 'nt':
windll.kernel32.SetConsoleTitleW(window_title)
except:
pass
def create_and_start_thread(proxy):
thread = threading.Thread(target=generate_url, args=(proxy,))
thread.start()
return thread
def main():
global success_count
if use_proxies == 'no':
while success_count < num_urls:
generate_url(None)
else:
num_threads = int(input(f"Enter Number Of Threads: "))
while success_count < num_urls and not stop_event.is_set():
threads = []
for i in range(num_threads - len(threads)):
proxy = random.choice(proxies) if proxies else None
thread = create_and_start_thread(proxy)
threads.append(thread)
for thread in threads:
if not thread.is_alive():
threads.remove(thread)
try:
for thread in threads:
thread.join()
except KeyboardInterrupt:
print("Script terminated by user.")
while len(threads) < num_threads and not stop_event.is_set():
proxy = random.choice(proxies) if proxies else None
thread = create_and_start_thread(proxy)
threads.append(thread)
end_time = time.time()
elapsed_time = end_time - start_time
print(f"All URLs generated and saved! Star https://github.com/TheCuteOwl/Discord-Nitro-Generator for making this script")
print(f"Time taken: {elapsed_time:.2f} seconds")
main()