Created
June 21, 2025 23:15
-
-
Save NoozAbooz/2a6a41fc713f95dd883a0caffe600ed3 to your computer and use it in GitHub Desktop.
Brute-forces Discord server invite URLs when only a portion of the URL is provided
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import time | |
| import sys | |
| import itertools | |
| import string | |
| def generate_combinations(pattern, partial_known): | |
| """ | |
| Generate all possible combinations based on the pattern and partially known string. | |
| Args: | |
| pattern (str): Pattern string where: | |
| 'v' = lowercase letter (a-z) | |
| '^' = uppercase letter (A-Z) | |
| '#' = digit (0-9) | |
| '-' = any letter (both lowercase and uppercase) | |
| partial_known (str): Partially known string with '_' for unknown characters | |
| Returns: | |
| list: All possible combinations | |
| """ | |
| if len(pattern) != len(partial_known): | |
| raise ValueError("Pattern and partial known string must be the same length") | |
| # Create possible character sets for each position | |
| char_sets = [] | |
| for i, char in enumerate(partial_known): | |
| if char == '_': | |
| # Unknown character, use pattern to determine possible characters | |
| pattern_char = pattern[i] | |
| if pattern_char == 'v': | |
| char_sets.append(string.ascii_lowercase) | |
| elif pattern_char == '^': | |
| char_sets.append(string.ascii_uppercase) | |
| elif pattern_char == '#': | |
| char_sets.append(string.digits) # All digits 0-9 | |
| elif pattern_char == '-': | |
| char_sets.append(string.ascii_lowercase + string.ascii_uppercase + string.digits) # Both cases | |
| else: | |
| char_sets.append(pattern_char) # Exact match required | |
| else: | |
| # Known character, only one possibility | |
| char_sets.append(char) | |
| # Generate all combinations | |
| combinations = [] | |
| for combo_parts in itertools.product(*char_sets): | |
| combinations.append(''.join(combo_parts)) | |
| return combinations | |
| def check_discord_invite(invite_slug): | |
| """ | |
| Check if a Discord invite slug is valid. | |
| Args: | |
| invite_slug (str): The invite code (part after discord.gg/) | |
| Returns: | |
| tuple: (is_valid, retry_after) | |
| is_valid (bool): True if the invite is valid, False otherwise | |
| retry_after (int): Seconds to wait if rate limited, 0 otherwise | |
| """ | |
| # Discord API endpoint for invite validation | |
| url = f"https://discord.com/api/v10/invites/{invite_slug}" | |
| try: | |
| response = requests.get(url) | |
| # Check if we're rate limited | |
| if response.status_code == 429: | |
| # Parse Retry-After header | |
| retry_after = int(response.headers.get('Retry-After', 5)) | |
| print(f"Rate limited! Need to wait {retry_after} seconds.") | |
| return False, retry_after | |
| # Check if the request was successful (status code 200) | |
| if response.status_code == 200: | |
| return True, 0 | |
| else: | |
| return False, 0 | |
| except requests.exceptions.RequestException as e: | |
| print(f"Error occurred: {e}") | |
| return False, 0 | |
| def find_valid_invite(pattern, partial_known, delay_seconds): | |
| """ | |
| Try all possible combinations and find the first valid Discord invite. | |
| Args: | |
| pattern (str): Pattern string | |
| partial_known (str): Partially known string | |
| delay_seconds (float): Seconds to wait between requests | |
| Returns: | |
| str: Valid invite slug or None if no valid invites found | |
| """ | |
| combinations = generate_combinations(pattern, partial_known) | |
| print(f"Generated {len(combinations)} possible combinations to try") | |
| for i, combo in enumerate(combinations): | |
| print(f"Trying combination {i+1}/{len(combinations)}: {combo}") | |
| is_valid, retry_after = check_discord_invite(combo) | |
| if is_valid: | |
| return combo | |
| # Wait either the retry_after time (if rate limited) or the default delay | |
| sleep_time = retry_after if retry_after > 0 else delay_seconds | |
| print(f"Waiting {sleep_time} seconds before next request...") | |
| time.sleep(sleep_time) | |
| return None | |
| def main(): | |
| if len(sys.argv) != 3: | |
| print("Usage: python find_discord_invite.py <pattern> <partial_known>") | |
| print("Example: python find_discord_invite.py vvv^^#vv^v bamYE_hjOx") | |
| print("Pattern symbols: v=lowercase, ^=uppercase, #=digit, -=any letter (lower or upper)") | |
| sys.exit(1) | |
| pattern = sys.argv[1] | |
| partial_known = sys.argv[2] | |
| # Prompt user for delay between requests | |
| while True: | |
| try: | |
| delay_input = input("Enter time between requests in seconds (default: 2): ").strip() | |
| if not delay_input: | |
| delay_seconds = 2.0 | |
| else: | |
| delay_seconds = float(delay_input) | |
| break | |
| except ValueError: | |
| print("Please enter a valid number.") | |
| print(f"Using {delay_seconds} seconds delay between requests.") | |
| valid_invite = find_valid_invite(pattern, partial_known, delay_seconds) | |
| if valid_invite: | |
| print(f"Found valid Discord invite: discord.gg/{valid_invite}") | |
| else: | |
| print("No valid Discord invites found among the combinations.") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment