← Back to all leaks

GitHub Webhook scraper

Scrape webhooks with ease

Scroll down for more info

Code

import requests import re import json import time from concurrent.futures import ThreadPoolExecutor, as_completed class DiscordWebhookFinder: def __init__(self, github_token=None): self.session = requests.Session() self.session.headers.update({ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36', 'Accept': 'application/vnd.github.v3+json' }) if github_token: self.session.headers.update({'Authorization': f'token {github_token}'}) print("Using GitHub token for authentication") else: print("Warning: No GitHub token provided. Rate limits will be strict.") self.found_webhooks = set() self.valid_webhooks = set() self.rate_limit_remaining = 30 def check_rate_limit(self): try: response = self.session.get('https://api.github.com/rate_limit', timeout=5) if response.status_code == 200: data = response.json() resources = data.get('resources', {}) core = resources.get('core', {}) self.rate_limit_remaining = core.get('remaining', 0) reset_time = core.get('reset', 0) if self.rate_limit_remaining == 0: wait_time = max(reset_time - time.time(), 0) + 10 print(f"Rate limit exceeded. Waiting {wait_time:.0f} seconds...") time.sleep(wait_time) return False return True except Exception as e: print(f"Error checking rate limit: {e}") return True def search_github(self, query, max_pages=3): base_url = "https://api.github.com/search/code" webhook_pattern = r'https?://(?:discord|discordapp)\.com/api/webhooks/\d+/[a-zA-Z0-9_-]+' for page in range(1, max_pages + 1): if not self.check_rate_limit(): continue try: params = { 'q': f'{query} extension:json OR extension:yml OR extension:yaml OR extension:env OR extension:txt OR extension:py OR extension:js', 'page': page, 'per_page': 30 } response = self.session.get(base_url, params=params, timeout=15) if response.status_code == 403: print("Rate limit exceeded. Waiting 60 seconds...") time.sleep(60) continue elif response.status_code == 401: print("Authentication failed. Check your GitHub token.") return elif response.status_code != 200: print(f"HTTP Error {response.status_code}: {response.text}") continue data = response.json() if 'items' not in data or not data['items']: print(f"No results for query: {query}") break print(f"Processing {len(data['items'])} items for '{query}' (page {page})") for item in data['items']: try: if not self.check_rate_limit(): continue raw_url = item['html_url'].replace('github.com', 'raw.githubusercontent.com').replace('/blob/', '/') file_response = self.session.get(raw_url, timeout=10) if file_response.status_code == 200: content = file_response.text found = re.findall(webhook_pattern, content) for webhook in found: if webhook not in self.found_webhooks: self.found_webhooks.add(webhook) print(f"Found webhook: {webhook}") if self.validate_webhook(webhook): self.valid_webhooks.add(webhook) time.sleep(1.5) except Exception as e: print(f"Error processing file: {e}") continue except requests.exceptions.RequestException as e: print(f"Network error searching GitHub: {e}") time.sleep(10) except Exception as e: print(f"Unexpected error searching GitHub: {e}") break def validate_webhook(self, webhook_url): try: if not webhook_url.startswith(('https://discord.com/api/webhooks/', 'https://discordapp.com/api/webhooks/')): return False response = self.session.get(webhook_url, timeout=8) if response.status_code == 200: print(f"Valid webhook: {webhook_url}") return True else: print(f"Invalid webhook: {webhook_url} (Status: {response.status_code})") return False except requests.exceptions.RequestException as e: print(f"Network error validating webhook: {e}") return False except Exception as e: print(f"Error validating webhook: {e}") return False def search_with_queries(self, queries, max_pages=2): for query in queries: print(f"Searching for: '{query}'") self.search_github(query, max_pages) time.sleep(5) def save_results(self, filename="valid_webhooks.txt"): if self.valid_webhooks: with open(filename, 'w') as f: for webhook in self.valid_webhooks: f.write(webhook + '\n') print(f"Saved {len(self.valid_webhooks)} valid webhooks to {filename}") else: print("No valid webhooks to save.") def main(): github_token = "nga here u put ur github token ok?" search_queries = [ 'discord webhook', 'webhook_url', 'DISCORD_WEBHOOK_URL', 'discord.com/api/webhooks', 'webhook discord', 'discord_webhook' ] finder = DiscordWebhookFinder(github_token=github_token) print("Starting Discord webhook search on GitHub...") print("creds: txrt owners") print("-" * 60) try: finder.search_with_queries(search_queries, max_pages=2) print("\n" + "="*60) print("Search completed!") print(f"Total webhooks found: {len(finder.found_webhooks)}") print(f"Valid webhooks: {len(finder.valid_webhooks)}") if finder.valid_webhooks: print("Valid webhooks:") for webhook in finder.valid_webhooks: print(webhook) finder.save_results() else: print("No valid webhooks found.") except KeyboardInterrupt: print("Search interrupted by user.") if finder.valid_webhooks: finder.save_results() except Exception as e: print(f"An error occurred: {e}") if __name__ == "__main__": main()

How to Use

  1. Save the code as a Python file (e.g., webhook_finder.py)
  2. Install required dependencies: pip install requests
  3. Get a GitHub personal access token (optional but recommended)
  4. Replace the token placeholder in the code
  5. Run the script: python webhook_finder.py

Features

Requirements

Made by 7665300