[SHEHZADE//ABDULLAH ANSARI]
Red Team Consultant @ Google | MS in Cybersecurity @ NYU
● 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)
50 lines · 1.5 KB
| 1 | package client |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "fmt" |
| 6 | "time" |
| 7 | |
| 8 | "github.com/shehzade/contraband/pkg/client/sweep" |
| 9 | "github.com/shehzade/contraband/pkg/common" |
| 10 | ) |
| 11 | |
| 12 | func runStage1Sweep(ctx context.Context, cfg ClientConfig, logger common.Logger) ([]common.ProbeResult, error) { |
| 13 | ports, err := common.ParsePortsField(cfg.Ports) |
| 14 | if err != nil { |
| 15 | return nil, fmt.Errorf("invalid ports specification %q: %w", cfg.Ports, err) |
| 16 | } |
| 17 | |
| 18 | logger.Info(fmt.Sprintf("Stage 1: Initiating L4 port sweep against %s (%d ports, concurrency: %d)", |
| 19 | cfg.Server, len(ports), cfg.Concurrency)) |
| 20 | |
| 21 | sweepOpts := sweep.SweepOptions{ |
| 22 | Mode: sweep.ModeBoth, |
| 23 | Concurrency: cfg.Concurrency, |
| 24 | RateLimit: cfg.RateLimit, |
| 25 | Timeout: 1500 * time.Millisecond, |
| 26 | RequireReflection: false, |
| 27 | Logger: logger, |
| 28 | } |
| 29 | sweepEngine := sweep.NewEngine(sweepOpts) |
| 30 | sweepResults, err := sweepEngine.Sweep(ctx, cfg.Server, ports) |
| 31 | if err != nil { |
| 32 | logger.Warn(fmt.Sprintf("L4 sweep completed with non-fatal warning: %v", err)) |
| 33 | } |
| 34 | |
| 35 | var probes []common.ProbeResult |
| 36 | openPorts := 0 |
| 37 | for _, p := range sweepResults { |
| 38 | probe := p |
| 39 | probe.Stage = "sweep" |
| 40 | probes = append(probes, probe) |
| 41 | |
| 42 | if probe.Verdict == common.VerdictSuccess { |
| 43 | openPorts++ |
| 44 | latencyMs := float64(probe.Timestamps.TCPDuration.Microseconds()) / 1000.0 |
| 45 | logger.Success(fmt.Sprintf("[OPEN] Port %d/%s (Latency: %.2fms)", probe.TargetPort, probe.Protocol, latencyMs)) |
| 46 | } |
| 47 | } |
| 48 | logger.Info(fmt.Sprintf("Stage 1 Complete: %d/%d ports open/unfiltered", openPorts, len(ports))) |
| 49 | return probes, nil |
| 50 | } |