-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
229 lines (222 loc) · 12.8 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import discum, time, os, random, string, httpx, json
from threading import Thread
from os import listdir
from itertools import cycle
from base64 import b64encode
from urllib.request import Request
#Ur Info
changed = 0
usernameScraped = 0
pfpScraped = 0
scrapedDone = 0
changerDone = 0
UP = "\x1B[3A"
CLR = "\x1B[0K"
config = json.load(open('config.json'))
token = config.get('token')
ProxyPool = cycle(open("data/proxies.txt", "r").read().splitlines())
bot = discum.Client(token=token, log=False)
def close_after_fetching(resp, guild_id):
if bot.gateway.finishedMemberFetching(guild_id):
bot.gateway.removeCommand({'function': close_after_fetching, 'params': {'guild_id': guild_id}})
bot.gateway.close()
def rc(x):
''.join(random.choices(string.ascii_uppercase + string.digits, k=x))
def scrape(guild_id, channel_id):
global usernameScraped
global pfpScraped
global scrapedDone
scrapedDone = 0
Thread(target=scraperPrint, args=(guild_id,)).start()
try:
usernames = []
pfps = []
bot.gateway.fetchMembers(guild_id, channel_id, wait=0.01,reset=False,keep="all")
bot.gateway.command({'function': close_after_fetching, 'params': {'guild_id': guild_id}})
bot.gateway.run()
bot.gateway.resetSession()
g = bot.gateway.session.guild(guild_id)
for info in (dict(g.members).items()):
info2 = list(info)
usernames.append(info2[1]["username"])
avatar = info2[1]["avatar"]
pfps.append(f"{info2[0]}:{avatar}")
with open("data/usernames.txt", "a+") as w:
for i in usernames:
if "|" in i:
pass
elif "HAPEBEAST" in i:
pass
elif "BUSINESS APE" in i:
pass
else:
try:
usernameScraped+=1
w.write(f"{i}\n")
except:
pass
threads = []
for i in pfps:
i2 = i.split(":")
if i2[1] == "None":
pass
elif i2[1] == None:
pass
else:
url = f"https://cdn.discordapp.com/avatars/{i2[0]}/{i2[1]}.png?size=512"
try:
with open("data/pfps.txt", "a+") as f:
f.write(f'{url}\n')
f.close()
x = Thread(target=save, args=(url, i2,))
x.start()
threads.append(x)
except Exception as error:
print(error)
for i in threads:
i.join()
scrapedDone = 1
input(f"Scraped {pfpScraped} Avatars and {usernameScraped} Usernames!")
return bot.gateway.session.guild(guild_id).members
except Exception as err:
input(f"Failed to scrape. Error: {err}")
def save(url, i2):
global pfpScraped
count=0
while count < 4: #retries 3 times
try:
with open(f'./data/imgs/{i2[0]}.png', 'wb') as f:
pfpScraped+=1
f.write(x.content)
return
except:
pass
def changer(namepfp, tokenformat, proxyless):
global changed
global changerDone
changerDone = 0
os.system('cls' if os.name == 'nt' else 'clear')
tokens = []
usernames = []
tokenfile = open("data/tokens.txt", "r").read().splitlines()
pfps = "data/imgs/"
usernames = cycle(open("data/usernames.txt", "r").read().splitlines())
if tokenformat=='1':
for i in tokenfile:tokens.append(i)
elif tokenformat=='2':
for i in tokenfile:tokenunformatted=i.split(':');token=tokenunformatted[1];password=tokenunformatted[0];tokens.append(f"{token}:{password}")
elif tokenformat=='3':
for i in tokenfile:tokenunformatted=i.split(':');token=tokenunformatted[2];password=tokenunformatted[1];tokens.append(f"{token}:{password}")
elif tokenformat=='4':
for i in tokenfile:tokenunformatted=i.split(':');token=tokenunformatted[0];password=tokenunformatted[2];tokens.append(f"{token}:{password}")
elif tokenformat=='5':
for i in tokenfile:tokenunformatted=i.split(':');token=tokenunformatted[2];password=tokenunformatted[0];tokens.append(f"{token}:{password}")
elif tokenformat=='6':
for i in tokenfile:tokenunformatted=i.split(':');tokens=tokenunformatted[0];password=tokenunformatted[1];tokens.append(f"{token}:{password}")
if namepfp == "1":
Thread(target=changerPrint, args=(tokens, namepfp,)).start()
for toucan in tokens:
token = toucan.split(":")
headers={'Authorization': token[0],'accept': '*/*','accept-language': 'en-US','connection': 'keep-alive','cookie': f'__cfduid = {rc(43)}; __dcfduid={rc(32)}; __sdcfduid={rc(96)}; locale=en-US','DNT': '1','origin': 'https://discord.com','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','referer': 'https://discord.com/channels/@me','TE': 'Trailers','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36','X-Super-Properties': 'eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiQ2hyb21lIiwiZGV2aWNlIjoiIiwic3lzdGVtX2xvY2FsZSI6ImVuLVVTIiwiYnJvd3Nlcl91c2VyX2FnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzk2LjAuNDY2NC40NSBTYWZhcmkvNTM3LjM2IiwiYnJvd3Nlcl92ZXJzaW9uIjoiOTYuMC40NjY0LjQ1Iiwib3NfdmVyc2lvbiI6IjEwIiwicmVmZXJyZXIiOiIiLCJyZWZlcnJpbmdfZG9tYWluIjoiIiwicmVmZXJyZXJfY3VycmVudCI6Imh0dHBzOi8vZGlzY29yZC5jb20vIiwicmVmZXJyaW5nX2RvbWFpbl9jdXJyZW50IjoiZGlzY29yZC5jb20iLCJyZWxlYXNlX2NoYW5uZWwiOiJzdGFibGUiLCJjbGllbnRfYnVpbGRfbnVtYmVyIjoxMDg5MjQsImNsaWVudF9ldmVudF9zb3VyY2UiOm51bGx9',}
with open(pfps + random.choice(listdir(pfps)), "rb") as f:
img = f.read()
try:
if proxyless == "1":
proxy = f"http://{next(ProxyPool)}"
else:
proxy = None
httpx.patch('https://discord.com/api/v9/users/@me', proxies=proxy, headers=headers, json={"username":next(usernames),"avatar":f'data:image/png;base64,{b64encode(img).decode("ascii")}', "password":token[1]})
except Exception as err:
print(err)
changed+=1
changerDone = 1
input(f"Succesfully changed the Avatars and Usernames of {len(tokens)} tokens!\nPress enter to rerun the program...")
elif namepfp == "2":
Thread(target=changerPrint, args=(tokens, namepfp,))
for toucan in tokens:
token = toucan.split(":")
headers={'Authorization': token[0],'accept': '*/*','accept-language': 'en-US','connection': 'keep-alive','cookie': f'__cfduid = {rc(43)}; __dcfduid={rc(32)}; __sdcfduid={rc(96)}; locale=en-US','DNT': '1','origin': 'https://discord.com','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','referer': 'https://discord.com/channels/@me','TE': 'Trailers','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36','X-Super-Properties': 'eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiQ2hyb21lIiwiZGV2aWNlIjoiIiwic3lzdGVtX2xvY2FsZSI6ImVuLVVTIiwiYnJvd3Nlcl91c2VyX2FnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzk2LjAuNDY2NC40NSBTYWZhcmkvNTM3LjM2IiwiYnJvd3Nlcl92ZXJzaW9uIjoiOTYuMC40NjY0LjQ1Iiwib3NfdmVyc2lvbiI6IjEwIiwicmVmZXJyZXIiOiIiLCJyZWZlcnJpbmdfZG9tYWluIjoiIiwicmVmZXJyZXJfY3VycmVudCI6Imh0dHBzOi8vZGlzY29yZC5jb20vIiwicmVmZXJyaW5nX2RvbWFpbl9jdXJyZW50IjoiZGlzY29yZC5jb20iLCJyZWxlYXNlX2NoYW5uZWwiOiJzdGFibGUiLCJjbGllbnRfYnVpbGRfbnVtYmVyIjoxMDg5MjQsImNsaWVudF9ldmVudF9zb3VyY2UiOm51bGx9',}
with open(pfps + random.choice(listdir(pfps)), "rb") as f:
img = f.read()
try:
if proxyless == "1":
proxy = f"http://{next(ProxyPool)}"
else:
proxy = None
httpx.patch('https://discord.com/api/v9/users/@me', proxies=proxy, headers=headers, json={"avatar":f'data:image/png;base64,{b64encode(img).decode("ascii")}'})
except Exception as err:
print(err)
changed+=1
changerDone = 1
input(f"Succesfully changed the Avatars of {len(tokens)} tokens!\nPress enter to rerun the program...")
elif namepfp == "3":
Thread(target=changerPrint, args=(tokens, namepfp,))
for toucan in tokens:
token = toucan.split(":")
headers={'Authorization': token[0],'accept': '*/*','accept-language': 'en-US','connection': 'keep-alive','cookie': f'__cfduid = {rc(43)}; __dcfduid={rc(32)}; __sdcfduid={rc(96)}; locale=en-US','DNT': '1','origin': 'https://discord.com','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','referer': 'https://discord.com/channels/@me','TE': 'Trailers','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36','X-Super-Properties': 'eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiQ2hyb21lIiwiZGV2aWNlIjoiIiwic3lzdGVtX2xvY2FsZSI6ImVuLVVTIiwiYnJvd3Nlcl91c2VyX2FnZW50IjoiTW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzk2LjAuNDY2NC40NSBTYWZhcmkvNTM3LjM2IiwiYnJvd3Nlcl92ZXJzaW9uIjoiOTYuMC40NjY0LjQ1Iiwib3NfdmVyc2lvbiI6IjEwIiwicmVmZXJyZXIiOiIiLCJyZWZlcnJpbmdfZG9tYWluIjoiIiwicmVmZXJyZXJfY3VycmVudCI6Imh0dHBzOi8vZGlzY29yZC5jb20vIiwicmVmZXJyaW5nX2RvbWFpbl9jdXJyZW50IjoiZGlzY29yZC5jb20iLCJyZWxlYXNlX2NoYW5uZWwiOiJzdGFibGUiLCJjbGllbnRfYnVpbGRfbnVtYmVyIjoxMDg5MjQsImNsaWVudF9ldmVudF9zb3VyY2UiOm51bGx9',}
try:
if proxyless == "1":
proxy = f"http://{next(ProxyPool)}"
else:
proxy = None
httpx.patch('https://discord.com/api/v9/users/@me', proxies=proxy, headers=headers, json={"usernames":next(usernames), "password":token[1]})
except Exception as err:
print(err)
changed+=1
changerDone = 1
input(f"Succesfully changed the Usernames of {len(tokens)} tokens!\nPress enter to rerun the program...")
def scraperPrint(guild_id):
global pfpScraped
global usernameScraped
global scrapedDone
os.system('cls' if os.name == 'nt' else 'clear')
guild_name = httpx.get(f'https://discord.com/api/v9/guilds/{guild_id}', headers={'Authorization':token}).json().get('name')
print(f"Scraping {guild_name}!\n")
print('\n\n')
while scrapedDone == 0:
print(f"{UP}Usernames Scraped: {usernameScraped}{CLR}\nAvatars Scraped: {pfpScraped}{CLR}\n")
time.sleep(0.2)
def changerPrint(tokens, mode):
global changed
global changerDone
print(f"Changing {len(tokens)} tokens!\n\n")
while changerDone == 0:
if mode == "1":
print(f'{UP}Usernames & Avatars changed: {changed}{CLR}')
elif mode == "2":
print(f'{UP}Avatars changed: {changed}{CLR}')
elif mode == "3":
print(f'{UP}Usernames changed: {changed}{CLR}')
time.sleep(0.2)
try:
while True:
os.system('cls' if os.name == 'nt' else 'clear')
choice = input("Do you want to scrape Avatars & Userames or change Avatars & Usernames in tokens.txt?\n[1] Scrape\n[2] Changer\nChoice: ")
if choice == "1":
os.system('cls' if os.name == 'nt' else 'clear')
print("Username and Avatar scraper")
serverID = input("Server ID: ")
channelID = input("Channel ID: ")
x = Thread(target=scrape, args=(serverID, channelID,))
x.start()
x.join()
time.sleep(1)
os.system('cls' if os.name == 'nt' else 'clear')
elif choice == "2":
os.system('cls' if os.name == 'nt' else 'clear')
print("Username and Avatar changer")
namepfp = input("\n[1] Change Avatars and Usernames\n[2] Change Avatars\n[3] Change Usernames\nChoice: ")
os.system('cls' if os.name == 'nt' else 'clear')
tokenformat = input("\nToken format?\n[1] token:password\n[2] password:token\n[3] email:password:token\n[4] token:email:password\n[5] password:email:token\n[6] token:password:email\nChoice: ")
os.system('cls' if os.name == 'nt' else 'clear')
proxyless = input("Use proxies?\n\n[1] Proxyless\n[2] Proxied")
x = Thread(target=changer, args=(namepfp, tokenformat, proxyless,))
x.start()
x.join()
time.sleep(1)
os.system('cls' if os.name == 'nt' else 'clear')
else:
os.system('cls' if os.name == 'nt' else 'clear')
print("Please only input either '1' or '2'.\n")
except Exception as error:
print(f"Error: {error}")