detecting-command-and-control-over-dns

Detects DNS tunneling, DGA domains, and beaconing patterns in DNS query logs.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill detecting-command-and-control-over-dns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: detecting-command-and-control-over-dns
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/network-security/detecting-command-and-control-over-dns
Command: npx skills add https://github.com/xalgord/xalgorix --skill detecting-command-and-control-over-dns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, scikit-learn, pandas, tldextract, dnspython.

What problem does it solve?

Security teams struggle to identify command-and-control traffic hidden inside DNS, where attackers tunnel data through encoded subdomains, TXT records, and DGA-generated domains that evade simple signature rules.

Core Features & Use Cases

  • Entropy-Based Tunnel Detection: Computes Shannon entropy, subdomain length, and encoding ratios on DNS queries from Zeek, Suricata, or tshark to flag Iodine, dnscat2, dns2tcp, and Cobalt Strike DNS traffic.
  • TXT Record Payload Analysis: Decodes base64 TXT record content to detect PE/ELF executables, PowerShell stagers, and staged payload delivery while whitelisting legitimate SPF/DKIM records.
  • ML DGA Classification: Trains Random Forest or Gradient Boosting classifiers on character-level features (entropy, bigram deviation, digit ratios) to separate DGA domains from legitimate ones.
  • Beaconing Detection: Analyzes inter-query timing intervals per source IP and base domain to surface low-and-slow periodic C2 check-ins.
  • Use Case: A SOC analyst investigating suspicious DNS traffic can feed Zeek dns.log output into the entropy analysis workflow, flag high-entropy subdomains, then classify the associated domains with the DGA model to confirm tunneling.

Quick Start

Analyze my Zeek dns.log for DNS tunneling indicators and classify any suspicious domains as DGA or legitimate.

Frequently Asked Questions about detecting-command-and-control-over-dns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I detect DNS tunneling in network traffic?

Detect DNS tunneling by calculating Shannon entropy on query subdomains and flagging values above 3.5 combined with lengths over 30 characters. Parse Zeek dns.log or Suricata EVE JSON, then score queries for hex/base32 encoding patterns and unusual record types like NULL, TXT, or CNAME.

How to classify DGA domains with machine learning?

Train a Random Forest or Gradient Boosting classifier on character-level features: entropy, digit ratio, vowel ratio, English bigram deviation, and digit-letter transitions. Feed labeled lists of legitimate domains (Tranco top 1M) and known DGA domains, then classify new domains with probability scores.

What DNS record types indicate C2 traffic?

TXT, NULL, CNAME, and MX records are commonly abused for C2 payload delivery. Iodine uses NULL/TXT records, dnscat2 uses TXT/CNAME, and Cobalt Strike DNS beacons use A/TXT records with hex-encoded content.

Does DNS tunneling detection work with DoH or DoT traffic?

No, DNS over HTTPS (443) and DNS over TLS (853) bypass port-53 sensors entirely and never appear in Zeek dns.log. Monitor ssl.log for SNI connections to public resolvers like dns.google from non-browser hosts and block or alert on known DoH resolver IPs.

Why does entropy-based DNS detection miss slow beacons?

Low-and-slow beacons sending a few bytes every 30-300 seconds keep subdomain entropy and volume below standard thresholds. Detect them by scoring inter-query interval regularity (low coefficient of variation) per source IP and base domain over hours instead of single-query features.

How do I reduce false positives in DNS tunnel detection?

Baseline legitimate high-entropy domains such as antivirus telemetry (*.avts.mcafee.com) and CDN endpoints (*.akamaiedge.net) and whitelist them before alerting. Also match known legitimate TXT patterns like SPF, DKIM, and DMARC records to exclude them from payload analysis.