● Notice //GitHub (@shehzade) is temporarily suspended pending an automated false-positive review. All tools are hosted on this Code Mirror and available on request (contact); GitHub links will return once reinstated.
PUBLIC MIRRORGo v1.0

Multi-protocol network egress assessment and DLP verification framework featuring automated L4 sweeps, corporate proxy traversal, and covert protocol smuggling across 20+ channels.

$ git clone https://shehzade.io/repos/contraband.git Copy
Source ZIP (1.93 MB)
Code 174 Commits 1
← Back to directory
134 lines · 4.5 KB
Raw
1package main
2
3import (
4 "context"
5 "fmt"
6 "os"
7 "os/signal"
8 "syscall"
9 "time"
10
11 "github.com/shehzade/contraband/pkg/common"
12 "github.com/shehzade/contraband/pkg/soak"
13 "github.com/spf13/cobra"
14)
15
16var (
17 soakServer string
18 soakDashboard string
19 soakDuration string
20 soakLogFile string
21 soakMaxHeapMB int
22 soakValidationOnly bool
23 soakDryRun bool
24 soakZones int
25 soakVolume string
26 appLogger common.Logger
27)
28
29var rootCmd = &cobra.Command{
30 Use: "contraband-soak",
31 Short: "Overnight Continuous Multi-Scenario Soak & Live Stress Engine",
32 Long: `Contraband Overnight Continuous Soak & Stress Engine:
33Executes uninterrupted 8-10 hour multi-scenario load testing across all 20 L7 smuggling protocols,
345 concurrent network zones, progressive volume spectrum (50MB-5GB+), strict <32MB heap invariant,
35procedural synthetic DLP, steganography, proxy traversal, evasion, negative testing,
36continuous evidence logging, and live command center dashboard synchronization.`,
37 RunE: runSoakApp,
38}
39
40func init() {
41 appLogger = common.GetLogger()
42
43 rootCmd.Flags().StringVarP(&soakServer, "server", "s", "127.0.0.1", "Target Contraband reflection server address")
44 rootCmd.Flags().StringVarP(&soakDashboard, "dashboard", "d", "http://127.0.0.1:8080", "Address of the Contraband live dashboard server")
45 rootCmd.Flags().StringVar(&soakDuration, "duration", "10h", "Total soak execution window (e.g. 8h, 10h)")
46 rootCmd.Flags().StringVar(&soakLogFile, "log-file", "evidence/soak_test.log", "Continuous audit trail log file path")
47 rootCmd.Flags().IntVar(&soakMaxHeapMB, "max-heap-mb", 32, "Strict resident heap memory invariant ceiling in MB")
48 rootCmd.Flags().BoolVar(&soakValidationOnly, "validation-only", false, "Execute pre-soak validation round (micro, medium, bulk tiers) and exit")
49 rootCmd.Flags().BoolVar(&soakDryRun, "dry-run", false, "Pre-flight validation plan without executing network transmissions")
50 rootCmd.Flags().IntVar(&soakZones, "zones", 5, "Number of concurrent network zones (default 5)")
51 rootCmd.Flags().StringVar(&soakVolume, "volume", "", "Soak volume tier to stream (e.g. 50MB, 100MB, 1GB)")
52}
53
54func runSoakApp(cmd *cobra.Command, args []string) error {
55 dur, err := time.ParseDuration(soakDuration)
56 if err != nil {
57 return fmt.Errorf("invalid duration format %q: %w", soakDuration, err)
58 }
59
60 cfg := soak.DefaultSoakConfig()
61 cfg.TargetServer = soakServer
62 cfg.DashboardURL = soakDashboard
63 cfg.Duration = dur
64 cfg.LogPath = soakLogFile
65 cfg.MaxHeapCeiling = uint64(soakMaxHeapMB) * 1024 * 1024
66 cfg.DryRun = soakDryRun
67
68 if soakZones > 0 {
69 cfg.Concurrency = soakZones
70 }
71 if soakVolume != "" {
72 volBytes, err := common.ParseBytes(soakVolume)
73 if err != nil {
74 return fmt.Errorf("invalid volume format %q: %w", soakVolume, err)
75 }
76 cfg.Volumes = []int64{volBytes}
77 cfg.ValidationVolumes = []int64{volBytes}
78 }
79
80 if dur <= 2*time.Minute {
81 cfg.ReportInterval = 10 * time.Second
82 }
83
84 if cfg.DryRun {
85 appLogger.Info("[DRY-RUN] Soak Pre-Flight Plan:")
86 appLogger.Info(fmt.Sprintf(" Target Server: %s", cfg.TargetServer))
87 appLogger.Info(fmt.Sprintf(" Live Dashboard: %s", cfg.DashboardURL))
88 appLogger.Info(fmt.Sprintf(" Duration: %s", cfg.Duration))
89 appLogger.Info(fmt.Sprintf(" Evidence Log: %s", cfg.LogPath))
90 appLogger.Info(fmt.Sprintf(" Memory Ceiling: < %d MB", soakMaxHeapMB))
91 appLogger.Info(fmt.Sprintf(" Network Zones: %d zones", len(soak.AllZones())))
92 appLogger.Info(fmt.Sprintf(" Protocols: %d L7 channels", len(soak.AllSoakProtocols())))
93 appLogger.Info("[DRY-RUN] Pre-flight validation passed cleanly. Exiting without network I/O.")
94 return nil
95 }
96
97 engine, err := soak.NewSoakEngine(cfg)
98 if err != nil {
99 return fmt.Errorf("failed to initialize soak engine: %w", err)
100 }
101 defer engine.Close()
102
103 runner := soak.NewSoakRunner(engine)
104
105 ctx, cancel := context.WithTimeout(context.Background(), dur)
106 defer cancel()
107
108 sigChan := make(chan os.Signal, 1)
109 signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
110 go func() {
111 <-sigChan
112 appLogger.Info("Shutdown signal received, gracefully terminating soak engine...")
113 cancel()
114 }()
115
116 if soakValidationOnly {
117 return runner.RunValidationRound(ctx)
118 }
119
120 // For short test runs (<= 5m), jump straight to continuous multi-zone execution
121 if dur > 5*time.Minute {
122 if err := runner.RunValidationRound(ctx); err != nil {
123 appLogger.Warn(fmt.Sprintf("Pre-soak validation pass warning: %v", err))
124 }
125 }
126
127 return runner.RunContinuous(ctx)
128}
129
130func main() {
131 if err := rootCmd.Execute(); err != nil {
132 os.Exit(1)
133 }
134}