Offensive Testing
Offensive Testing
Relevant source files
Purpose and Scope
This document provides an overview of WSHawk's offensive security testing capabilities, including vulnerability detection modules, intelligent verification methods, and the testing workflow pipeline. Offensive testing focuses on discovering exploitable vulnerabilities in WebSocket applications through active penetration testing techniques.
For detailed information about individual vulnerability modules and their implementation, see Vulnerability Detection Modules. For browser-based verification and out-of-band testing techniques, see Advanced Verification: Playwright and OAST. For session security testing, see Session Hijacking Tests. For blue team security validation, see Defensive Validation.
Sources: README.md L1-L245
Vulnerability Testing Workflow
WSHawk implements a five-phase intelligence-driven testing workflow that distinguishes it from basic pattern-matching scanners. The process begins with a passive learning phase, followed by context-aware payload injection, multi-layered verification, and comprehensive reporting.
End-to-End Testing Pipeline
Sources: scanner_v2.py L87-L141
Vulnerability Detection Modules
WSHawk tests for seven primary vulnerability categories, each implemented as a dedicated method in the WSHawkV2 class. All tests leverage the learning phase intelligence to perform context-aware payload injection.
| Vulnerability Type | Test Method | Payload Count | OAST Support | Primary Verification |
| --- | --- | --- | --- | --- |
| SQL Injection | test_sql_injection_v2() | 22,000+ | No | Error-based detection |
| Cross-Site Scripting | test_xss_v2() | 22,000+ | No | Browser execution |
| Command Injection | test_command_injection_v2() | 22,000+ | No | Output detection |
| Path Traversal | test_path_traversal_v2() | ~5,000 | No | File content detection |
| XML External Entity | test_xxe_v2() | ~3,000 | Yes | Entity processing |
| NoSQL Injection | test_nosql_injection_v2() | ~5,000 | No | Query error detection |
| SSRF | test_ssrf_v2() | Internal targets | Yes | Metadata access |
Sources: scanner_v2.py L143-L543
Vulnerability Type Details
SQL Injection Testing
The test_sql_injection_v2() method implements database-aware testing using server fingerprinting. When ServerFingerprinter identifies the backend database (MySQL, PostgreSQL, MSSQL, Oracle), the scanner prioritizes database-specific payloads for improved detection accuracy.
Key Features:
- Intelligent payload injection into detected message fields
- Database-specific payload selection based on fingerprinting
- Error-based and blind detection techniques
- Integration with
VulnerabilityVerifierfor confidence scoring
Sources: scanner_v2.py L143-L213
Cross-Site Scripting Testing
The test_xss_v2() method implements context-aware XSS detection with optional browser-based verification. Unlike basic reflection scanners, WSHawk analyzes the injection context (HTML attribute, JavaScript string, etc.) and verifies actual script execution using Playwright.
Verification Levels:
- Pattern-based (MEDIUM confidence): Payload appears in response with dangerous context
- Browser-verified (CRITICAL confidence): Payload executes in Chromium via
HeadlessBrowserXSSVerifier
Sources: scanner_v2.py L215-L293
Command Injection Testing
The test_command_injection_v2() method uses language-specific payloads when the server programming language is identified. It detects both in-band (output-based) and blind command execution.
Detection Methods:
- Command output in WebSocket responses
- Timing-based blind detection
- System file access confirmation
Sources: scanner_v2.py L295-L359
XML External Entity (XXE) Testing
The test_xxe_v2() method integrates with the OAST provider for blind XXE detection. When use_oast is enabled, payloads include DNS/HTTP callbacks to detect out-of-band entity resolution.
Sources: scanner_v2.py L402-L456
NoSQL Injection Testing
The test_nosql_injection_v2() method tests MongoDB and other NoSQL query manipulation through operator injection ($ne, $gt, etc.) and JavaScript execution contexts.
Sources: scanner_v2.py L458-L496
Server-Side Request Forgery Testing
The test_ssrf_v2() method attempts to access internal endpoints, cloud metadata services, and localhost resources. Detection relies on server responses indicating successful internal network access.
Internal Targets:
http://localhost/http://127.0.0.1http://169.254.169.254/latest/meta-data/(AWS metadata)http://metadata.google.internal(GCP metadata)
Sources: scanner_v2.py L498-L543
Intelligence-Driven Testing Architecture
WSHawk employs three intelligence modules that transform generic payload spraying into context-aware security testing. These modules analyze server behavior during the learning phase and adapt testing strategies accordingly.
Intelligence Module Integration
Sources: scanner_v2.py L87-L141
MessageIntelligence: Format Detection and Smart Injection
The MessageIntelligence class analyzes message structure to determine format (JSON, XML, binary, plain text) and identifies injectable fields. This enables the scanner to inject payloads into the correct locations rather than blindly replacing entire messages.
Key Method:
inject_payload_into_message(base_message, payload)- Returns list of intelligently-crafted messages with payload injected into each detected field
Usage in Scanner:
Sources: scanner_v2.py L15
ServerFingerprinter: Technology Stack Detection
The ServerFingerprinter class identifies server technologies by analyzing error messages, stack traces, and response patterns collected during testing. It recommends database-specific SQL payloads, language-specific command injection vectors, and framework-specific attack techniques.
Key Methods:
add_response(message)- Accumulates response data for analysisfingerprint()- Returns detected language, framework, and databaseget_recommended_payloads(fingerprint)- Returns technology-specific payloads
Usage in Scanner:
Sources: scanner_v2.py L17
VulnerabilityVerifier: Confidence-Based Detection
The VulnerabilityVerifier class provides multi-layered verification logic that goes beyond simple pattern matching. It analyzes response characteristics to assign confidence levels (LOW, MEDIUM, HIGH, CRITICAL) and reduce false positives.
Verification Methods:
verify_sql_injection(response, payload)- Detects error messages, syntax patternsverify_xss(response, payload)- Context analysis, dangerous insertion pointsverify_command_injection(response, payload)- Output patterns, execution indicatorsverify_path_traversal(response, payload)- File content signatures
Return Format: (is_vulnerable: bool, confidence: ConfidenceLevel, description: str)
Sources: scanner_v2.py L16
Verification Methods
WSHawk implements three verification layers that progressively confirm exploitability, reducing false positives and providing actionable evidence.
Three-Layer Verification Architecture
Sources: scanner_v2.py L250-L271
Layer 1: Pattern-Based Verification (Standard)
All vulnerability tests use the VulnerabilityVerifier class to analyze responses for exploit indicators. This layer provides immediate feedback without external dependencies.
Indicators by Vulnerability Type:
| Type | Detection Indicators |
| --- | --- |
| SQL Injection | Database error messages, ODBC warnings, SQL syntax errors |
| XSS | Payload in dangerous contexts, unescaped script tags |
| Command Injection | Command output patterns, system file contents |
| Path Traversal | /etc/passwd contents, Windows system files |
| XXE | Entity processing errors, external entity references |
| NoSQL | MongoDB errors, BSON warnings, query operator syntax |
| SSRF | Metadata endpoints, connection refused messages |
Sources: scanner_v2.py L185-L191
Layer 2: Browser-Based Verification (XSS Only)
When use_headless_browser is enabled, XSS findings with HIGH confidence trigger browser-based verification using the HeadlessBrowserXSSVerifier class. This verifies that the payload actually executes JavaScript in a real browser environment.
Workflow:
- Pattern-based detection finds potential XSS (MEDIUM/HIGH confidence)
- For HIGH confidence findings, spawn headless Chromium via Playwright
- Inject response into browser DOM
- Monitor for
alert()calls, console messages, or DOM manipulation - If execution confirmed, upgrade to CRITICAL confidence and capture screenshot
Key Code:
Sources: scanner_v2.py L21
Layer 3: Out-of-Band Verification (XXE/SSRF)
For blind vulnerabilities like XXE and SSRF, the OASTProvider generates unique callback URLs that include DNS subdomains or HTTP endpoints. When the server processes the payload, it makes external requests that the OAST server logs as proof of exploitation.
OAST Workflow:
- Scanner starts
OASTProvider(either custom server or Interactsh) - For XXE payloads, generate XML with external entity referencing OAST domain
- For SSRF payloads, inject OAST HTTP URL
- Monitor OAST server for incoming DNS queries or HTTP requests
- Match callback identifiers to specific payloads
Key Code:
Sources: scanner_v2.py L22
WSHawkV2 Scanner Class Architecture
The WSHawkV2 class serves as the main orchestrator, coordinating intelligence modules, rate limiting, verification layers, and reporting.
Class Structure and Dependencies
Sources: scanner_v2.py L28-L76
Initialization and Configuration
The WSHawkV2.__init__() method instantiates all intelligence and verification modules. Key configuration flags control advanced features:
Configuration Options:
use_headless_browser(default:True) - Enable Playwright browser verification for XSSuse_oast(default:True) - Enable out-of-band testing for XXE/SSRFmax_rps(default:10) - Maximum requests per second for rate limitingauth_sequence(optional) - YAML file path for authentication flow
Sources: scanner_v2.py L33-L75
Scan Execution Flow
The run_intelligent_scan() method implements the complete testing workflow:
Execution Steps:
- Connect to WebSocket target via
connect() - Learn for 5 seconds via
learning_phase() - Execute 7 vulnerability tests sequentially
- Test session security via
SessionHijackingTester - Cleanup browser and OAST resources
- Generate HTML report via
EnhancedHTMLReporter - Display summary statistics
Rate Limiting: Each test respects the TokenBucketRateLimiter with adaptive rate adjustment based on server response times.
Sources: scanner_v2.py L545-L680
Payload Management and Mutation
WSHawk's payload system combines a large static payload library (22,000+ vectors) with intelligent mutation strategies for WAF bypass. For mutation engine details, see the separate Mutation Engine documentation.
Payload Loading
The WSPayloads class provides static methods to load payloads from text files in the payloads/ directory:
Payload Methods:
get_sql_injection()- SQL injection payloads from multiple databasesget_xss()- XSS payloads across multiple contextsget_command_injection()- OS command execution vectorsget_path_traversal()- File system access payloadsget_xxe()- XML external entity payloadsget_nosql_injection()- NoSQL operator injection payloads
Sources: scanner_v2.py L26
Intelligent Payload Selection
Rather than testing all 22,000+ payloads (which would take hours), WSHawk intelligently selects payloads based on:
- Server fingerprinting - Use database-specific SQL payloads if MySQL/PostgreSQL/etc. detected
- Language detection - Use language-specific command payloads if Python/PHP/Node.js detected
- Subset sampling - Test representative subset (100-200 payloads per type) for speed
- Confidence-based stopping - Stop testing once HIGH/CRITICAL confidence finding confirmed
Example from SQL Testing:
Sources: scanner_v2.py L150-L158
Traffic Logging and Evidence Collection
Throughout testing, WSHawk maintains detailed logs of all WebSocket traffic for inclusion in the final report. This provides auditable evidence of each vulnerability finding.
Logging Infrastructure
Message Counters:
messages_sent- Total payloads transmittedmessages_received- Total responses received- Per-test timing and statistics
Traffic Logs:
- Request/response pairs stored in
traffic_logslist - Timestamps for each interaction
- Response snippets included in vulnerability records
Sources: scanner_v2.py L65-L76
Report Generation
After all tests complete, WSHawk generates a professional HTML report using the EnhancedHTMLReporter class. The report includes:
Report Sections:
- Executive summary with vulnerability counts by severity
- CVSS v3.1 scores for each finding
- Detailed vulnerability descriptions with evidence
- Screenshots from browser-based XSS verification
- Raw WebSocket traffic logs
- Server fingerprint information
- Remediation recommendations
Report Filename: wshawk_report_YYYYMMDD_HHMMSS.html
Sources: scanner_v2.py L50
Summary: Offensive Testing Capabilities
WSHawk's offensive testing architecture implements three key innovations:
- Intelligence-Driven Testing - 5-second learning phase enables context-aware payload injection and technology-specific attack selection
- Multi-Layer Verification - Pattern detection, browser execution, and out-of-band callbacks progressively confirm exploitability
- Confidence-Based Reporting - Four-level confidence scoring (LOW/MEDIUM/HIGH/CRITICAL) with CVSS 3.1 risk assessment
This approach transforms WebSocket security testing from blind fuzzing to targeted, evidence-based vulnerability assessment suitable for professional penetration testing engagements.
Sources: README.md L9-L34