README.md (16752B)
1 # Contraband 2 3 [](https://golang.org) 4 [-green.svg)](https://golang.org) 5 [](docs/wiki/Soak-Testing-and-Benchmarks.md) 6 [](LICENSE) 7 8 Contraband is a pure Go network egress assessment framework for security operators and network defenders. It evaluates perimeter firewalls, corporate forward proxies, and Data Loss Prevention (DLP) inspection engines through automated L4 port sweeps, proxy authentication traversal, protocol smuggling across 20+ channels, and real-time telemetry. 9 10 ```mermaid 11 flowchart LR 12 Client["Contraband Client<br/>(L4 Sweep + Evasion + DLP)"] --> Proxy["Corporate Proxy / NGFW<br/>(PAC, NTLM/Kerberos, uTLS)"] 13 Proxy --> Server["Contraband Server<br/>(Multi-Port Reflection)"] 14 Server --> Hub["LiveHub Telemetry Engine"] 15 Hub --> Dashboard["Web Dashboard (:8080)<br/>(Real-Time SSE + Telemetry)"] 16 Client -.->|"--sync-report"| Hub 17 ``` 18 19 --- 20 21 ## Command Center Live HUD 22 23 Contraband provides a unified real-time operations dashboard served directly by the reflection listener. It visualizes concurrent egress streams, bandwidth utilization, DLP bypass efficiency, and dynamic Egress Exposure Index (EEI) metrics as probes traverse perimeter controls. 24 25  26 *Figure 1: Contraband Command Center live telemetry dashboard showing radial metric dials, bandwidth throughput, EEI posture rating, and active multi-zone egress streams (PCI CDE, Corporate LAN, Cloud VPC).* 27 28 <br/> 29 30 ### Protocol & Port Telemetry Matrix 31 32 Monitor 20 active protocol smuggling channels, open outbound egress ports, and live Server-Sent Events (SSE) telemetry logs with sub-second reflection confirmations. 33 34  35 *Figure 2: Protocol smuggling rack monitor and egress port listener matrix tracking real-time probe arrivals and payload reflections.* 36 37 <br/> 38 39 ### Synchronized Multi-Zone Reports Ledger 40 41 Client assessment results from segmented network zones automatically stream to the central listener, synchronizing findings, exposure scores, and downloadable forensic artifacts. 42 43  44 *Figure 3: Synchronized client assessment ledger aggregating multi-zone audits with direct HTML, JSON, SARIF, and firewall rule export.* 45 46 --- 47 48 ## 30-Second Quickstart 49 50 ### 1. Start Listener & Live Dashboard 51 Run on your external staging or assessment listener host: 52 53 ```bash 54 contraband server \ 55 --live-dashboard :8080 \ 56 --ports full \ 57 --protocols all \ 58 --evidence-dir ./evidence 59 ``` 60 Open `http://<server-ip>:8080/dashboard` to view the live dashboard. 61 62  63 *Figure 4: Contraband reflection server initialization with multi-port binding (:21 to :50051), TLS fallback, and live SSE event bus telemetry.* 64 65 <br/> 66 67 ### 2. Run Egress Assessment 68 Run on the target internal assessment host: 69 70 ```bash 71 contraband client \ 72 --server 198.51.100.1 \ 73 --ports full \ 74 --protocols all \ 75 --dlp all \ 76 --sync-report http://198.51.100.1:8080 \ 77 --output-html report.html \ 78 --output-json report.json \ 79 --output-sarif report.sarif 80 ``` 81 82  83 *Figure 5: Contraband client performing pre-flight port checks, protocol smuggling, DLP signature evasion, and EEI posture scoring.* 84 85 <br/> 86 87 ### 3. Assessment Scenarios by Environment 88 89 #### Scenario A: Stealth & Low-and-Slow EDR Evasion 90 Throttle exfiltration rate to 100 KB/s with randomized inter-packet jitter (2s–10s), Chrome TLS fingerprinting, and AES-256-GCM + Zstandard transform chaining to blend with routine background traffic: 91 92 ```bash 93 contraband client \ 94 --server 198.51.100.1 \ 95 --protocols https_post,dns_over_https \ 96 --cadence low-and-slow \ 97 --throughput 100KB/s \ 98 --interval-min 2s \ 99 --interval-max 10s \ 100 --tls-fingerprint chrome \ 101 --transforms aes_gcm,zstd,base64 \ 102 --passphrase "AssessmentSecretKey2026!" 103 ``` 104 105 #### Scenario B: High-Throughput QUIC & UDP Deep Packet Inspection 106 Paces a 2 MB DLP payload at a steady 1 MB/s across discrete 64 KB chunks to evaluate NGFW deep-packet inspection over modern UDP-based HTTP/3 and SMB-over-QUIC listeners: 107 108 ```bash 109 contraband client \ 110 --server 198.51.100.1 \ 111 --protocols http3_quic,smb_quic \ 112 --size 2MB \ 113 --rate 1MB/s \ 114 --chunk-size 64KB \ 115 --cadence steady \ 116 --sync-report http://198.51.100.1:8080 117 ``` 118 119 #### Scenario C: Corporate Proxy Traversal (NTLM / Negotiate / WPAD) 120 Auto-detects WinHTTP/WPAD proxy configurations or routes through an explicit corporate forward proxy with NTLM authentication and HTTP/2 multiplexing: 121 122 ```bash 123 contraband client \ 124 --server 198.51.100.1 \ 125 --proxy "http://corp-proxy.internal:8080" \ 126 --proxy-auth ntlm \ 127 --protocols http_post,https_post,websocket \ 128 --ports 80,443,8080,8443 129 ``` 130 131 #### Scenario D: Restricted & Air-Gapped Egress (DNS-Only Smuggling) 132 When all outbound direct TCP egress is blocked and only recursive internal DNS resolvers are reachable, tunnels chunked payloads over authoritative DNS TXT and A queries: 133 134 ```bash 135 contraband client \ 136 --server tunnel.egress.example.com \ 137 --protocols dns_txt,dns_a \ 138 --size 500KB \ 139 --chunk-size 64KB \ 140 --rate 50KB/s 141 ``` 142 143 #### Scenario E: Steganographic Carrier Smuggling (Deep File / DPI Bypass) 144 Embeds encrypted synthetic PCI/PII records into the least significant bits (LSB) of PNG/BMP pixel matrices or polyglot files to bypass content-disarm and deep file inspection: 145 146 ```bash 147 contraband client \ 148 --server 198.51.100.1 \ 149 --protocols https_post \ 150 --stego png \ 151 --carrier-type json \ 152 --dlp pci,pii \ 153 --transforms aes_gcm 154 ``` 155 156 #### Scenario F: Enterprise Multi-Zone Segmentation Audit 157 Tags outbound telemetry with network segment identifiers (`pci-enclave`, `dmz`, `workstations`) to isolate cross-segmentation leakage and aggregate zone comparisons on the centralized dashboard: 158 159 ```bash 160 contraband client \ 161 --server 198.51.100.1 \ 162 --zone "pci-enclave" \ 163 --ports standard \ 164 --protocols web,file,cloud \ 165 --dlp pci \ 166 --sync-report http://198.51.100.1:8080 167 ``` 168 169 #### Scenario G: Pre-Flight Safety Dry Run (Zero Sockets, Zero Wire Traffic) 170 Validates target DNS reachability, port presets, and protocol handlers while confirming the <32 MB heap invariant without transmitting packets over the network: 171 172 ```bash 173 contraband client \ 174 --server 198.51.100.1 \ 175 --protocols all \ 176 --dry-run 177 ``` 178 179 --- 180 181 ## Interactive Forensic Reports 182 183 Contraband compiles complete assessment telemetry into zero-CDN, standalone HTML reports that can be safely opened offline or attached to client deliverables. Reports include interactive SVG speedometer gauges for the Egress Exposure Index (EEI), subscore breakdowns, probe matrices, and Layer 4 egress port heatmaps. 184 185  186 *Figure 6: Standalone zero-dependency HTML forensic report featuring interactive EEI gauge, exposure subscores, and Layer 4 egress port heatmap.* 187 188 --- 189 190 ## Core CLI Flag Reference 191 192 | Flag | Default | Description | 193 | :--- | :--- | :--- | 194 | `-s, --server <host>` | `127.0.0.1` | Target reflection listener IP or hostname | 195 | `-p, --ports <preset/range>`| `quick` | Target ports: `quick` (25 common), `standard` (100), `full`, or comma/range (e.g. `80,443,8000-8100`) | 196 | `--protocols <category/list>`| `all` | Protocols: `all`, `web`, `dns`, `file`, `mail`, `smb`, `cloud`, `covert`, or comma-separated list | 197 | `--dlp <category>` | `all` | In-memory synthetic DLP secrets: `pci`, `pii`, `hipaa`, `secrets`, or `all` | 198 | `--carrier-type <format>` | `csv` | Structured carrier wrapper: `csv`, `json`, `sql`, `email`, or `syslog` | 199 | `--stego <carrier>` | `none` | Steganographic carrier: `bmp`, `png`, `wav`, `jpeg-zip`, or `pdf-jar` | 200 | `--proxy <mode/url>` | `auto` | Proxy path: `auto` (env/PAC/WPAD discovery), `direct`, or explicit URL (`http://proxy:8080`, `socks5://host:1080`) | 201 | `--proxy-auth <type>` | `basic` | Proxy authentication mode: `basic`, `ntlm`, or `negotiate` | 202 | `--tls-fingerprint <ua>` | `chrome` | uTLS Client Hello mimicry: `chrome`, `edge`, `safari`, `firefox`, or `curl` | 203 | `--throughput <rate>` | `unlimited`| Outbound rate limit (e.g. `500KB/s`, `2MB/s`) | 204 | `--cadence <profile>` | `steady` | Traffic shaping: `steady`, `jittered` (500ms–4s), `burst`, or `office-hours` | 205 | `--sync-report <url>` | *(none)* | URL of live dashboard server to synchronize results and stream chunk telemetry | 206 | `--output-html <path>` | *(none)* | Destination path for standalone zero-CDN HTML dashboard report | 207 | `--output-json <path>` | *(none)* | Destination path for structured JSON assessment report | 208 | `--output-sarif <path>` | *(none)* | Destination path for SARIF v2.1.0 security finding artifact | 209 210 --- 211 212 ## Protocol Matrix 213 214 | Channel | Protocol ID | Target Ports | RFC / Standard | Framing & Transport Mechanism | 215 | :--- | :--- | :--- | :--- | :--- | 216 | **Web** | `http_post` | 80, 8080 | RFC 9112 (HTTP/1.1) | Chunked transfer encoding, multipart form-data, or raw binary stream | 217 | **Web** | `http2_post` | 443, 8443 | RFC 9113 (HTTP/2) | Multiplexed binary DATA frames over TLS 1.3 streams | 218 | **Web** | `http3_quic` | 443 UDP | RFC 9114 (HTTP/3) | Multiplexed binary streams encapsulated inside native QUIC datagrams | 219 | **Web** | `websocket_binary` | 443, 80 | RFC 6455 | Masked binary frames (Opcode 0x2) over persistent WebSocket connection | 220 | **Web** | `grpc_protobuf` | 50051, 443 | gRPC / HTTP/2 | Client-streaming RPC carrying protobuf-serialized chunk payloads | 221 | **Web** | `webdav` | 443, 80 | RFC 4918 | Windows WebClient PROPFIND interrogation followed by chunked HTTP PUT | 222 | **DNS** | `dns_a` | 53 UDP/TCP | RFC 1035 | Base32-encoded chunk data in subdomains; listener responds with synthetic A records | 223 | **DNS** | `dns_txt` | 53 UDP/TCP | RFC 1035 | Base64-encoded chunk data in TXT query labels; supports TCP fallback on truncation | 224 | **DNS** | `dns_over_https` | 443, 8443 | RFC 8484 | Standard wireformat DNS queries encapsulated inside HTTPS POST requests | 225 | **DNS** | `dns_over_tls` | 853 TCP | RFC 7858 | Length-prefixed wireformat DNS messages over a dedicated TLS 1.3 channel | 226 | **File** | `ftp` | 21, 2121 | RFC 959 | Cleartext control channel authentication and passive (PASV) data channel upload | 227 | **File** | `ftps` | 990, 21 | RFC 4217 | Explicit (AUTH TLS) and Implicit TLS-wrapped secure file transmission | 228 | **File** | `sftp` | 22, 2222 | RFC 4253 (SSH-2) | Subsystem channel over encrypted TCP carrying binary SSH_FXP_WRITE packets | 229 | **Mail** | `smtp` | 25, 465, 587 | RFC 5321 | Outbound mail with Base64-encoded multipart MIME attachments over cleartext or TLS | 230 | **SMB** | `smb_file` | 445 TCP | MS-SMB2 | TreeConnect to administrative shares with chunked direct WRITE requests | 231 | **SMB** | `smb_hash_capture` | 445 TCP | MS-NLMP | Negotiates security context to capture NetNTLMv2 challenge-response hashes | 232 | **SMB** | `smb_quic` | 443 UDP | MS-SMB2 / RFC 9000 | Direct SMB over QUIC with ALPN negotiation for Windows 11 / Server 2022 | 233 | **Cloud** | `aws_s3` | 443 HTTPS | AWS SigV4 REST | Automated PutObject authenticated uploads with automated --destroy cleanup | 234 | **Cloud** | `gcp_gcs` | 443 HTTPS | GCS JSON API | Google Cloud Storage multipart uploads with automated --destroy cleanup | 235 | **Cloud** | `azure_blob` | 443 HTTPS | Azure REST API | Azure Storage PUT block blob operations with automated --destroy cleanup | 236 | **Covert** | `icmp_echo` | Raw L3/L4 | RFC 792 | Echo Request (Type 8) embedding magic header bytes and payload in data padding | 237 | **Covert** | `ntp_timestamp` | 123 UDP | RFC 5905 (NTPv4) | Client Mode 3 queries embedding payload chunks in fractional transmit timestamps | 238 | **Covert** | `syslog` | 514, 6514 | RFC 5424 | Structured event messages transmitted over UDP, TCP, or TLS transport | 239 | **Covert** | `mqtt` | 1883, 8883 | ISO/IEC 20922 | MQTT binary PUBLISH control packets dispatched across telemetry topics | 240 241 <br/> 242 243 ### Wire Forensics & SHA-256 Reassembly Matrix 244 245 The table below documents the wire dissector filters, framing specifications, and bit-level SHA-256 payload reassembly verified across all 24 Layer 4 and Layer 7 transport protocols: 246 247 | Gate | Protocol | Port / Transport | Tshark Dissector Filter | Framing / RFC Compliance | SHA-256 Reassembly | 248 | :--- | :--- | :--- | :--- | :--- | :--- | 249 | **01** | `http_post` | 8080/TCP | `http.request.method == "POST"` | RFC 9112 Chunked / Content-Length | MATCH | 250 | **02** | `https_post` | 8443/TCP | `tls.handshake.type == 1` | TLS 1.3 Application Data Frame | MATCH | 251 | **03** | `http3_quic` | 8443/UDP | `quic` | RFC 9000 QUIC Initial / 1-RTT | MATCH | 252 | **04** | `websocket_binary` | 8080/TCP | `websocket.opcode == 2` | RFC 6455 Binary Opcode 0x2 Masked | MATCH | 253 | **05** | `grpc_protobuf` | 50051/TCP | `http2.header.name == "content-type"` | gRPC Frame / application/grpc | MATCH | 254 | **06** | `webdav` | 8080/TCP | `http.request.method == "PUT"` | RFC 4918 PUT / PROPFIND | MATCH | 255 | **07** | `dns_a` | 5353/UDP | `dns.qry.type == 1` | RFC 1035 Base32 Subdomain Label | MATCH | 256 | **08** | `dns_txt` | 5353/UDP | `dns.qry.type == 16` | RFC 1035 TXT Record Response | MATCH | 257 | **09** | `dns_over_https` | 8443/TCP | `http2.header.value contains "dns-message"` | RFC 8484 Wireformat DNS Payload | MATCH | 258 | **10** | `dns_over_tls` | 8853/TCP | `tls.handshake.type == 1` | RFC 7858 2-byte Length-prefixed TLS | MATCH | 259 | **11** | `ftp` | 2121/TCP | `ftp.request.command == "STOR"` | RFC 959 Passive Mode Binary Transfer | MATCH | 260 | **12** | `ftps` | 2122/TCP | `tls.handshake.type == 1` | RFC 4217 Explicit TLS Command & Data | MATCH | 261 | **13** | `sftp` | 2222/TCP | `ssh.message_code == 94` | SSH_FXP_WRITE Channel Data Stream | MATCH | 262 | **14** | `smtp` | 2525/TCP | `smtp.req.command == "DATA"` | RFC 5321 Base64 Encoded Envelope | MATCH | 263 | **15** | `smb2_pipe` | 4445/TCP | `smb2.cmd == 9` | SMB2 Write Request Named Pipe | MATCH | 264 | **16** | `smb3_share` | 4445/TCP | `smb2.cmd == 9` | SMB3 Tree Connect / Share Write | MATCH | 265 | **17** | `s3_api` | 9000/TCP | `http.request.method == "PUT"` | AWS S3 Signature Version 4 PUT | MATCH | 266 | **18** | `azure_blob` | 10000/TCP | `http.request.method == "PUT"` | Azure BlockBlob Storage API | MATCH | 267 | **19** | `gcs_api` | 4443/TCP | `http.request.method == "POST"` | Google Cloud Resumable Upload | MATCH | 268 | **20** | `icmp_echo` | ICMP/IP | `icmp.type == 8` | RFC 792 Echo Request Payload Injection | MATCH | 269 | **21** | `ntp_covert` | 1123/UDP | `ntp` | RFC 5905 Extension Field Embedding | MATCH | 270 | **22** | `snmp_trap` | 1162/UDP | `snmp.pdu_type == 7` | RFC 3416 SNMPv2-Trap PDU Varbind | MATCH | 271 | **23** | `syslog_udp` | 1514/UDP | `syslog` | RFC 5424 PRI/HEADER Structured Data | MATCH | 272 | **24** | `quic_raw` | 4433/UDP | `quic` | RFC 9000 Direct Datagram Frame | MATCH | 273 | **25** | `Cryptographic Identity` | Reassembly | `sha256sum original.bin reassembled.bin` | Dynamic PRNG Seed 8888 20KB Digest: `afe17faac084641780a63a83e838dcaf7942ccee9d0c6ab85c2a51b0686f871d` | 100% BIT-FOR-BIT | 274 275 --- 276 277 ## Detailed Documentation & Operator Wiki 278 279 All deep-dive technical specifications and operational manuals are indexed in the **[Operator Wiki](docs/wiki/Home.md)**: 280 281 | Guide | Description | 282 | :--- | :--- | 283 | **[Installation and Build Guide](docs/wiki/Installation-and-Build.md)** | Cross-compilation matrix and CGO-free build instructions. | 284 | **[Quickstart Guide](docs/wiki/Quickstart-Guide.md)** | 30-second operational execution guides for standalone and unified binaries. | 285 | **[Protocols Reference](docs/wiki/Protocols-Reference.md)** | Deep dive into all 20+ transport channels and server verifiers. | 286 | **[Proxy Traversal & Evasion](docs/wiki/Proxy-Traversal-and-Evasion.md)** | PAC auto-discovery, NTLM/Kerberos auth, and uTLS profiles. | 287 | **[Synthetic DLP Verification](docs/wiki/Synthetic-DLP-Verification.md)** | Luhn card generation, SSN/NINO/SIN rules, HL7/FHIR, and cloud keys. | 288 | **[Command Center HUD Reference](docs/wiki/Command-Center-HUD.md)** | Real-time SSE event bus, metrics schema, and REST API. | 289 | **[Soak Testing & Benchmarks](docs/wiki/Soak-Testing-and-Benchmarks.md)** | 3.18 TB soak methodology, memory invariants, and sizing. | 290 291 --- 292 293 ## License 294 295 Contraband is licensed under the [Apache License 2.0](LICENSE).