Red Team Tactics · Detection Engineering · Zero-Trust Defence
// AiTM (Adversary-in-the-Middle) phishing flow: victim_browser ──→ phishing_proxy ──→ legit_site ↑ ↓ intercepts: forwards: • credentials • all requests • session_token • all responses • OTP codes • page content // What the proxy captures: cookie = "SessionToken=eyJhbGciOiJSUzI1NiJ9..." // Attacker replays this cookie → authenticated session // TOTP/SMS MFA = completely bypassed
// Phase 1: Model probing via DNS resolver API for domain in candidate_domains: result = resolver.query(domain) // blocked or allowed? scores[domain] = infer_risk_score(result) // Phase 2: Gradient estimation (finite differences) def estimate_gradient(domain, eps=1): perturbed = mutate(domain, position=i) delta_score = query(perturbed) - query(domain) return delta_score / eps // Phase 3: Iterative evasion while risk_score > THRESHOLD: grad = estimate_gradient(current_domain) current_domain = apply_perturbation(grad) // Converges in ~200 queries to evading domain
// Building the phishing infrastructure graph: G = DiGraph() // Nodes: domains, IPs, ASNs, certificates, registrars G.add_node("phish-bank.ng", type="domain", risk=0.94) G.add_node("185.220.101.47", type="ip", rep="malicious") G.add_node("AS12345", type="asn", label="bulletproof") G.add_node("cert_AA:BB:CC", type="cert", age_h=2) // Edges: resolves_to, shares_ip, issued_by, registered_by G.add_edge("phish-bank.ng", "185.220.101.47", rel="resolves_to") G.add_edge("185.220.101.47", "AS12345", rel="hosted_on") // GNN propagates risk scores through graph: // guilt-by-association → new domains scored by neighbours
// Step 1: Target profile from OSINT profile = { name: "Chidi Okonkwo", role: "CFO, Lagos Fintech Ltd", recent_post: "Excited about our Series B close!", connections: ["John Smith (KPMG)", "Ada Obi (CBN)"], email_pattern: "c.okonkwo@lagosfintech.ng" } // Step 2: LLM generates personalised phish prompt = f"Write a convincing email to {profile.name} from {profile.connections[0]} about post-Series-B compliance requirements..." // Output: Perfect grammar, correct names, real context // No spelling errors, appropriate tone, plausible ask // Detection rate by humans: ~8% (Stanford 2024)
// DNSSEC validation flow: $ delv +rtrace +vtrace bank.com A // Resolver validates signature chain: . (root) KSK → DS hash → com. ZSK → DS hash → bank.com ZSK → RRSIG validates A record // If attacker hijacks registrar and changes NS: bank.com NS → attacker_ns.evil.com // Result: DNSSEC validation FAILS (DS mismatch) // Validating resolvers return SERVFAIL → attack exposed // RPKI prevents BGP hijacking of DNS traffic: ROA: 203.0.113.0/24 AS12345 maxLength=24 // Invalid BGP announcement → RPKI-invalid → dropped
dig bank.com DNSKEY +dnssec | grep "256\|257"
dig bank.com DS @8.8.8.8
delv bank.com A | grep "fully validated"
title: DNS Query to Newly Registered Phishing Domain status: stable description: Detects DNS queries to domains registered within 24h matching brand similarity patterns logsource: category: dns detection: selection: dns.query.name|re: '(bank|paypal|microsoft|gtbank).{0,20}\.(com|ng|net)' dns.registration_age_hours: |lt: 24 filter_legit: dns.query.name|endswith: - 'gtbank.com' - 'microsoft.com' condition: selection and not filter_legit falsepositives: - New legitimate subdomains (verify with CTI) level: high tags: - attack.initial_access - attack.t1566.002 # Spearphishing Link
| LAYER | CONTROL | BYPASSED BY | HARDENS WITH |
|---|---|---|---|
| DNS | DMARC p=reject | Display name spoof | BIMI + VMC |
| Gateway | AI URL rewrite | AiTM proxies | Time-of-click scan |
| Sandbox | Detonation | Delayed payload | 48h re-scan |
| Identity | FIDO2 MFA | SMS/TOTP | Origin binding |
| Session | CAE + Entra ID | Static tokens | Continuous eval |
| Endpoint | EDR + isolation | LOTL attacks | Behavioural AI |
// Campaign metrics to track: metrics = { "delivery_rate": sent / delivered, // email gateway effectiveness "open_rate": opened / delivered, // curiosity / urgency response "click_rate": clicked / opened, // URL inspection habits "cred_submit_rate": submitted / clicked, // critical failure metric "report_rate": reported / delivered, // security culture metric "time_to_click": mean(click_times), // decision velocity "time_to_report": mean(report_times) // response speed } // Target: cred_submit < 2%, report_rate > 30% // Segment by department, role, prior training
// Trigger: User reports phishing email on_event("PhishingReported"): T+00s: email.extract_iocs(reported_email) // → [domain, url, sender_ip, attachment_hash] T+02s: parallel([ vt.scan(iocs), // VirusTotal enrichment urlscan.submit(url), // live screenshot + analysis whois.query(domain), // registration age check dns.sinkhole(domain), // block immediately ]) T+05s: email.quarantine(campaign_matches) // find + pull all similar emails org-wide T+10s: if vt.malicious or age_hours < 48: identity.revokeSession(affected_users) endpoint.isolate(if_clicked) T+30s: ticket.create(severity, enriched_iocs) threat_intel.share(iocs) // MISP / STIX/TAXII
| FRONTIER | CURRENT STATE | OPEN PROBLEMS |
|---|---|---|
| LLM detection | ~78% accuracy | Watermarking, perplexity evasion |
| AI-DGA detection | >95% known families | Zero-day AI-DGA evasion |
| AiTM detection | Heuristic only | Reliable real-time token binding |
| Post-quantum auth | NIST standards ready | DNS perf with larger DNSSEC keys |
| Federated CTI | Manual STIX/TAXII | Privacy-preserving ML sharing |
// flip → analysis notes · ←→ navigate · space → flip