● 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
contraband / pkg / client / stage_shaping.go
← Back to directory
32 lines · 953 B
Raw
1package client
2
3import (
4 "context"
5 "math"
6 "time"
7
8 "github.com/shehzade/contraband/pkg/client/traffic"
9 "github.com/shehzade/contraband/pkg/common"
10)
11
12func runStage3Shaping(ctx context.Context, cfg ClientConfig, logger common.Logger) (*traffic.TokenBucket, *traffic.CadenceEngine) {
13 rateBytes, _ := common.ParseBandwidthRate(cfg.Throughput)
14 chunkSizeBytes, _ := common.ParseBytes(cfg.ChunkSize)
15 if chunkSizeBytes <= 0 {
16 chunkSizeBytes = common.DefaultChunkSize
17 }
18 burstBytes := int64(math.Max(4*1024*1024, float64(chunkSizeBytes)*2))
19 shaper := traffic.NewTokenBucket(rateBytes, burstBytes, 0)
20
21 minDur, _ := common.ParseDuration(cfg.IntervalMin)
22 if minDur <= 0 {
23 minDur = 500 * time.Millisecond
24 }
25 maxDur, _ := common.ParseDuration(cfg.IntervalMax)
26 if maxDur <= 0 {
27 maxDur = 4 * time.Second
28 }
29 cadenceEngine, _ := traffic.NewCadenceEngine(cfg.Cadence, minDur, maxDur, 0.2, traffic.DistributionUniform)
30
31 return shaper, cadenceEngine
32}