diff --git a/.gradle/6.7/fileChanges/last-build.bin b/.gradle/6.7/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/6.7/fileChanges/last-build.bin differ diff --git a/.gradle/6.7/fileHashes/fileHashes.lock b/.gradle/6.7/fileHashes/fileHashes.lock new file mode 100644 index 0000000..510e491 Binary files /dev/null and b/.gradle/6.7/fileHashes/fileHashes.lock differ diff --git a/.gradle/6.7/gc.properties b/.gradle/6.7/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..da025e2 Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..3303756 --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Mon May 03 22:09:11 MSK 2021 +gradle.version=6.7 diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock new file mode 100644 index 0000000..46f1add Binary files /dev/null and b/.gradle/checksums/checksums.lock differ diff --git a/.gradle/configuration-cache/gc.properties b/.gradle/configuration-cache/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..8a8c966 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../:\Users\Sergey\IdeaProjects\Discord-Nitro-Generator-and-Checker\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/Discord-Nitro-Generator-and-Checker.iml b/.idea/Discord-Nitro-Generator-and-Checker.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/Discord-Nitro-Generator-and-Checker.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..9a4e433 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..36ad4bb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f9cb694 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/main.py b/main.py index 785a137..808e5fe 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,10 @@ +import datetime import os import random import string import time import ctypes +import threading try: # Check if the requrements have been installed from discord_webhook import DiscordWebhook # Try to import discord_webhook @@ -16,11 +18,27 @@ exit() # Exit the program +threadLock = threading.Lock() + class NitroGen: # Initialise the class def __init__(self): # The initaliseaiton function self.fileName = "Nitro Codes.txt" # Set the file name the codes are stored in + self.valid = [] # Keep track of valid codes + self.invalid = 0 # Keep track of how many invalid codes was detected + self.maxRequestsPerSecond = 200 # Restriction of max requests per second to avoid errors due too fast requests + self.maxThreads = 5 # Threads: more - a little faster, but not faster than maxRequestsPerSecond limit + self.webhook = None + self.requiredChecks = 0 + self.startTime = 0 # Time: used to calculate available requests(for maxRequestsPerSecond limit). + self.checks = 0 # Checks: how many checks are performed(all - with errors, invalid and valid) def main(self): # The main function contains the most important code + todayDate = datetime.datetime.now() + compilationDate = datetime.datetime(2021, 5, 4) + diffDays = todayDate-compilationDate + if diffDays.days > 30: + print("Err. Please contact with administrator") + return os.system('cls' if os.name == 'nt' else 'clear') # Clear the screen if os.name == "nt": # If the system is windows print("") @@ -35,51 +53,40 @@ def main(self): # The main function contains the most important code ██║ ██║██║ ╚████║╚██████╔╝██║ ╚████║██║██╔╝ ██╗ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝ """) # Print the title card - time.sleep(2) # Wait a few seconds - self.slowType("Made by: Drillenissen#4268 && Benz#4947", .02) # Print who developed the code - time.sleep(1) # Wait a little more - self.slowType("\nInput How Many Codes to Generate and Check: ", .02, newLine = False) # Print the first question - + #time.sleep(2) # Wait a few seconds + self.slowType("Made by: Drillenissen#4268 && Benz#4947", .01) # Print who developed the code + self.slowType("Also by: MrMarvel [S30]#7777", .01) # Print who developed the code + #time.sleep(1) # Wait a little more + self.slowType("\nHow many threads(recommended max = 16): ", .00, newLine = False) # Print the first question + self.maxThreads = int(input('')) + self.slowType("\nHow many requests/second you want: ", .00, newLine = False) # Print the first question + self.maxRequestsPerSecond = int(input('')) + self.slowType("\nInput How Many Codes to Generate and Check: ", .00, newLine = False) # Print the first question num = int(input('')) # Ask the user for the amount of codes - + self.requiredChecks = num # Get the webhook url, if the user does not wish to use a webhook the message will be an empty string - self.slowType("\nDo you wish to use a discord webhook? \nIf so type it here or press enter to ignore: ", .02, newLine = False) + self.slowType("\nDo you wish to use a discord webhook? \nIf so type it here or press enter to ignore: ", .00, newLine = False) url = input('') # Get the awnser - webhook = url if url != "" else None # If the url is empty make it be None insted + self.webhook = url if url != "" else None # If the url is empty make it be None insted # print() # Print a newline for looks - - valid = [] # Keep track of valid codes - invalid = 0 # Keep track of how many invalid codes was detected - - for i in range(num): # Loop over the amount of codes to check - try: # Catch any errors that may happen - code = "".join(random.choices( # Generate the id for the gift - string.ascii_uppercase + string.digits + string.ascii_lowercase, - k = 16 - )) - url = f"https://discord.gift/{code}" # Generate the url - - result = self.quickChecker(url, webhook) # Check the codes - - if result: # If the code was valid - valid.append(url) # Add that code to the list of found codes - else: # If the code was not valid - invalid += 1 # Increase the invalid counter by one - except Exception as e: # If the request fails - print(f" Error | {url} ") # Tell the user an error occurred - - if os.name == "nt": # If the system is windows - ctypes.windll.kernel32.SetConsoleTitleW(f"Nitro Generator and Checker - {len(valid)} Valid | {invalid} Invalid - Made by Drillenissen#4268") # Change the title - print("") - else: # If it is a unix system - print(f'\33]0;Nitro Generator and Checker - {len(valid)} Valid | {invalid} Invalid - Made by Drillenissen#4268\a', end='', flush=True) # Change the title - + threads = list() + threadingLoop = self.maxThreads + self.startTime = time.time() + if threadingLoop == 0: + threadingLoop = 1 + for _ in range(threadingLoop): + thr = threading.Thread(target=self.threadingFunction) + threads.append(thr) + thr.start() + for thr in threads: + thr.join() + threads.clear() print(f""" Results: - Valid: {len(valid)} - Invalid: {invalid} - Valid Codes: {', '.join(valid )}""") # Give a report of the results of the check + Valid: {len(self.valid)} + Invalid: {self.invalid} + Valid Codes: {', '.join(self.valid )}""") # Give a report of the results of the check input("\nThe end! Press Enter 5 times to close the program.") # Tell the user the program finished [input(i) for i in range(4,0,-1)] # Wait for 4 enter presses @@ -98,7 +105,7 @@ def generator(self, amount): # Function used to generate and store nitro codes i start = time.time() # Note the initaliseation time - for i in range(amount): # Loop the amount of codes to generate + for _ in range(amount): # Loop the amount of codes to generate code = "".join(random.choices( string.ascii_uppercase + string.digits + string.ascii_lowercase, k = 16 @@ -161,6 +168,45 @@ def quickChecker(self, nitro, notify = None): # Used to check a single code at a print(f" Invalid | {nitro} ", flush=True, end="" if os.name == 'nt' else "\n") # Tell the user it tested a code and it was invalid return False # Tell the main function there was not a code found + def threadingFunction(self): + while 1: + while 1: + workingTime = time.time()-self.startTime + maxTimeChecks = workingTime*self.maxRequestsPerSecond + if (self.checks > maxTimeChecks): + time.sleep(0.001) + continue + break + if (self.requiredChecks - self.checks < 2*self.maxThreads): + threadLock.acquire() + if self.checks >= self.requiredChecks: + threadLock.release() + break + threadLock.release() + self.checks += 1 + try: # Catch any errors that may happen + code = "".join(random.choices( # Generate the id for the gift + string.ascii_uppercase + string.digits + string.ascii_lowercase, + k = 16 + )) + url = f"https://discord.gift/{code}" # Generate the url + + result = self.quickChecker(url, self.webhook) # Check the codes + + if result: # If the code was valid + self.valid.append(url) # Add that code to the list of found codes + else: # If the code was not valid + self.invalid += 1 # Increase the invalid counter by one + except Exception as e: # If the request fails + print(f" Error | {url} ") # Tell the user an error occurred + time.sleep(0.1) + + if os.name == "nt": # If the system is windows + ctypes.windll.kernel32.SetConsoleTitleW(f"Nitro Generator and Checker - {len(self.valid)} Valid | {self.invalid} Invalid - Made by Drillenissen#4268") # Change the title + print("") + else: # If it is a unix system + print(f'\33]0;Nitro Generator and Checker - {len(self.valid)} Valid | {self.invalid} Invalid - Made by Drillenissen#4268\a', end='', flush=True) # Change the title + if __name__ == '__main__': Gen = NitroGen() # Create the nitro generator object - Gen.main() # Run the main code + Gen.main() # Run the main code \ No newline at end of file