Discord Account Creator written in python
import json
import threading

import time

from utils.ui import Log
from utils.utils import Utils
import tls_client

import os
import onest_captcha

if not os.path.exists("info"):
    os.mkdir("info")

config = json.load(open("info/config.json", encoding="utf-8"))


threadcount = int(config['threads'])

genned = 0
errors = 0
solved = 0
StartTime = time.time()



class Console():
    global genned
    global errors
    global solved

    def __init__(self):
        self.title = f"Genned : {genned} | Errors: {errors} | Solved: {solved} | Elapsed: {round(time.time() - StartTime, 2)}s"


build_number = int(Utils.BuildNumber())
if build_number == "":
    Log.Error("Failed to parse build number, please try again later.")
    exit()
else:
    Utils.clear()
    Log.Info(f"Build number: {build_number}")

Console()


def main():
    date = Utils.GetBirthday()
    ua = Utils.PickUserAgent()
    # implement proxies. Proxy not working
    # proxy = Utils.RandomProxy()
    # formattedProxy = f"http://{proxy}"
    global genned, solved, \
        errors
    client = tls_client.Session(client_identifier='chrome_108')
    resp = client.get("https://discord.com/api/v9/experiments")
    fingerprint = resp.json()['fingerprint']
    time_solve = time.time()
    solv = onest_captcha.OneStCaptchaClient(config["captchakey"])
    capresp = solv.h_captcha_task_proxyless('https://discord.com/', site_key='4c672d35-0701-42b2-88c3-78380b0db560')
    key = capresp.get("token")
    time_solve = time.time() - time_solve
    Log.Info(f"Solved key in {round(time_solve, 2)}s")
    solved += 1
    Console()

    data = {
        'fingerprint': fingerprint,
        'email': str(Utils.RandomEmail()),
        'username': str(Utils.username()),
        'password': str(Utils.Password()),
        'consent': True,
        'date_of_birth': date,
        "gift_code_sku_id": None,
        "captcha_key": key,
        "promotional_email_opt_in": True
    }

    headers = {
        'origin': 'https://discord.com',
        'referer': f'https://discord.gg/',
        'x-discord-locale': 'en-US',
        'x-debug-options': 'bugReporterEnabled',
        'user-agent': ua,
        'x-fingerprint': fingerprint,
        'x-super-properties': Utils.GetProperties(build_number),
        'Content-Type': 'application/json'
    }

    response = client.post('https://discord.com/api/v9/auth/register', json=data, headers=headers)
    if response.status_code == 201:
        token = response.json()['token']
        Log.Success(f"Generated {token[:40]}.......")
        genned += 1
        Console()
        with open(f"tokens.txt", "a", encoding="utf-8") as f:
            f.write(f"{token}\n")

    elif response.status_code == 429:
        Log.Error("Rate Limited.")
        errors += 1
        Console()

    elif 'captcha' in response.text:
        Log.Error("Captcha Data Invalid")
        errors += 1
        Console()

    else:
        Log.Error("Unknown Error")
        errors += 1
        Console()

if __name__ == '__main__':
    main()


"""
this is to be replaced with the main call above. 
this will make you lots more accounts per second but you need to implement 
proxies to not be ratelimited.

class Main():
    pass


def loop():
    global errors
    while True:
        try:
           Console()
            main()
        except Exception as e:
            print(f"Error: {e}")
            errors += 1
            Console()


for i in range(threadcount):
    threading.Thread(target=loop).start()
"""

main.py
Theflashiscool2/FlashGen
from datetime import datetime
from colorama import Fore
import threading

lock = threading.Lock()


