Project Heimdall is a sophisticated, AI-powered penetration testing framework that integrates multiple security tools and automates vulnerability assessment through intelligent test plan generation and execution.
The primary end-to-end experience now runs through src/heimdall/orchestration/orchestration4.py. It coordinates all agents and tools to plan, execute, and report a security assessment.
-
Entry points:
- CLI:
heimdall-scan - Module:
python -m heimdall.orchestration.orchestration4 - Python API:
from heimdall.orchestration.orchestration4 import run_orchestration
- CLI:
-
Flow:
- Launch Playwright via
WebProxyand capture network traffic - Navigate to the base URL and extract page data with
PageDataExtractor - Summarize content with
ContextManagerAgent(token-aware context trimming) - Generate plans with
PlannerAgent - Iteratively select and execute actions with
ActionerAgentusing Gemini function calling - Execute browser/security functions via
PlaywrightToolsandtools.tool_calls - Aggregate findings and generate a PDF via
ReporterAgent
- Launch Playwright via
-
Runtime knobs (
run_orchestration):expand_scope(bool),max_iterations(int),keep_messages(int)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Project Heimdall β
β β
β βββββββββββββββ ββββββββββββββββββββββββββββββββββββ β
β β PlannerAgentβββββΆβ ToolCall System β β
β β β β β β
β β β’ Gemini LLMβ β βββββββββββββββ ββββββββββββββββ β β
β β β’ OWASP β β β Security β β Browser β β β
β β Based β β β Tools β β Automation β β β
β β β’ YAML β β β β β β β β
β β Parsing β β β β’ SQLMap β β β’ Playwright β β β
β β β β β β’ Nmap β β β’ Dynamic β β β
β βββββββββββββββ β β β’ Nikto β β Testing β β β
β β β β’ OWASP ZAP β β β’ Form β β β
β β β β’ Hydra β β Automation β β β
β β β β’ Gobuster β β β β β
β β βββββββββββββββ ββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββββΌβββββββββββββββββββββββ β
β β Vulnerability Report β β
β β β’ Severity Classification β β
β β β’ Tool Performance Metrics β β
β β β’ Recommendations β β
β β β’ JSON Export β β
β βββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Purpose: AI-powered security test plan generation using Google's Gemini 2.0-flash model.
Key Features:
- LLM-Powered Analysis: Uses Gemini 2.0-flash for intelligent security assessment planning
- OWASP-Based Methodology: Follows industry-standard vulnerability testing frameworks
- YAML Parsing: Structured plan extraction with fallback mechanisms
- Comprehensive Input Analysis: Processes HTML, forms, APIs, headers, and reconnaissance data
System Prompt Capabilities:
Security Testing Areas:
- Authentication & Session Management
- Input Validation (SQL Injection, XSS, Command Injection)
- Authorization & Access Control (IDOR, Privilege Escalation)
- Business Logic Vulnerabilities
- Information Disclosure
- File Upload Security
- API Security Testing
- Network Infrastructure AssessmentExample Generated Plan:
{
"title": "SQL Injection via Authentication Bypass",
"description": "Test the /auth/login endpoint for SQL injection vulnerabilities using various payloads including union-based, boolean-based, and time-based techniques. Focus on username and password parameters with payloads like ' OR '1'='1' -- and UNION SELECT statements."
}Purpose: Generate strategic actions from plans and execute the right tool per iteration using Gemini function calling.
Architecture:
- Function-calling orchestration: Single tool call per iteration (browser or security)
- Security and browser tools catalog: SQLi, XSS, Nmap, API discovery, IDOR, JWT, plus Playwright actions
- Error handling: Resilient execution; fallbacks when tool-calling fails
- Results aggregation: Findings captured and forwarded to
ReporterAgent
| Category | Tools | Purpose |
|---|---|---|
| SQL Injection | SQLMap | Automated SQL injection detection and exploitation |
| XSS Testing | XSStrike, Browser Automation | Cross-site scripting vulnerability detection |
| Network Scanning | Nmap, Masscan | Port scanning and service enumeration |
| Web Scanning | OWASP ZAP | Web server vulnerability scanning |
| Directory Enumeration | Gobuster, FFUF, DIRB | Hidden directory and file discovery |
| Authentication | Hydra, Custom Scripts | Brute force and authentication bypass testing |
| Browser Automation | Playwright | Dynamic testing and manual verification |
# The ActionerAgent provides a "Tool Selector Command".
# If the named function exists in the allowed tools list, it is executed with provided args.
if actioner_command == "sql_injection_test(url=..., parameter=...)":
β Call `tools.tool_calls.sql_injection_test(...)`
elif actioner_command == "xss_test(url=..., parameter=...)":
β Call `tools.tool_calls.xss_test(...)`Purpose: Playwright-based dynamic security testing.
Capabilities:
- Dynamic Form Testing: Automated form interaction and payload injection
- Session Management: Cookie and authentication state handling
- JavaScript Execution: Custom security testing scripts
- Screenshot Capture: Visual evidence collection
- Response Analysis: Content parsing and vulnerability detection
Security Testing Actions:
# Core browser automation methods
goto(page, url) # Navigate to target URL
fill(page, selector, payload) # Inject test payloads
click(page, selector) # Interact with elements
execute_js(page, script) # Run custom security scripts
submit(page, form_selector) # Submit forms with payloadsasync def sql_injection_testing(plan):
# 1. SQLMap automated testing
sqlmap_result = await run_sqlmap(target_url, plan)
# 2. Manual browser-based testing
browser_result = await manual_sql_injection_test(target_url, plan)
# 3. OWASP ZAP SQL injection scan
zap_result = await zap_sql_injection_scan(target_url)
# Aggregate results and recommendations
return combined_resultsasync def xss_testing(plan):
# 1. XSStrike automated XSS detection
xsstrike_result = await run_xsstrike(target_url, plan)
# 2. Browser-based payload injection
browser_result = await manual_xss_test(target_url, plan)
# 3. ZAP XSS scanning
zap_result = await zap_xss_scan(target_url)
return aggregated_xss_resultsasync def api_security_testing(plan):
# 1. API endpoint enumeration
ffuf_result = await run_ffuf_api_enum(target_url)
# 2. IDOR vulnerability testing
idor_result = await test_idor_vulnerabilities(target_url, plan)
# 3. Authorization bypass testing
auth_result = await test_api_authorization(target_url, plan)
return api_security_results@dataclass
class ToolResult:
success: bool
tool_name: str
command: str
output: str
error: str = ""
execution_time: float = 0.0
vulnerabilities_found: List[Dict] = None
recommendations: List[str] = None# Severity levels with automatic classification
vulnerability = {
'type': 'SQL Injection',
'severity': 'Critical', # Critical, High, Medium, Low
'tool': 'SQLMap',
'evidence': 'Injectable parameter found: username',
'recommendation': 'Use parameterized queries'
}{
"summary": {
"total_tests_executed": 8,
"total_execution_time": 45.2,
"total_vulnerabilities_found": 12,
"critical_vulnerabilities": 3,
"high_vulnerabilities": 4,
"medium_vulnerabilities": 4,
"low_vulnerabilities": 1
},
"vulnerabilities_by_severity": { ... },
"vulnerabilities_by_type": { ... },
"tools_performance": { ... },
"recommendations": [ ... ]
}available_tools = {
'nmap': check_command('nmap'),
'sqlmap': check_command('sqlmap'),
'nikto': check_command('nikto'),
'zap': ZAP_AVAILABLE,
'playwright': PLAYWRIGHT_AVAILABLE,
# ... additional tools
}config = {
'zap_proxy': 'http://127.0.0.1:8080',
'zap_api_key': None,
'timeout': 300, # 5 minutes default
'max_threads': 5,
'output_dir': './pentest_results',
'wordlists': {
'common': '/usr/share/wordlists/dirb/common.txt',
'big': '/usr/share/wordlists/dirb/big.txt'
}
}from agents.planner import PlannerAgent
from tools.tool_calls import ToolCall
# Initialize components
planner = PlannerAgent(desc="Security testing planner")
tool_executor = ToolCall(config={'timeout': 60})
# Generate test plans
plans = planner.plan(target_data)
# Execute each plan
for plan in plans:
result = await tool_executor.execute_plan_step(plan)
print(f"Tool: {result.tool_name}, Vulnerabilities: {len(result.vulnerabilities_found)}")Run from CLI (installed via pyproject.toml script):
heimdall-scanRun as a Python module:
python -m heimdall.orchestration.orchestration4Run from Python:
from heimdall.orchestration.orchestration4 import run_orchestration
# knobs: expand_scope=True, max_iterations=10, keep_messages=12
run_orchestration(expand_scope=False, max_iterations=1, keep_messages=5)Change the target URL:
- Edit the
base_urlinheimdall/orchestration/orchestration4.py, or - Use the provided test wrapper
run_local_test.pywhich overridesrun_orchestrationto point to a test site
- β Login form bypass testing
- β Session fixation detection
- β Session timeout validation
- β Multi-factor authentication bypass
- β Credential brute force attacks
- β SQL injection (Union, Boolean, Time-based)
- β Cross-site scripting (Reflected, Stored, DOM)
- β Command injection
- β LDAP injection
- β XML injection
- β Insecure Direct Object Reference (IDOR)
- β Privilege escalation testing
- β Horizontal access control bypass
- β Vertical access control bypass
- β Role-based access testing
- β REST API enumeration
- β GraphQL testing
- β API versioning vulnerabilities
- β Rate limiting bypass
- β API key exposure
- β Network port scanning
- β Service enumeration
- β SSL/TLS configuration testing
- β Web server vulnerability scanning
- β Directory enumeration
- Async/await patterns for parallel tool execution
- Configurable timeouts to prevent hanging
- Resource pooling for browser instances
- Thread management for CPU-intensive tasks
- Graceful degradation when tools are unavailable
- Fallback mechanisms for failed tests
- Comprehensive logging for debugging
- Timeout protection for long-running scans
- Structured JSON reports for programmatic processing
- Human-readable summaries for analysts
- Evidence preservation with screenshots and logs
- Export capabilities for integration with other tools
-
Install Dependencies:
pip install playwright zapv2 requests playwright install
-
Install Security Tools:
# On Ubuntu/Debian apt-get install nmap sqlmap nikto gobuster ffuf hydra # OWASP ZAP (download from official site) # Configure ZAP API access
-
Run Orchestration:
# Option A: CLI heimdall-scan # Option B: module python -m heimdall.orchestration.orchestration4 # Option C: Python import python - <<'PY'
from heimdall.orchestration.orchestration4 import run_orchestration run_orchestration(expand_scope=False, max_iterations=1, keep_messages=5) PY
4. **Environment Variables**:
```bash
# Required for LLM-powered agents
export GEMINI_API_KEY=... # Planner/Actioner/Reporter when using Gemini
export FIREWORKS_API_KEY=... # ContextManager when using Fireworks models
- β AI-Powered Planning: Gemini 2.0-flash for intelligent test generation
- β 26+ Security Tools: Integration with industry-standard tools
- β Automated Tool Selection: Smart mapping based on plan content
- β Browser Automation: Playwright for dynamic testing
- β Comprehensive Reporting: Detailed vulnerability analysis
- β OWASP Methodology: Industry-standard testing approaches
- β Concurrent Execution: High-performance parallel testing
- β Extensible Architecture: Easy to add new tools and methods
- β Production Ready: Error handling and timeout management
- β Evidence Collection: Screenshots, logs, and detailed output
This system represents a sophisticated, enterprise-grade penetration testing framework that combines the power of AI planning with comprehensive tool automation for effective security assessment.