From 4692fefb4f9f2f38a54ceff4d83b49345423a5b9 Mon Sep 17 00:00:00 2001 From: itsmemohamednaseem-rgb Date: Fri, 10 Oct 2025 09:57:04 +0530 Subject: [PATCH] Improve dependency handling and error messages --- requirements.txt | 8 +++++--- sublist3r.py | 44 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/requirements.txt b/requirements.txt index 498ea9d..54d9229 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ -argparse -dnspython -requests +argparse>=1.4.0 +dnspython>=2.2.0 +requests>=2.25.0 +urllib3>=1.26.0 +colorama>=0.4.4 # Optional, for colored output diff --git a/sublist3r.py b/sublist3r.py index e5a7856..fbfad1d 100755 --- a/sublist3r.py +++ b/sublist3r.py @@ -18,6 +18,30 @@ import socket import json from collections import Counter +# Function to check and install dependencies +def check_dependencies(): + missing_modules = [] + try: + import requests + except ImportError: + missing_modules.append('requests') + try: + import dns.resolver + except ImportError: + missing_modules.append('dnspython') + + if missing_modules: + print("\nError: Missing required modules: " + ", ".join(missing_modules)) + print("\nPlease install the missing modules using one of these commands:") + print("\npip install " + " ".join(missing_modules)) + print("pip3 install " + " ".join(missing_modules)) + print("\nOr install all requirements using:") + print("pip install -r requirements.txt") + sys.exit(1) + +# Check dependencies before importing +check_dependencies() + # external modules from subbrute import subbrute import dns.resolver @@ -34,9 +58,9 @@ else: # In case you cannot install some of the required development packages # there's also an option to disable the SSL warning: try: - import requests.packages.urllib3 - requests.packages.urllib3.disable_warnings() -except: + import urllib3 + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) +except ImportError: pass # Check if we are running this on windows platform @@ -51,12 +75,14 @@ if is_windows: R = '\033[91m' # red W = '\033[0m' # white try: - import win_unicode_console , colorama - win_unicode_console.enable() - colorama.init() - #Now the unicode will work ^_^ - except: - print("[!] Error: Coloring libraries not installed, no coloring will be used [Check the readme]") + try: + import colorama + colorama.init() + except ImportError: + print("[!] Optional: Install colorama for colored output (pip install colorama)") + G = Y = B = R = W = G = Y = B = R = W = '' + except Exception as e: + print("[!] Error with color handling:", str(e)) G = Y = B = R = W = G = Y = B = R = W = ''