diff --git a/README.md b/README.md index fcab784..7c3b27f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@
- A discord nitro generator and checker for all your nitro needs
+ A Discord Nitro generator and checker for all your nitro needs
Explore the docs »
@@ -22,10 +22,10 @@
·
Request Feature
·
- Join the discord
+ Join the Discord
-It generates and checks discord nitro codes at the same time for maximum efficiency
+Generates and check Nitro codes at the same time for maximum efficiency
### Built With
* [Requests](https://github.com/psf/requests)
* [Discord webhook](https://github.com/lovvskillz/python-discord-webhook)
-* [Colored](https://gitlab.com/dslackw/colored)
+* [Colorama](https://github.com/tartley/colorama)
## Getting Started
To get a local copy up and running follow these simple steps.
### Prerequisites
-You need to install Python, that can be done [here](https://www.python.org)
+You need to install Python (3.6 or higher), that can be done [here](https://www.python.org/downloads/)
### Installation
1. Clone the repo
```sh
- git clone https://github.com/logicguy1/The-all-in-one-discord-tool.git
+ git clone https://github.com/Music-Dude/Discord-Nitro-Generator-and-Checker.git
```
2. Install Python packages
+ ##### The program will give you an option to install them, but you can install them manually too.
```sh
# Windows:
- py -3 -m pip install -r requirements.txt
+ py -3 -m pip install requests discord_webhook colorama
# Unix
- python3.8 -m pip install -r requirements.txt
+ python3 -m pip install requests
+ python3 -m pip install discord_webhook
+ python3 -m pip install colorama
```
-
-#### Or this can be done using android with unrooted Termux
-```
-git clone https://github.com/logicguy1/Discord-Nitro-Generator-and-Checker
-pkg install python
-pip install -r requirements.txt
-cd Discord-Nitro-Generator-and-Checker
-python3 main.py
-```
-
+
+ #### Or this can be done on Android with unrooted Termux
+ ```
+ git clone https://github.com/logicguy1/Discord-Nitro-Generator-and-Checker
+ pkg install python
+ python3 -m pip install requests discord_webhook colorama
+ cd Discord-Nitro-Generator-and-Checker
+ python3 main.py
+ ```
+
## Usage
-Run the `main.py` file using `py -3 main.py`
-The code will show you two prompts:
-1. How many codes to generate
-2. If you want to use a discord webhook, if you dont know how to get a discord webhook url it is located at
+Run the file [`main.py`](/main.py) using `py -3 main.py`, or `python3 main.py` on Unix.
+The code will show you three prompts:
+1. How many codes to generate, input 0 to generate without a limit.
+2. If you want to use a Discord webhook to report valid codes. You can find a webhook URL at
```channel settings » intergrations » webhooks » create webhook```
- If you dont want to use a webhook simply leave this blank
+3. How many threads to run. More threads will increase efficiency in generation, but also use more CPU.
-The code will start generating and checking after that step
+\
+After this, the program will begin generating and checking Nitro codes.
-_For more examples, please refer to the [Documentation](https://example.com)_
+For more examples, please refer to the [Documentation](https://example.com)
## Roadmap
@@ -114,9 +118,9 @@ See the [open issues](https://github.com/logicguy1/Discord-Nitro-Generator-and-C
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
1. Fork the Project
-2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
-3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
-4. Push to the Branch (`git push origin feature/AmazingFeature`)
+2. Create your Feature Branch `git checkout -b feature/AmazingFeature`
+3. Commit your Changes `git commit -m 'Add some AmazingFeature'`
+4. Push to the Branch `git push origin feature/AmazingFeature`
5. Open a Pull Request
## Copyright
@@ -126,7 +130,7 @@ Contributions are what make the open source community such an amazing place to l
Logicguy - [@Drillenissen#4268](https://www.discordapp.com) - logicguy.mailandcontact@gmail.com
-Project Link: [https://github.com/logicguy1/The-all-in-one-discord-tool](https://github.com/logicguy1/The-all-in-one-discord-tool)
+Project Link: https://github.com/logicguy1/The-all-in-one-discord-tool
diff --git a/assets/example.png b/assets/example.png
index d5c8c2a..6cb3d1f 100644
Binary files a/assets/example.png and b/assets/example.png differ
diff --git a/main.py b/main.py
index 785a137..4ccd7e6 100644
--- a/main.py
+++ b/main.py
@@ -1,166 +1,213 @@
+# https://github.com/logicguy1/Discord-Nitro-Generator-and-Checker/
+# I cleaned up a lot, including adding color, multithreading (thanks https://git.io/JsDmT), and auto module install
+
import os
import random
import string
import time
import ctypes
+import threading
+from sys import executable
+
+
+try: # Try to import modules
+ import requests
+ from discord_webhook import DiscordWebhook
+ from colorama import Fore, Style
+except ImportError: # Ask user to install if there was an error
+ install = input(
+ 'It looks like you don\'t have all dependencies installed, would you like to install them? [Y/N] ')
+
+ installCommand = f'''{executable} -m pip install requests discord_webhook colorama'''
+
+ if 'y' in install.lower():
+ os.system(installCommand)
+
+ from discord_webhook import DiscordWebhook # Import modules again
+ import requests
+ from colorama import Fore, Style
+ else:
+ print(f'Okay, you can install the modules with {installCommand}')
+ exit()
+
+
+class NitroGen:
+ def __init__(self):
+ self.valid = set() # Sets don't allow repetition, gives better performance
+ self.numCodes = None
+ self.maxThreads = None
+ self.webhookUrl = None
+ self.startTime = None
+ self.totalCodes = 0
+ self.threadingLock = threading.Lock()
+
+ def intro(self):
+ # Clear the screen
+ os.system('cls' if os.name == 'nt' else 'clear')
+
+ self.setWindowTitle(
+ 'Nitro Generator and Checker - Made by Drillenissen#4268')
+
+ print(f'''{Style.DIM}\n
+ █████╗ ███╗ ██╗ ██████╗ ███╗ ██╗██╗██╗ ██╗
+ ██╔══██╗████╗ ██║██╔═══██╗████╗ ██║██║╚██╗██╔╝
+ ███████║██╔██╗ ██║██║ ██║██╔██╗ ██║██║ ╚███╔╝
+ ██╔══██║██║╚██╗██║██║ ██║██║╚██╗██║██║ ██╔██╗
+ ██║ ██║██║ ╚████║╚██████╔╝██║ ╚████║██║██╔╝ ██╗
+ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝
+ {Style.RESET_ALL}''')
+
+ self.slowType(
+ f'{Fore.LIGHTBLUE_EX} Made by: Drillenissen#4268, Benz#4947, & Music_Dude#6374\n', .02)
+
+ time.sleep(1)
+
+ def config(self):
+ self.slowType(
+ f'{Style.RESET_ALL} Input how many codes to generate and check (0 for infinity): {Fore.RED}', .02, newLine=False)
+ while True:
+ try:
+ self.numCodes = int(input(''))
+ break
+ except:
+ print(
+ f'{Style.RESET_ALL} Invalid number. Enter how many codes to generate and check: {Fore.RED}', end='')
+ continue
+ if self.numCodes == 0:
+ # Generate infinite codes if the user inputs 0
+ self.numCodes = float('Inf')
+
+ self.slowType(
+ f'{Style.RESET_ALL}\n Do you wish to use a discord webhook? [Y/N] {Fore.RED}', .02, newLine=False)
+ useWebhook = input('')
+ if 'y' in useWebhook.lower():
+ self.slowType(
+ f'{Style.RESET_ALL}\n Okay, enter the url here: {Fore.RED}', .02, newLine=False)
+ self.webhookUrl = input('')
+ try:
+ r = requests.get(self.webhookUrl)
+ if r.status_code != 200:
+ raise ValueError
+ except:
+ print(
+ f'{Style.RESET_ALL} Invalid webhook url provided, ignoring!\n')
+
+ self.slowType(
+ f'{Style.RESET_ALL}\n What is the maximum number of threads you\'d like to run: {Fore.RED}', .02, newLine=False)
+
+ while True:
+ try:
+ self.maxThreads = int(input(''))
+ if self.maxThreads > self.numCodes:
+ print(
+ f'{Style.RESET_ALL} Max number of threads must be less than the max number of codes to generate.\n Enter another number: {Fore.RED}', end='')
+ continue
+ break
+ except:
+ print(
+ f'{Style.RESET_ALL} Invalid number. Enter the maximum number of threads you\'d like to run: {Fore.RED}', end='')
+ continue
+
+ print(
+ f'\n\n{Fore.LIGHTBLACK_EX} ------------------------------------------------\n{Style.RESET_ALL}')
+
+ def main(self):
+ self.startTime = time.time()
+ with self.threadingLock: # Threading lock prevents threads from generating too many/too few codes
+ while self.totalCodes < self.numCodes:
+ try:
+ # Generate code URL
+ code = ''.join(random.choices(
+ string.ascii_uppercase + string.digits + string.ascii_lowercase,
+ k=16
+ ))
+ url = f'https://discord.gift/{code}'
+
+ isValid = self.checkCode(url, self.webhookUrl)
+
+ if isValid:
+ self.valid.add(url)
+ self.setWindowTitle(
+ f'Nitro Generator and Checker - Valid | {len(self.valid)} - Made by Drillenissen#4268')
+
+ # Catch any errors during execution
+ except Exception as e:
+ print(
+ f'{Fore.RED} Error {Fore.LIGHTWHITE_EX}|{Style.RESET_ALL} {url} ')
+
+ self.totalCodes += 1
+
+ def results(self):
+ results = f' Generated {self.totalCodes} codes in {time.time() - self.startTime:0.2F} seconds\n Valid: {len(self.valid)}\n'
+
+ if len(self.valid) > 0:
+ # Show valid codes only if there are any
+ results += f' Valid Codes: {", ".join(self.valid )}\n'
+
+ print(
+ f'\n{Fore.LIGHTBLACK_EX} ------------------------------------------------\n\n{Fore.CYAN}{results}{Style.RESET_ALL}')
+
+ def checkCode(self, code, notify=None):
+ url = f'https://discordapp.com/api/v6/entitlements/gift-codes/{code}?with_application=false&with_subscription_plan=true'
+ response = requests.get(url)
+
+ if response.status_code == 200: # If the response was valid
+ print(f'{Fore.GREEN} Valid {Fore.LIGHTWHITE_EX}|{Style.RESET_ALL} {code}', flush=True,
+ end='' if os.name == 'nt' else '\n')
+ with open('nitro_codes.txt', 'w') as file: # Open file to write
+ # Write the nitro code to the file it will automatically add a newline
+ file.write(code)
+
+ if notify != None:
+ return
+
+ DiscordWebhook( # Notify webhook that a code was detected
+ url=notify,
+ username='Nitro Codes',
+ content=f'Valid nitro code detected! @everyone\n{code}'
+ ).execute()
+
+ return True # Tell the main function a code was found
+
+ # If the response was invalid
+ else:
+ print(f'{Fore.LIGHTYELLOW_EX} Invalid {Fore.LIGHTWHITE_EX}|{Style.RESET_ALL} {code}', flush=True,
+ end='' if os.name == 'nt' else '\n')
+ return False # Tell the main function there was not a code found
+
+ # Print text a little fancier
+ def slowType(self, text: str, speed: float, newLine=True):
+ for i in text:
+ # Flush forces Python to print the char
+ print(i, end='', flush=True)
+ time.sleep(speed)
+ if newLine:
+ print()
+
+ def setWindowTitle(self, newTitle: str):
+ if os.name == 'nt':
+ ctypes.windll.kernel32.SetConsoleTitleW(newTitle)
+ else:
+ print(f'\33]0;{newTitle}\a',
+ end='', flush=True)
-try: # Check if the requrements have been installed
- from discord_webhook import DiscordWebhook # Try to import discord_webhook
-except ImportError: # If it chould not be installed
- input(f"Module discord_webhook not installed, to install run '{'py -3' if os.name == 'nt' else 'python3.8'} -m pip install discord_webhook'\nPress enter to exit") # Tell the user it has not been installed and how to install it
- exit() # Exit the program
-try: # Setup try statement to catch the error
- import requests # Try to import requests
-except ImportError: # If it has not been installed
- input(f"Module requests not installed, to install run '{'py -3' if os.name == 'nt' else 'python3.8'} -m pip install requests'\nPress enter to exit")# Tell the user it has not been installed and how to install it
- exit() # Exit the program
-
-
-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
-
- def main(self): # The main function contains the most important code
- os.system('cls' if os.name == 'nt' else 'clear') # Clear the screen
- if os.name == "nt": # If the system is windows
- print("")
- ctypes.windll.kernel32.SetConsoleTitleW("Nitro Generator and Checker - Made by Drillenissen#4268") # Change the
- else: # Or if it is unix
- print(f'\33]0;Nitro Generator and Checker - Made by Drillenissen#4268\a', end='', flush=True) # Update title of command prompt
-
- print(""" █████╗ ███╗ ██╗ ██████╗ ███╗ ██╗██╗██╗ ██╗
-██╔══██╗████╗ ██║██╔═══██╗████╗ ██║██║╚██╗██╔╝
-███████║██╔██╗ ██║██║ ██║██╔██╗ ██║██║ ╚███╔╝
-██╔══██║██║╚██╗██║██║ ██║██║╚██╗██║██║ ██╔██╗
-██║ ██║██║ ╚████║╚██████╔╝██║ ╚████║██║██╔╝ ██╗
-╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝╚═╝ ╚═╝
- """) # 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
-
- num = int(input('')) # Ask the user for the amount of codes
-
- # 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)
- url = input('') # Get the awnser
- 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
-
- print(f"""
-Results:
- Valid: {len(valid)}
- Invalid: {invalid}
- Valid Codes: {', '.join(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
-
-
- def slowType(self, text, speed, newLine = True): # Function used to print text a little more fancier
- for i in text: # Loop over the message
- print(i, end = "", flush = True) # Print the one charecter, flush is used to force python to print the char
- time.sleep(speed) # Sleep a little before the next one
- if newLine: # Check if the newLine argument is set to True
- print() # Print a final newline to make it act more like a normal print statement
-
- def generator(self, amount): # Function used to generate and store nitro codes in a seperate file
- with open(self.fileName, "w", encoding="utf-8") as file: # Load up the file in write mode
- print("Wait, Generating for you") # Let the user know the code is generating the codes
-
- start = time.time() # Note the initaliseation time
-
- for i in range(amount): # Loop the amount of codes to generate
- code = "".join(random.choices(
- string.ascii_uppercase + string.digits + string.ascii_lowercase,
- k = 16
- )) # Generate the code id
-
- file.write(f"https://discord.gift/{code}\n") # Write the code
-
- # Tell the user its done generating and how long tome it took
- print(f"Genned {amount} codes | Time taken: {round(time.time() - start, 5)}s\n") #
-
- def fileChecker(self, notify = None): # Function used to check nitro codes from a file
- valid = [] # A list of the valid codes
- invalid = 0 # The amount of invalid codes detected
- with open(self.fileName, "r", encoding="utf-8") as file: # Open the file containing the nitro codes
- for line in file.readlines(): # Loop over each line in the file
- nitro = line.strip("\n") # Remove the newline at the end of the nitro code
-
- # Create the requests url for later use
- url = f"https://discordapp.com/api/v6/entitlements/gift-codes/{nitro}?with_application=false&with_subscription_plan=true"
-
- response = requests.get(url) # Get the responce from the url
-
- if response.status_code == 200: # If the responce went through
- print(f" Valid | {nitro} ") # Notify the user the code was valid
- valid.append(nitro) # Append the nitro code the the list of valid codes
-
- if notify is not None: # If a webhook has been added
- DiscordWebhook( # Send the message to discord letting the user know there has been a valid nitro code
- url = notify,
- content = f"Valid Nito Code detected! @everyone \n{nitro}"
- ).execute()
- else: # If there has not been a discord webhook setup just stop the code
- break # Stop the loop since a valid code was found
-
- else: # If the responce got ignored or is invalid ( such as a 404 or 405 )
- print(f" Invalid | {nitro} ") # Tell the user it tested a code and it was invalid
- invalid += 1 # Increase the invalid counter by one
-
- return {"valid" : valid, "invalid" : invalid} # Return a report of the results
-
- def quickChecker(self, nitro, notify = None): # Used to check a single code at a time
- # Generate the request url
- url = f"https://discordapp.com/api/v6/entitlements/gift-codes/{nitro}?with_application=false&with_subscription_plan=true"
- response = requests.get(url) # Get the response from discord
-
- if response.status_code == 200: # If the responce went through
- print(f" Valid | {nitro} ", flush=True, end="" if os.name == 'nt' else "\n") # Notify the user the code was valid
- with open("Nitro Codes.txt", "w") as file: # Open file to write
- file.write(nitro) # Write the nitro code to the file it will automatically add a newline
-
- if notify is not None: # If a webhook has been added
- DiscordWebhook( # Send the message to discord letting the user know there has been a valid nitro code
- url = notify,
- content = f"Valid Nito Code detected! @everyone \n{nitro}"
- ).execute()
-
- return True # Tell the main function the code was found
-
- else: # If the responce got ignored or is invalid ( such as a 404 or 405 )
- 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
if __name__ == '__main__':
- Gen = NitroGen() # Create the nitro generator object
- Gen.main() # Run the main code
+ threadList = []
+
+ Gen = NitroGen()
+ Gen.intro() # Show title screen & info
+ Gen.config() # Get configuration values
+
+ for i in range(Gen.maxThreads):
+ t = threading.Thread(target=Gen.main)
+ t.start()
+ threadList.append(t)
+
+ for t in threading.enumerate():
+ if t is not threading.currentThread(): # Don't join main thread
+ t.join() # Join stops main thread from continuing until all threads are finished
+
+ Gen.results()
+
+ input('\n Finished! Press Enter to exit the program.')