Overview
DNS is often trusted by firewalls, making it a prime channel for data exfiltration and command‑and‑control (C2). In Pakistani organizations, DNS tunneling has been observed in APT campaigns targeting banks and e‑government portals. Detecting these techniques early requires Zeek logging, Suricata rules, and correlation with threat intelligence.
Detecting DNS Tunneling with Zeek
- Enable DNS logging – add
logdns = ALLtozeek.conf. - Capture DNS traffic –
zeek -i eth0 -C. - Analyze
dns.log– look for high‑entropy query names, long subdomains, or unusually high query frequency. - Enrich with JA3/JARM – hash the client’s TLS fingerprint to spot DGA‑related DNS over HTTPS patterns.
- Automate alerts – send
dns.logto Elastic Stack, create a watch for entropy > 4.0.
Suricata Rules for DGA Detection
- Use ET Open rule
alert dns any any -> any any (msg:"ET DNS Query to suspected DGA domain"; dns.query; pcre:"/[a-z]{10,}\\.[a-z]{2,}$/"; sid:2100001;). - Add custom rule for subdomains longer than 15 characters:
alert dns $HOME_NET any -> any any (msg:"Possible DNS Tunneling – Long Subdomain"; dns.query; byte_test:4,>,15,0; sid:2100002;). - Enable HTTP/2 detection to catch DNS‑over‑HTTPS tunnels.
Integrating with MISP for Pakistani Threat Feeds
- Subscribe to NCCIA/PTCL DNS blocklists via MISP.
- Export Suricata EVE JSON to MISP.
- Tag events with
finanical-sector,gov‑pk. - Create Sigma rule for high‑entropy DNS queries:
title: DNS Tunneling via High Entropy Subdomain; logsource: zeek; detection: condition: dns_query_entropy > 4.0;. - Automate sinkhole – update firewall rules with collected indicators.
Pakistani Context: Real‑World Scenarios
- Daraz/Olx phishing kits often use DNS TXT records for C2; Zeek’s
dns.logreveals unusualTXTqueries to unregistered domains. - NADRA’s e‑service portal was observed exfiltrating employee credentials via DNS queries to a foreign server; early detection prevented data breach.
- Regulatory compliance – PTA mandates DNS log retention for 90 days; store logs in a SIEM compliant with data‑sovereignty rules.
Do’s and Don’ts
- Do keep DNS logs for the mandated period.
- Do correlate DNS anomalies with user identity from AD logs.
- Don’t ignore low‑and‑slow tunnels that blend with legitimate traffic.
- Don’t block DNS entirely – you’ll break services; use allow‑listing instead.
Takeaway: By combining Zeek’s detailed DNS logging, Suricata’s detection rules, and MISP sharing, Pakistani SOCs can spot DNS‑based exfiltration before data leaves the network.
