This commit is contained in:
gowtham-darkseid
2025-11-30 15:05:59 +05:30
parent 3a753ab948
commit 1eda662772
2 changed files with 355 additions and 158 deletions
+167 -79
View File
@@ -49,39 +49,67 @@ class AutoPentestX:
# Initialize database
self.db = Database()
print("\n" + "="*70)
print(" "*20 + "AutoPentestX v1.0")
print(" "*10 + "Automated Penetration Testing & Vulnerability Assessment")
print("="*70)
print(f"\n[*] Target: {self.target}")
print(f"[*] Tester: {self.tester_name}")
print(f"[*] Safe Mode: {'ENABLED' if self.safe_mode else 'DISABLED'}")
print(f"[*] Timestamp: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print("\n" + "="*70 + "\n")
RED = '\033[91m'
GREEN = '\033[92m'
CYAN = '\033[96m'
YELLOW = '\033[93m'
BOLD = '\033[1m'
RESET = '\033[0m'
print(f"\n{CYAN}╔════════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}{RED}▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓{RESET} {YELLOW}AutoPentestX v1.0{RESET} {RED}▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓{RESET} {CYAN}{RESET}")
print(f"{CYAN}{RESET} {GREEN}Automated Penetration Testing & Vulnerability Assessment{RESET} {CYAN}{RESET}")
print(f"{CYAN}╚════════════════════════════════════════════════════════════════════╝{RESET}")
print(f"\n{CYAN}┌────────────────────── [MISSION BRIEFING] ─────────────────────────┐{RESET}")
print(f"{CYAN}{RESET} {YELLOW}{RESET} Target IP/Domain: {GREEN}{self.target}{RESET}")
print(f"{CYAN}{RESET} {YELLOW}{RESET} Operator: {GREEN}{self.tester_name}{RESET}")
print(f"{CYAN}{RESET} {YELLOW}{RESET} Safe Mode: {GREEN if self.safe_mode else RED}{'[✓] ENABLED' if self.safe_mode else '[✗] DISABLED'}{RESET}")
print(f"{CYAN}{RESET} {YELLOW}{RESET} Timestamp: {GREEN}{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}{RESET}")
print(f"{CYAN}└───────────────────────────────────────────────────────────────────┘{RESET}\n")
def display_banner(self):
"""Display application banner"""
RED = '\033[91m'
GREEN = '\033[92m'
CYAN = '\033[96m'
YELLOW = '\033[93m'
MAGENTA = '\033[95m'
BOLD = '\033[1m'
RESET = '\033[0m'
banner = f"""
{RED}╔═══════════════════════════════════════════════════════════════════╗
{RED}{BOLD}╔═══════════════════════════════════════════════════════════════════╗
║ ║
║ █████╗ ██╗ ██╗████████╗ ██████╗ ██████╗ ███████╗███╗ ██╗ ║
║ ██╔══██╗██║ ██║╚══██╔══╝██╔═══██╗██╔══██╗██╔════╝████╗ ██║ ║
║ ███████║██║ ██║ ██║ ██║ ██║██████╔╝█████╗ ██╔██╗ ██║ ║
║ ██╔══██║██║ ██║ ██║ ██║ ██║██╔═══╝ ██╔══╝ ██║╚██╗██║ ║
║ ██║ ██║╚██████╔╝ ██║ ╚██████╔╝██║ ███████╗██║ ╚████║ ║
║ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ║
║ ║{RESET}
{GREEN} T E S T X - Penetration Testing Toolkit
Author: Gowtham Darkseid {RESET}
║ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ║{RESET}
{CYAN}║ ║
████████╗███████╗███████╗████████╗██╗ ██╗
╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝╚██╗██╔╝
║ ██║ █████╗ ███████╗ ██║ ╚███╔╝ ║
║ ██║ ██╔══╝ ╚════██║ ██║ ██╔██╗ ║
║ ██║ ███████╗███████║ ██║ ██╔╝ ██╗ ║
║ ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ║{RESET}
{GREEN}║ ║
║ ▄▄▄▄▄▄▄ PENETRATION TESTING FRAMEWORK ▄▄▄▄▄▄▄ ║{RESET}
{YELLOW}║ [CODENAME: D A R K S E I D] ║{RESET}
{MAGENTA}║ Author: Gowtham Darkseid ║{RESET}
{RED}║ ║
║ ⚠️ WARNING: For AUTHORIZED testing and EDUCATIONAL use ONLY
║ Unauthorized access to computer systems is ILLEGAL!
║ ⚠️ [CLASSIFIED] FOR AUTHORIZED OPS & TRAINING ONLY ⚠️
>> Unauthorized system access = FEDERAL CRIME <<
║ ║
╚═══════════════════════════════════════════════════════════════════╝{RESET}
{CYAN}┌───────────────────────────────────────────────────────────────────┐
│ [SYSTEM STATUS] │
│ ├─ Exploit Engine: {GREEN}█████████{RESET} ARMED │
│ ├─ Scanner Array: {GREEN}█████████{RESET} ONLINE │
│ ├─ CVE Database: {GREEN}█████████{RESET} SYNCED │
│ └─ Neural Core: {GREEN}█████████{RESET} OPERATIONAL │
└───────────────────────────────────────────────────────────────────┘{RESET}
"""
print(banner)
@@ -94,22 +122,34 @@ class AutoPentestX:
self.display_banner()
# Step 1: Initialize scan in database
print("\n[STEP 1] Initializing scan...")
CYAN = '\033[96m'
GREEN = '\033[92m'
RED = '\033[91m'
YELLOW = '\033[93m'
BOLD = '\033[1m'
RESET = '\033[0m'
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}{YELLOW}[PHASE 1]{RESET} {GREEN}{RESET} Initializing attack sequence... {CYAN}{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
self.scan_id = self.db.insert_scan(self.target)
if not self.scan_id:
print("[✗] Failed to initialize scan in database")
print(f"{RED}[✗] CRITICAL ERROR: Database initialization failed{RESET}")
return False
print(f"[✓] Scan ID: {self.scan_id}")
print(f"{GREEN}[✓]{RESET} Mission ID: {YELLOW}{self.scan_id}{RESET} | Status: {GREEN}ACTIVE{RESET}")
# Step 2: Network scanning
print("\n[STEP 2] Network Scanning...")
print("-" * 70)
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}{YELLOW}[PHASE 2]{RESET} {GREEN}{RESET} Network reconnaissance in progress... {CYAN}{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print(f"{CYAN}{'' * 70}{RESET}")
scanner = Scanner(self.target)
self.scan_results = scanner.run_full_scan()
if not self.scan_results:
print("[✗] Network scan failed")
print(f"{RED}[✗] ABORT: Network reconnaissance failed{RESET}")
return False
print(f"{GREEN}[✓]{RESET} Phase 2 complete - {GREEN}{len(self.scan_results.get('ports', []))}{RESET} ports discovered")
# Update database with OS detection
self.db.update_scan(self.scan_id,
@@ -121,8 +161,10 @@ class AutoPentestX:
# Step 3: Vulnerability Scanning
if not self.skip_web:
print("\n[STEP 3] Vulnerability Scanning...")
print("-" * 70)
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}{YELLOW}[PHASE 3]{RESET} {GREEN}{RESET} Vulnerability analysis initiated... {CYAN}{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print(f"{CYAN}{'' * 70}{RESET}")
vuln_scanner = VulnerabilityScanner(
self.target,
self.scan_results.get('ports', [])
@@ -137,7 +179,7 @@ class AutoPentestX:
for web_vuln in self.vuln_results.get('web_vulnerabilities', []):
self.db.insert_web_vulnerability(self.scan_id, web_vuln)
else:
print("\n[STEP 3] Vulnerability Scanning... SKIPPED")
print(f"\n{YELLOW}[PHASE 3]{RESET} Vulnerability analysis... {YELLOW}[SKIPPED BY OPERATOR]{RESET}")
self.vuln_results = {
'vulnerabilities': [],
'web_vulnerabilities': [],
@@ -145,8 +187,10 @@ class AutoPentestX:
}
# Step 4: CVE Lookup
print("\n[STEP 4] CVE Database Lookup...")
print("-" * 70)
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}{YELLOW}[PHASE 4]{RESET} {GREEN}{RESET} Accessing CVE intelligence database... {CYAN}{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print(f"{CYAN}{'' * 70}{RESET}")
cve_lookup = CVELookup()
services = self.scan_results.get('services', [])
self.cve_results = cve_lookup.lookup_services(services)
@@ -166,8 +210,10 @@ class AutoPentestX:
self.db.insert_vulnerability(self.scan_id, vuln_data)
# Step 5: Risk Assessment
print("\n[STEP 5] Risk Assessment...")
print("-" * 70)
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}{YELLOW}[PHASE 5]{RESET} {GREEN}{RESET} Computing threat matrix... {CYAN}{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print(f"{CYAN}{'' * 70}{RESET}")
risk_engine = RiskEngine()
self.risk_results = risk_engine.calculate_overall_risk(
self.scan_results,
@@ -189,8 +235,10 @@ class AutoPentestX:
# Step 6: Exploitation (Safe Mode)
if not self.skip_exploit:
print("\n[STEP 6] Exploitation Assessment (Safe Mode)...")
print("-" * 70)
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}{YELLOW}[PHASE 6]{RESET} {GREEN}{RESET} Exploit simulation {YELLOW}[SAFE MODE]{RESET}... {CYAN}{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print(f"{CYAN}{'' * 70}{RESET}")
exploit_engine = ExploitEngine(safe_mode=self.safe_mode)
# Match exploits
@@ -215,15 +263,17 @@ class AutoPentestX:
}
self.db.insert_exploit(self.scan_id, None, exploit_data)
else:
print("[*] No exploits matched")
print(f"{YELLOW}[*]{RESET} No exploits matched vulnerability profile")
self.exploit_results = []
else:
print("\n[STEP 6] Exploitation Assessment... SKIPPED")
print(f"\n{YELLOW}[PHASE 6]{RESET} Exploitation assessment... {YELLOW}[SKIPPED BY OPERATOR]{RESET}")
self.exploit_results = []
# Step 7: Generate PDF Report
print("\n[STEP 7] Generating PDF Report...")
print("-" * 70)
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}{YELLOW}[PHASE 7]{RESET} {GREEN}{RESET} Compiling classified intelligence report... {CYAN}{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print(f"{CYAN}{'' * 70}{RESET}")
pdf_generator = PDFReportGenerator(self.target, self.scan_id)
report_file = pdf_generator.generate_report(
self.scan_results,
@@ -237,7 +287,7 @@ class AutoPentestX:
)
if not report_file:
print("[!] PDF report generation failed, but scan completed successfully")
print(f"{YELLOW}[!]{RESET} Report generation failed, but mission data captured successfully")
# Calculate total time
self.end_time = time.time()
@@ -252,13 +302,18 @@ class AutoPentestX:
return True
except KeyboardInterrupt:
print("\n\n[!] Scan interrupted by user")
RED = '\033[91m'
YELLOW = '\033[93m'
RESET = '\033[0m'
print(f"\n\n{RED}[!] MISSION ABORT - Operator initiated shutdown{RESET}")
if self.scan_id:
self.db.update_scan(self.scan_id, status='interrupted')
return False
except Exception as e:
print(f"\n[✗] Critical error during assessment: {e}")
RED = '\033[91m'
RESET = '\033[0m'
print(f"\n{RED}[✗] CRITICAL SYSTEM ERROR: {e}{RESET}")
import traceback
traceback.print_exc()
if self.scan_id:
@@ -271,46 +326,67 @@ class AutoPentestX:
def display_final_summary(self, duration, report_file):
"""Display final assessment summary"""
print("\n\n" + "="*70)
print(" "*20 + "ASSESSMENT COMPLETE")
print("="*70)
print(f"\n[✓] Target: {self.target}")
print(f"[✓] Scan ID: {self.scan_id}")
print(f"[✓] Duration: {duration:.2f} seconds ({duration/60:.2f} minutes)")
print(f"[✓] Timestamp: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
RED = '\033[91m'
GREEN = '\033[92m'
CYAN = '\033[96m'
YELLOW = '\033[93m'
MAGENTA = '\033[95m'
BOLD = '\033[1m'
RESET = '\033[0m'
print("\n" + "-"*70)
print("RESULTS SUMMARY")
print("-"*70)
print(f"\n\n{GREEN}{''*70}{RESET}")
print(f"{BOLD}{GREEN}{'' * 18}{RESET} {YELLOW}MISSION COMPLETE{RESET} {GREEN}{'' * 18}{RESET}")
print(f"{GREEN}{''*70}{RESET}")
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}[OPERATION SUMMARY]{RESET} {CYAN}{RESET}")
print(f"{CYAN}╠══════════════════════════════════════════════════════════════════╣{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Target: {YELLOW}{self.target}{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Mission ID: {YELLOW}{self.scan_id}{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Duration: {YELLOW}{duration:.2f}s{RESET} ({YELLOW}{duration/60:.2f} min{RESET})")
print(f"{CYAN}{RESET} {GREEN}{RESET} Timestamp: {YELLOW}{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}[INTELLIGENCE GATHERED]{RESET} {CYAN}{RESET}")
print(f"{CYAN}╠══════════════════════════════════════════════════════════════════╣{RESET}")
if self.scan_results:
print(f"Open Ports: {len(self.scan_results.get('ports', []))}")
print(f"Services Detected: {len(self.scan_results.get('services', []))}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Open Ports: {YELLOW}{len(self.scan_results.get('ports', []))}{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Services Detected: {YELLOW}{len(self.scan_results.get('services', []))}{RESET}")
if self.risk_results:
print(f"Total Vulnerabilities: {self.risk_results.get('total_vulnerabilities', 0)}")
print(f"Web Vulnerabilities: {self.risk_results.get('web_vulnerabilities', 0)}")
print(f"SQL Injection Points: {self.risk_results.get('sql_vulnerabilities', 0)}")
print(f"CVEs Identified: {len(self.cve_results) if self.cve_results else 0}")
print(f"Overall Risk Level: {self.risk_results.get('overall_risk_level', 'UNKNOWN')}")
print(f"Risk Score: {self.risk_results.get('total_risk_score', 0):.2f}")
vuln_count = self.risk_results.get('total_vulnerabilities', 0)
risk_level = self.risk_results.get('overall_risk_level', 'UNKNOWN')
risk_color = RED if risk_level in ['CRITICAL', 'HIGH'] else YELLOW if risk_level == 'MEDIUM' else GREEN
print(f"{CYAN}{RESET} {GREEN}{RESET} Total Vulnerabilities: {RED if vuln_count > 0 else GREEN}{vuln_count}{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Web Vulnerabilities: {YELLOW}{self.risk_results.get('web_vulnerabilities', 0)}{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} SQL Injection Points: {RED if self.risk_results.get('sql_vulnerabilities', 0) > 0 else GREEN}{self.risk_results.get('sql_vulnerabilities', 0)}{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} CVEs Identified: {YELLOW}{len(self.cve_results) if self.cve_results else 0}{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Overall Risk Level: {BOLD}{risk_color}{risk_level}{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Risk Score: {risk_color}{self.risk_results.get('total_risk_score', 0):.2f}{RESET}")
if self.exploit_results:
print(f"Exploits Matched: {len(self.exploit_results)}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Exploits Matched: {MAGENTA}{len(self.exploit_results)}{RESET}")
print("\n" + "-"*70)
print("OUTPUT FILES")
print("-"*70)
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print(f"\n{CYAN}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{CYAN}{RESET} {BOLD}[CLASSIFIED DATA STORAGE]{RESET} {CYAN}{RESET}")
print(f"{CYAN}╠══════════════════════════════════════════════════════════════════╣{RESET}")
if report_file and os.path.exists(report_file):
print(f"[✓] PDF Report: {report_file}")
print(f"{CYAN}{RESET} {GREEN}{RESET} PDF Report: {YELLOW}{report_file}{RESET}")
print(f"[✓] Database: database/autopentestx.db")
print(f"[✓] Logs: logs/")
print(f"{CYAN}{RESET} {GREEN}{RESET} Database: {YELLOW}database/autopentestx.db{RESET}")
print(f"{CYAN}{RESET} {GREEN}{RESET} Logs: {YELLOW}logs/{RESET}")
print(f"{CYAN}╚══════════════════════════════════════════════════════════════════╝{RESET}")
print("\n" + "="*70)
print("\n[i] Thank you for using AutoPentestX!")
print("[i] Remember: Use this tool responsibly and ethically.\n")
print(f"\n{GREEN}{''*70}{RESET}")
print(f"\n{CYAN}[i]{RESET} {GREEN}Mission accomplished. Thank you for using AutoPentestX!{RESET}")
print(f"{CYAN}[i]{RESET} {YELLOW}Remember: Hack ethically. Hack legally. Hack responsibly.{RESET}")
print(f"{RED}[!]{RESET} {RED}Unauthorized access to systems = Federal prosecution{RESET}\n")
def main():
@@ -356,24 +432,36 @@ WARNING: This tool is for AUTHORIZED testing and EDUCATIONAL purposes ONLY.
args = parser.parse_args()
# Confirmation prompt
print("\n" + "="*70)
print("⚠️ LEGAL WARNING ⚠️")
print("="*70)
print("\nYou are about to run an automated penetration testing tool.")
print("This tool should ONLY be used on systems you own or have")
print("explicit written authorization to test.")
print("\nUnauthorized access to computer systems is ILLEGAL and may")
print("result in criminal prosecution.")
print("\nBy continuing, you confirm that you have proper authorization")
print("to perform security testing on the target system.")
print("="*70)
RED = '\033[91m'
YELLOW = '\033[93m'
CYAN = '\033[96m'
BOLD = '\033[1m'
RESET = '\033[0m'
confirmation = input("\nDo you have authorization to test this target? (yes/no): ")
print(f"\n{RED}{''*70}{RESET}")
print(f"{BOLD}{RED}⚠️ [LEGAL WARNING] - AUTHORIZATION REQUIRED ⚠️{RESET}")
print(f"{RED}{''*70}{RESET}")
print(f"\n{YELLOW}╔══════════════════════════════════════════════════════════════════╗{RESET}")
print(f"{YELLOW}{RESET} You are about to deploy an automated penetration testing tool. {YELLOW}{RESET}")
print(f"{YELLOW}{RESET} This weapon should ONLY be used on: {YELLOW}{RESET}")
print(f"{YELLOW}{RESET} • Systems you own {YELLOW}{RESET}")
print(f"{YELLOW}{RESET} • Systems with explicit written authorization {YELLOW}{RESET}")
print(f"{YELLOW}{RESET} {YELLOW}{RESET}")
print(f"{YELLOW}{RESET} {RED}Unauthorized system access = FEDERAL CRIME{RESET} {YELLOW}{RESET}")
print(f"{YELLOW}{RESET} {RED}Punishment: Fines + Imprisonment{RESET} {YELLOW}{RESET}")
print(f"{YELLOW}{RESET} {YELLOW}{RESET}")
print(f"{YELLOW}{RESET} By continuing, you confirm proper authorization to test. {YELLOW}{RESET}")
print(f"{YELLOW}╚══════════════════════════════════════════════════════════════════╝{RESET}")
confirmation = input(f"\n{CYAN}>{RESET} {BOLD}Do you have authorization to test this target?{RESET} {YELLOW}(yes/no):{RESET} ")
if confirmation.lower() not in ['yes', 'y']:
print("\n[!] Assessment cancelled. Authorization not confirmed.")
print(f"\n{RED}[!] MISSION ABORT - Authorization not confirmed.{RESET}")
print(f"{YELLOW}[*] Smart choice. Always obtain permission first.{RESET}\n")
sys.exit(0)
print(f"{CYAN}[*] Authorization confirmed. Proceeding with operation...{RESET}")
# Initialize and run assessment
safe_mode = not args.no_safe_mode