Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /mcp_pentest_suite /config.py
| """ | |
| Configuration module for the MCP Pentest Suite. | |
| Centralizes all settings, tool paths, API keys, and compliance rules. | |
| """ | |
| import os | |
| from dataclasses import dataclass, field | |
| from pathlib import Path | |
| from typing import Dict, List, Optional | |
| class ToolConfig: | |
| """Configuration for integrated security tools.""" | |
| name: str | |
| executable: str | |
| version_check: str | |
| install_url: str | |
| category: str # recon, scan, exploit, report, ai_model | |
| mcp_tools: List[str] = field(default_factory=list) | |
| enabled: bool = True | |
| class ComplianceRule: | |
| """A compliance rule for pentest operations.""" | |
| rule_id: str | |
| name: str | |
| description: str | |
| severity: str # critical, high, medium, low | |
| check_type: str # scope_validation, authorization, data_protection | |
| enabled: bool = True | |
| class MCPSuiteConfig: | |
| """Master configuration for the MCP Pentest Suite.""" | |
| # Server settings | |
| mcp_host: str = "127.0.0.1" | |
| mcp_port: int = 9876 | |
| mcp_transport: str = "stdio" # stdio, sse, websocket | |
| # AI Provider settings | |
| ai_provider: str = "openrouter" # openrouter, openai, anthropic, ollama | |
| ai_model: str = "anthropic/claude-sonnet-4" | |
| ai_api_key: str = field(default_factory=lambda: os.getenv("AI_API_KEY", "")) | |
| ai_base_url: str = "https://openrouter.ai/api/v1" | |
| ai_temperature: float = 0.3 | |
| ai_max_tokens: int = 4096 | |
| # Ollama local settings (fallback) | |
| ollama_host: str = "http://localhost:11434" | |
| ollama_model: str = "qwen3:32b" | |
| # Sandbox settings | |
| sandbox_enabled: bool = True | |
| sandbox_type: str = "docker" # docker, gvisor, firejail | |
| sandbox_timeout: int = 300 # seconds | |
| sandbox_max_memory: str = "512m" | |
| sandbox_network_isolated: bool = True | |
| # Safety settings | |
| require_human_approval: bool = True | |
| approval_threshold: str = "medium" # low, medium, high, critical | |
| max_concurrent_scans: int = 5 | |
| rate_limit_requests_per_minute: int = 60 | |
| blocked_ports: List[int] = field(default_factory=lambda: [22, 25, 53]) | |
| blocked_hosts: List[str] = field( | |
| default_factory=lambda: [ | |
| "localhost", | |
| "127.0.0.1", | |
| "::1", | |
| "0.0.0.0", | |
| "169.254.0.0/16", | |
| "10.0.0.0/8", | |
| "172.16.0.0/12", | |
| "192.168.0.0/16", | |
| ] | |
| ) | |
| # Logging | |
| log_level: str = "INFO" | |
| log_file: str = "logs/mcp_pentest.log" | |
| audit_log: str = "logs/audit.log" | |
| # Integrated tools configuration | |
| tools: Dict[str, ToolConfig] = field( | |
| default_factory=lambda: { | |
| "nuclei": ToolConfig( | |
| name="Nuclei", | |
| executable="nuclei", | |
| version_check="nuclei -version", | |
| install_url="https://github.com/projectdiscovery/nuclei", | |
| category="scan", | |
| mcp_tools=["nuclei_scan", "nuclei_template_list", "nuclei_template_generate"], | |
| ), | |
| "nmap": ToolConfig( | |
| name="Nmap", | |
| executable="nmap", | |
| version_check="nmap --version", | |
| install_url="https://nmap.org", | |
| category="recon", | |
| mcp_tools=["nmap_scan", "nmap_service_detect", "nmap_os_detect"], | |
| ), | |
| "sqlmap": ToolConfig( | |
| name="SQLMap", | |
| executable="sqlmap", | |
| version_check="sqlmap --version", | |
| install_url="https://sqlmap.org", | |
| category="exploit", | |
| mcp_tools=["sqlmap_scan", "sqlmap_dump", "sqlmap_shell"], | |
| ), | |
| "metasploit": ToolConfig( | |
| name="Metasploit", | |
| executable="msfconsole", | |
| version_check="msfconsole --version", | |
| install_url="https://metasploit.com", | |
| category="exploit", | |
| mcp_tools=["msf_search", "msf_exploit", "msf_payload"], | |
| ), | |
| "zap": ToolConfig( | |
| name="OWASP ZAP", | |
| executable="zap.sh", | |
| version_check="zap.sh -version", | |
| install_url="https://www.zaproxy.org", | |
| category="scan", | |
| mcp_tools=["zap_spider", "zap_scan", "zap_report"], | |
| ), | |
| "subfinder": ToolConfig( | |
| name="Subfinder", | |
| executable="subfinder", | |
| version_check="subfinder -version", | |
| install_url="https://github.com/projectdiscovery/subfinder", | |
| category="recon", | |
| mcp_tools=["subfinder_enum", "subfinder_passive"], | |
| ), | |
| "katana": ToolConfig( | |
| name="Katana", | |
| executable="katana", | |
| version_check="katana -version", | |
| install_url="https://github.com/projectdiscovery/katana", | |
| category="recon", | |
| mcp_tools=["katana_crawl", "katana_js_parse"], | |
| ), | |
| "httpx": ToolConfig( | |
| name="httpx", | |
| executable="httpx", | |
| version_check="httpx -version", | |
| install_url="https://github.com/projectdiscovery/httpx", | |
| category="recon", | |
| mcp_tools=["httpx_probe", "httpx_screenshot"], | |
| ), | |
| "naabu": ToolConfig( | |
| name="Naabu", | |
| executable="naabu", | |
| version_check="naabu -version", | |
| install_url="https://github.com/projectdiscovery/naabu", | |
| category="recon", | |
| mcp_tools=["naabu_portscan"], | |
| ), | |
| "waybackurls": ToolConfig( | |
| name="Waybackurls", | |
| executable="waybackurls", | |
| version_check="waybackurls -h", | |
| install_url="https://github.com/tomnomnom/waybackurls", | |
| category="recon", | |
| mcp_tools=["waybackurls_fetch"], | |
| ), | |
| } | |
| ) | |
| # AI-powered tool integrations | |
| ai_tools: Dict[str, ToolConfig] = field( | |
| default_factory=lambda: { | |
| "pentestgpt": ToolConfig( | |
| name="PentestGPT", | |
| executable="pentestgpt", | |
| version_check="pentestgpt --version", | |
| install_url="https://github.com/GreyDGL/PentestGPT", | |
| category="ai_model", | |
| mcp_tools=["pentestgpt_reasoning", "pentestgpt_attack_plan", "pentestgpt_report"], | |
| ), | |
| "garak": ToolConfig( | |
| name="Garak", | |
| executable="garak", | |
| version_check="garak --version", | |
| install_url="https://github.com/leondz/garak", | |
| category="ai_model", | |
| mcp_tools=["garak_probe", "garak_report"], | |
| ), | |
| "pyrit": ToolConfig( | |
| name="PyRIT", | |
| executable="pyrit", | |
| version_check="pyrit --version", | |
| install_url="https://github.com/Azure/PyRIT", | |
| category="ai_model", | |
| mcp_tools=["pyrit_attack", "pyrit_orchestrate", "pyrit_report"], | |
| ), | |
| "pentestagent": ToolConfig( | |
| name="PentestAgent", | |
| executable="pentestagent", | |
| version_check="pentestagent --version", | |
| install_url="https://github.com/GH05TCREW/PentestAgent", | |
| category="ai_model", | |
| mcp_tools=["pentestagent_scan", "pentestagent_crew", "pentestagent_shadow"], | |
| ), | |
| "nuclei_ai": ToolConfig( | |
| name="Nuclei AI Templates", | |
| executable="nuclei", | |
| version_check="nuclei -version", | |
| install_url="https://github.com/projectdiscovery/nuclei", | |
| category="ai_model", | |
| mcp_tools=["nuclei_ai_generate_template", "nuclei_ai_cve_scan"], | |
| ), | |
| } | |
| ) | |
| # Compliance rules (GDPR, BSI, NIST aligned) | |
| compliance_rules: List[ComplianceRule] = field( | |
| default_factory=lambda: [ | |
| ComplianceRule( | |
| rule_id="COMP-001", | |
| name="Written Authorization Required", | |
| description="All pentest activities require documented written authorization from the system owner", | |
| severity="critical", | |
| check_type="authorization", | |
| ), | |
| ComplianceRule( | |
| rule_id="COMP-002", | |
| name="Scope Validation", | |
| description="Target must be within defined scope - no out-of-scope testing allowed", | |
| severity="critical", | |
| check_type="scope_validation", | |
| ), | |
| ComplianceRule( | |
| rule_id="COMP-003", | |
| name="Data Minimization", | |
| description="Only collect data necessary for the security assessment (GDPR Art. 5(1)(c))", | |
| severity="high", | |
| check_type="data_protection", | |
| ), | |
| ComplianceRule( | |
| rule_id="COMP-004", | |
| name="No Personal Data Exfiltration", | |
| description="Personal data must not be extracted or stored outside the test environment", | |
| severity="critical", | |
| check_type="data_protection", | |
| ), | |
| ComplianceRule( | |
| rule_id="COMP-005", | |
| name="Audit Trail Required", | |
| description="All actions must be logged with timestamp, user, and result", | |
| severity="high", | |
| check_type="authorization", | |
| ), | |
| ComplianceRule( | |
| rule_id="COMP-006", | |
| name="Denial of Service Prevention", | |
| description="Tests must not cause service unavailability (rate limiting enforced)", | |
| severity="high", | |
| check_type="scope_validation", | |
| ), | |
| ComplianceRule( | |
| rule_id="COMP-007", | |
| name="Safe Harbor Compliance", | |
| description="Follow responsible disclosure practices for all findings", | |
| severity="medium", | |
| check_type="authorization", | |
| ), | |
| ] | |
| ) | |
| def from_env(cls) -> "MCPSuiteConfig": | |
| """Load configuration from environment variables.""" | |
| config = cls() | |
| config.mcp_host = os.getenv("MCP_HOST", config.mcp_host) | |
| config.mcp_port = int(os.getenv("MCP_PORT", str(config.mcp_port))) | |
| config.ai_provider = os.getenv("AI_PROVIDER", config.ai_provider) | |
| config.ai_model = os.getenv("AI_MODEL", config.ai_model) | |
| config.ai_api_key = os.getenv("AI_API_KEY", config.ai_api_key) | |
| config.sandbox_enabled = os.getenv("SANDBOX_ENABLED", "true").lower() == "true" | |
| config.require_human_approval = os.getenv("HUMAN_APPROVAL", "true").lower() == "true" | |
| config.log_level = os.getenv("LOG_LEVEL", config.log_level) | |
| return config | |
| def from_file(cls, path: str) -> "MCPSuiteConfig": | |
| """Load configuration from a JSON or YAML file.""" | |
| import json | |
| filepath = Path(path) | |
| if not filepath.exists(): | |
| return cls.from_env() | |
| with open(filepath, "r") as f: | |
| data = json.load(f) | |
| return cls(**data) | |
Xet Storage Details
- Size:
- 11.4 kB
- Xet hash:
- 9eeb6df5fe1d7147d0ed4592c16ea1d5b58eb8da80c6f018eb67c898a36a3835
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.