class Log:
    def Success(text):
        now = datetime.now()
        current_time = now.strftime("%H:%M:%S")
        lock.acquire()
        print(
            Fore.LIGHTGREEN_EX + "[" + Fore.LIGHTBLACK_EX + current_time + Fore.LIGHTGREEN_EX + "] [\] " + Fore.WHITE + text + Fore.RESET)
        lock.release()

    def Info(text):
        now = datetime.now()
        current_time = now.strftime("%H:%M:%S")
        lock.acquire()
        print(
            Fore.LIGHTYELLOW_EX + "[" + Fore.LIGHTBLACK_EX + current_time + Fore.LIGHTYELLOW_EX + "] [!] " + Fore.WHITE + text + Fore.RESET)
        lock.release()

    def Error(text):
        now = datetime.now()
        current_time = now.strftime("%H:%M:%S")
        lock.acquire()
        print(Fore.RED + "[" + Fore.LIGHTBLACK_EX + current_time + Fore.LIGHTRED_EX + "] [-] " + Fore.WHITE + text + Fore.RESET)
        lock.release()

utils/ui.py
Theflashiscool2/FlashGen
import random
import re
import string
from json import dumps, loads
from base64 import b64encode
import os

import httpx
import requests

from utils.ui import Log

config = loads(open("info/config.json", "r").read())


