[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)
61 lines · 1.6 KB
| 1 | package client |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "crypto/sha256" |
| 6 | "encoding/hex" |
| 7 | "fmt" |
| 8 | "io" |
| 9 | "time" |
| 10 | |
| 11 | "github.com/shehzade/contraband/pkg/client/dlp" |
| 12 | "github.com/shehzade/contraband/pkg/common" |
| 13 | ) |
| 14 | |
| 15 | type stage4Result struct { |
| 16 | TargetBytes int64 |
| 17 | EffectiveSeed int64 |
| 18 | ExpectedHash string |
| 19 | DLPConfig dlp.GeneratorConfig |
| 20 | } |
| 21 | |
| 22 | func runStage4DLP(ctx context.Context, cfg *ClientConfig, logger common.Logger) (*stage4Result, error) { |
| 23 | targetBytes, err := common.ParseBytes(cfg.Size) |
| 24 | if err != nil || targetBytes <= 0 { |
| 25 | targetBytes = 1024 * 1024 // 1MB default |
| 26 | } |
| 27 | |
| 28 | effectiveSeed := cfg.Seed |
| 29 | if effectiveSeed == 0 { |
| 30 | effectiveSeed = time.Now().UnixNano() |
| 31 | cfg.Seed = effectiveSeed |
| 32 | } |
| 33 | |
| 34 | dlpConfig := dlp.GeneratorConfig{ |
| 35 | DLPType: cfg.DLPPayloads, |
| 36 | CarrierType: cfg.CarrierType, |
| 37 | Seed: effectiveSeed, |
| 38 | } |
| 39 | |
| 40 | // Streaming Invariant: |
| 41 | // Compute pre-flight rolling SHA-256 with bounded 64KB buffer (<200KB heap) |
| 42 | hasher := sha256.New() |
| 43 | preStreamer := dlp.NewDLPStreamer(targetBytes, dlpConfig) |
| 44 | copyBuf := make([]byte, 64*1024) |
| 45 | if _, err := io.CopyBuffer(hasher, preStreamer, copyBuf); err != nil { |
| 46 | preStreamer.Close() |
| 47 | return nil, fmt.Errorf("failed to compute pre-flight payload hash: %w", err) |
| 48 | } |
| 49 | preStreamer.Close() |
| 50 | expectedHash := hex.EncodeToString(hasher.Sum(nil)) |
| 51 | |
| 52 | logger.Info(fmt.Sprintf("Stage 4 Complete: Synthesized %d bytes of DLP payload (type: %s, sha256: %s)", |
| 53 | targetBytes, cfg.DLPPayloads, expectedHash[:12]+"...")) |
| 54 | |
| 55 | return &stage4Result{ |
| 56 | TargetBytes: targetBytes, |
| 57 | EffectiveSeed: effectiveSeed, |
| 58 | ExpectedHash: expectedHash, |
| 59 | DLPConfig: dlpConfig, |
| 60 | }, nil |
| 61 | } |