Improve dependency handling and error messages

This commit is contained in:
itsmemohamednaseem-rgb 2025-10-10 09:57:04 +05:30
parent 554ace7eee
commit 4692fefb4f
2 changed files with 40 additions and 12 deletions

View File

@ -1,3 +1,5 @@
argparse argparse>=1.4.0
dnspython dnspython>=2.2.0
requests requests>=2.25.0
urllib3>=1.26.0
colorama>=0.4.4 # Optional, for colored output

View File

@ -18,6 +18,30 @@ import socket
import json import json
from collections import Counter 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 # external modules
from subbrute import subbrute from subbrute import subbrute
import dns.resolver import dns.resolver
@ -34,9 +58,9 @@ else:
# In case you cannot install some of the required development packages # In case you cannot install some of the required development packages
# there's also an option to disable the SSL warning: # there's also an option to disable the SSL warning:
try: try:
import requests.packages.urllib3 import urllib3
requests.packages.urllib3.disable_warnings() urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
except: except ImportError:
pass pass
# Check if we are running this on windows platform # Check if we are running this on windows platform
@ -51,12 +75,14 @@ if is_windows:
R = '\033[91m' # red R = '\033[91m' # red
W = '\033[0m' # white W = '\033[0m' # white
try: try:
import win_unicode_console , colorama try:
win_unicode_console.enable() import colorama
colorama.init() colorama.init()
#Now the unicode will work ^_^ except ImportError:
except: print("[!] Optional: Install colorama for colored output (pip install colorama)")
print("[!] Error: Coloring libraries not installed, no coloring will be used [Check the readme]") 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 = '' G = Y = B = R = W = G = Y = B = R = W = ''