class Utils(object):
    @staticmethod
    def GetBirthday():
        year = str(random.randrange(1997, 2001))
        month = str(random.randrange(1, 12))
        day = str(random.randrange(1, 28))
        if len(month) == 1:
            month = '0' + month
        if len(day) == 1:
            day = '0' + day

        return f"{year}-{month}-{day}"

    @staticmethod
    def RandomEmail():
        return ''.join(random.choice(string.ascii_letters) for i in range(10)) + '@gmail.com'

    @staticmethod
    def Password():
        if config["password"] == "random":
            return ''.join(random.choice(string.ascii_letters + string.digits + string.punctuation) for i in range(10))
        else:
            return config["password"]
    @staticmethod
    def PickUserAgent():
        return open("info/useragents.txt", encoding="utf-8").read().splitlines()[
            random.randint(0, len(open("info/useragents.txt", encoding="utf-8").read().splitlines()) - 1)]
    @staticmethod
    def username():
        return open("info/usernames.txt", encoding="utf-8").read().splitlines()[
            random.randint(0, len(open("info/usernames.txt", encoding="utf-8").read().splitlines()) - 1)] + \
            open("info/usernames.txt", encoding="utf-8").read().splitlines()[
                random.randint(0, len(open("info/usernames.txt", encoding="utf-8").read().splitlines()) - 1)] + \
            open("info/usernames.txt", encoding="utf-8").read().splitlines()[
                random.randint(0, len(open("info/usernames.txt", encoding="utf-8").read().splitlines()) - 1)]

    @staticmethod
    def GetProperties(buildNum: int):
        return b64encode(dumps({"os": "Windows", "browser": "Chrome", "device": "", "system_locale": "pl-PL",
                                "browser_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
                                "browser_version": "108.0.0.0", "os_version": "10", "referrer": "",
                                "referring_domain": "", "referrer_current": "", "referring_domain_current": "",
                                "release_channel": "stable", "client_build_number": buildNum,
                                "client_event_source": None, "design_id": 0}).encode()).decode()

    @staticmethod
    def clear():
        os.system('cls' if os.name == 'nt' else 'clear')

    @staticmethod
    def RandomProxy():
        proxysources = [
            ["http://spys.me/proxy.txt", "%ip%:%port% "],
            ["http://www.httptunnel.ge/ProxyListForFree.aspx", " target=\"_new\">%ip%:%port%</a>"],
            ["https://raw.githubusercontent.com/sunny9577/proxy-scraper/master/proxies.json",
             "\"ip\":\"%ip%\",\"port\":\"%port%\","],
            ["https://raw.githubusercontent.com/fate0/proxylist/master/proxy.list",
             '"host": "%ip%".*?"country": "(.*?){2}",.*?"port": %port%'],
            ["https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list.txt",
             '%ip%:%port% (.*?){2}-.-S \\+'],
            ["https://raw.githubusercontent.com/opsxcq/proxy-list/master/list.txt",
             '%ip%", "type": "http", "port": %port%'],
            ["https://www.us-proxy.org/",
             "<tr><td>%ip%<\\/td><td>%port%<\\/td><td>(.*?){2}<\\/td><td class='hm'>.*?<\\/td><td>.*?<\\/td><td class='hm'>.*?<\\/td><td class='hx'>(.*?)<\\/td><td class='hm'>.*?<\\/td><\\/tr>"],
            ["https://free-proxy-list.net/",
             "<tr><td>%ip%<\\/td><td>%port%<\\/td><td>(.*?){2}<\\/td><td class='hm'>.*?<\\/td><td>.*?<\\/td><td class='hm'>.*?<\\/td><td class='hx'>(.*?)<\\/td><td class='hm'>.*?<\\/td><\\/tr>"],
            ["https://www.sslproxies.org/",
             "<tr><td>%ip%<\\/td><td>%port%<\\/td><td>(.*?){2}<\\/td><td class='hm'>.*?<\\/td><td>.*?<\\/td><td class='hm'>.*?<\\/td><td class='hx'>(.*?)<\\/td><td class='hm'>.*?<\\/td><\\/tr>"],
            ["https://www.proxy-list.download/api/v0/get?l=en&t=https", '"IP": "%ip%", "PORT": "%port%",'],
            [
                "https://api.proxyscrape.com/?request=getproxies&proxytype=http&timeout=6000&country=all&ssl=yes&anonymity=all",
                "%ip%:%port%"],
            ["https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/http.txt", "%ip%:%port%"],
            ["https://raw.githubusercontent.com/shiftytr/proxy-list/master/proxy.txt", "%ip%:%port%"],
            ["https://proxylist.icu/", "<td>%ip%:%port%</td><td>http<"],
            ["https://proxylist.icu/proxy/1", "<td>%ip%:%port%</td><td>http<"],
            ["https://proxylist.icu/proxy/2", "<td>%ip%:%port%</td><td>http<"],
            ["https://proxylist.icu/proxy/3", "<td>%ip%:%port%</td><td>http<"],
            ["https://proxylist.icu/proxy/4", "<td>%ip%:%port%</td><td>http<"],
            ["https://proxylist.icu/proxy/5", "<td>%ip%:%port%</td><td>http<"],
            ["https://www.hide-my-ip.com/proxylist.shtml", '"i":"%ip%","p":"%port%",'],
            ["https://raw.githubusercontent.com/scidam/proxy-list/master/proxy.json",
             '"ip": "%ip%",\n.*?"port": "%port%",']
        ]
        random.shuffle(proxysources)

        for proxy in proxysources:
            url = proxy[0]
            custom_regex = proxy[1]
            proxylist = requests.get(url, timeout=5).text
            proxylist = proxylist.replace('null', '"N/A"')
            custom_regex = custom_regex.replace('%ip%', '([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})')
            custom_regex = custom_regex.replace('%port%', '([0-9]{1,5})')

            matching_proxies = re.findall(re.compile(custom_regex), proxylist)

            random.shuffle(matching_proxies)

            for proxy in matching_proxies:
                return proxy[0] + ":" + proxy[1]
    @staticmethod
    def get_js() -> str:
        try:
            resp = httpx.get("https://discord.com/app")
            resp.raise_for_status()
        except httpx.HTTPError as e:
            Log.Error(f"HTTP error occurred while fetching latest JS version: {e}")
            return ""

        try:
            js_version = resp.text.split('"></script><script src="/assets/')[2].split('" integrity')[0]
            return js_version
        except IndexError:
            Log.Error("Failed to parse JS version from response.")
            return ""
    @staticmethod
    def BuildNumber():
        js_version = Utils.get_js()
        url = f"https://discord.com/assets/{js_version}"

        resp = requests.get(url)
        body = resp.content.decode()

        regex_pattern = r'"buildNumber",null!==\(t="(\d+)"\)\?t:""\)'

        regex = re.compile(regex_pattern)
        match = regex.search(body)

        if match:
            build_number = match.group(1)
            return build_number
        else:
            Log.Error("Build number not found in the body text.")
            return ""

utils/utils.py
Theflashiscool2/FlashGen