#!/usr/bin/env python3 """ APEX - Advanced Penetration and Exploitation eXecution Framework The Most Powerful Ethical Hacking Tool Features: - Multi-stage reconnaissance (passive & active) - Advanced vulnerability scanning - Automated exploitation - Web application security testing - Network penetration testing - Wireless security assessment - Post-exploitation modules - Advanced reporting and analytics - Plugin architecture - Automation and scripting """ import sys import os import argparse import json import asyncio from pathlib import Path from datetime import datetime from typing import Dict, List, Any import importlib.util # ANSI Color codes class Colors: HEADER = '\033[95m' BLUE = '\033[94m' CYAN = '\033[96m' GREEN = '\033[92m' YELLOW = '\033[93m' RED = '\033[91m' END = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' class ApexFramework: """Main APEX Framework Class""" VERSION = "1.0.0" BANNER = f""" {Colors.CYAN}{Colors.BOLD} ╔═╗╔═╗╔═╗═╗ ╦ ╠═╣╠═╝║╣ ╔╩╦╝ ╩ ╩╩ ╚═╝╩ ╚═ {Colors.END}{Colors.GREEN} Advanced Penetration and Exploitation eXecution Framework Version: {VERSION} {Colors.YELLOW}The Ultimate Ethical Hacking Tool{Colors.END} {Colors.CYAN}═══════════════════════════════════════{Colors.END} """ def __init__(self, config_file=None): """Initialize APEX Framework""" self.home_dir = Path.home() / ".apex" self.home_dir.mkdir(exist_ok=True) self.config_file = config_file or self.home_dir / "apex.json" self.plugins_dir = self.home_dir / "plugins" self.plugins_dir.mkdir(exist_ok=True) self.results_dir = self.home_dir / "results" self.results_dir.mkdir(exist_ok=True) self.wordlists_dir = self.home_dir / "wordlists" self.wordlists_dir.mkdir(exist_ok=True) self.config = self.load_config() self.modules = {} self.session_data = {} def load_config(self) -> Dict: """Load configuration""" default_config = { "version": self.VERSION, "global": { "threads": 50, "timeout": 10, "user_agent": "APEX/1.0", "verify_ssl": False, "proxy": None, "output_format": "json" }, "reconnaissance": { "passive_enum": True, "active_enum": True, "deep_scan": False }, "scanning": { "service_detection": True, "os_detection": False, "vulnerability_scan": True }, "exploitation": { "auto_exploit": False, "safe_mode": True, "payload_encoding": True }, "web_testing": { "sql_injection": True, "xss_testing": True, "csrf_testing": True, "file_inclusion": True, "command_injection": True, "authentication_bypass": True }, "wireless": { "capture_handshakes": True, "wps_testing": True, "evil_twin": False }, "reporting": { "auto_report": True, "report_format": ["html", "json", "pdf"], "include_screenshots": True } } if self.config_file.exists(): try: with open(self.config_file, 'r') as f: loaded = json.load(f) # Merge with defaults return {**default_config, **loaded} except: pass # Save default config with open(self.config_file, 'w') as f: json.dump(default_config, f, indent=4) return default_config def save_config(self): """Save configuration""" with open(self.config_file, 'w') as f: json.dump(self.config, f, indent=4) def register_module(self, name: str, module_class): """Register a module""" self.modules[name] = module_class def print_banner(self): """Print APEX banner""" print(self.BANNER) def print_info(self, message): """Print info message""" print(f"{Colors.BLUE}[*]{Colors.END} {message}") def print_success(self, message): """Print success message""" print(f"{Colors.GREEN}[+]{Colors.END} {message}") def print_warning(self, message): """Print warning message""" print(f"{Colors.YELLOW}[!]{Colors.END} {message}") def print_error(self, message): """Print error message""" print(f"{Colors.RED}[-]{Colors.END} {message}") def print_header(self, message): """Print section header""" print(f"\n{Colors.CYAN}{Colors.BOLD}{'═' * 50}{Colors.END}") print(f"{Colors.CYAN}{Colors.BOLD} {message}{Colors.END}") print(f"{Colors.CYAN}{Colors.BOLD}{'═' * 50}{Colors.END}\n") def load_plugins(self): """Load plugins from plugins directory""" self.print_info("Loading plugins...") count = 0 for plugin_file in self.plugins_dir.glob("*.py"): try: spec = importlib.util.spec_from_file_location( plugin_file.stem, plugin_file ) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) if hasattr(module, 'register'): module.register(self) count += 1 self.print_success(f"Loaded plugin: {plugin_file.stem}") except Exception as e: self.print_error(f"Failed to load {plugin_file.stem}: {e}") self.print_success(f"Loaded {count} plugins") def save_results(self, module_name: str, results: Dict): """Save results to file""" timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") filename = self.results_dir / f"{module_name}_{timestamp}.json" with open(filename, 'w') as f: json.dump(results, f, indent=4) self.print_success(f"Results saved to: {filename}") def interactive_mode(self): """Interactive console mode""" self.print_banner() self.print_info("Entering interactive mode (type 'help' for commands)") while True: try: cmd = input(f"\n{Colors.CYAN}apex>{Colors.END} ").strip() if not cmd: continue if cmd.lower() in ['exit', 'quit', 'q']: self.print_info("Exiting APEX...") break elif cmd.lower() == 'help': self.show_help() elif cmd.lower() == 'modules': self.list_modules() elif cmd.lower() == 'info': self.show_info() elif cmd.startswith('use '): module_name = cmd[4:].strip() self.use_module(module_name) elif cmd.startswith('set '): parts = cmd[4:].split(None, 1) if len(parts) == 2: self.set_option(parts[0], parts[1]) elif cmd.lower() == 'options': self.show_options() elif cmd.lower() in ['run', 'execute']: self.execute_current_module() elif cmd.lower() == 'back': self.session_data.pop('current_module', None) self.print_info("Returned to main menu") else: self.print_error(f"Unknown command: {cmd}") except KeyboardInterrupt: print() continue except EOFError: print() break def show_help(self): """Show help menu""" help_text = f""" {Colors.BOLD}Available Commands:{Colors.END} {Colors.CYAN}Core Commands:{Colors.END} help - Show this help menu modules - List all available modules info - Show framework information exit/quit - Exit APEX {Colors.CYAN}Module Commands:{Colors.END} use - Select a module options - Show module options set