Advertisement
sajad2004i

Untitled

Sep 24th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.76 KB | None | 0 0
  1. import requests
  2. import time
  3. import argparse
  4. from concurrent.futures import ThreadPoolExecutor
  5. from colorama import Fore, init
  6.  
  7. # Initialize Colorama
  8. init(autoreset=True)
  9.  
  10. def send_request(url, filter_sizes, line_filters, match_code):
  11.     try:
  12.         response = requests.get(url)
  13.         size = len(response.content)  # Get the size of the response content
  14.         lines_count = len(response.text.splitlines())  # Count the number of lines in the response
  15.        
  16.         # Check if the response size is in the filter sizes
  17.         if filter_sizes is not None and size in filter_sizes:
  18.             return  # Do not print this URL
  19.  
  20.         # Check if the lines count is in the line filters
  21.         if line_filters is not None and lines_count in line_filters:
  22.             return  # Do not print this URL
  23.  
  24.         # Determine if we should print based on match_code
  25.         if match_code is not None and response.status_code != match_code:
  26.             return  # Only print if the status code matches the specified code
  27.  
  28.         # Print the status code, size, number of lines, and the URL
  29.         status_message = f"Status Code: {response.status_code} - Size: {size} bytes - Lines: {lines_count}"
  30.         if response.status_code == 200:
  31.             print(Fore.GREEN + f"{status_message} - {url}")
  32.         else:
  33.             print(Fore.YELLOW + f"{status_message} - {url}")
  34.     except requests.exceptions.RequestException:
  35.         pass
  36.         #print(Fore.RED + f"Request failed for {url}")
  37.  
  38. def fuzz_subdomains(domain, file, delay=0, filter_sizes=None, line_filters=None, match_code=None, thread_count=10):
  39.     if "FUZZ" not in domain:
  40.         print(Fore.RED + "Error: 'FUZZ' not found in the domain.")
  41.         return
  42.  
  43.     try:
  44.         with open(file) as f:
  45.             urls = [domain.replace("FUZZ", line.strip()) for line in f]
  46.  
  47.             if delay > 0:
  48.                 for url in urls:
  49.                     send_request(url, filter_sizes, line_filters, match_code)
  50.                     time.sleep(delay)  # Wait for the specified delay
  51.             else:
  52.                 # Use ThreadPoolExecutor for concurrent requests
  53.                 with ThreadPoolExecutor(max_workers=thread_count) as executor:
  54.                     executor.map(lambda url: send_request(url, filter_sizes, line_filters, match_code), urls)
  55.  
  56.     except FileNotFoundError:
  57.         print(Fore.RED + f"Error: File '{file}' not found.")
  58.  
  59. if __name__ == "__main__":
  60.     parser = argparse.ArgumentParser(description="Fuzzing tool for subdomains")
  61.     parser.add_argument("-u", "--url", required=True, help="Target URL with 'FUZZ'")
  62.     parser.add_argument("-f", "--file", required=True, help="Wordlist file")
  63.     parser.add_argument("-t", "--delay", type=int, help="Delay between requests (seconds)", default=0)
  64.     parser.add_argument("-fs", "--filter-size", type=str, help="Filter out responses of these sizes, comma-separated")
  65.     parser.add_argument("-li", "--line-filter", type=str, help="Filter out responses with these line counts, comma-separated")
  66.     parser.add_argument("-mc", "--match-code", type=int, help="Only show pages with the specified status code")
  67.     parser.add_argument("-th", "--threads", type=int, help="Number of concurrent threads", default=10)
  68.  
  69.     args = parser.parse_args()
  70.  
  71.     # Convert the comma-separated sizes into a list of integers
  72.     filter_sizes = None
  73.     if args.filter_size:
  74.         filter_sizes = list(map(int, args.filter_size.split(',')))
  75.  
  76.     # Convert the comma-separated line counts into a list of integers
  77.     line_filters = None
  78.     if args.line_filter:
  79.         line_filters = list(map(int, args.line_filter.split(',')))
  80.  
  81.     # Start fuzzing
  82.     fuzz_subdomains(args.url, args.file, args.delay, filter_sizes, line_filters, args.match_code, args.threads)
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement