New to Claude Skills? Learn how to install them →

mukul975 on GitHub

DNS Tunneling Detection with Zeek

Free

Identify covert data exfiltration via DNS queries.

Get this skill

Free · Opens the source repo

What DNS Tunneling Detection with Zeek does

The DNS Tunneling Detection with Zeek skill is designed for cybersecurity professionals who need to identify and analyze potential data exfiltration occurring through DNS tunneling. By leveraging Zeek's dns.log, this skill detects high-entropy subdomain queries, excessive query volumes, and unusual DNS record types, which are indicators of covert data channels. This skill is particularly useful in environments where DNS traffic is a primary vector for data breaches, allowing for proactive threat hunting and incident response.

To utilize this skill effectively, users must have Zeek deployed on their network to capture DNS traffic. The analysis involves calculating metrics such as query length distribution and subdomain entropy to identify anomalies. For instance, DNS queries that are significantly longer than typical lengths or exhibit high entropy may suggest encoded data, which is a hallmark of tunneling techniques. The skill also includes workflows for correlating DNS queries with connection logs and validating findings against threat intelligence to enhance detection accuracy.

This skill is ideal for security analysts and incident responders who are tasked with monitoring network traffic for signs of data exfiltration. It provides a structured approach to analyzing DNS logs, making it easier to spot suspicious patterns that could indicate malicious activity. By integrating with existing SIEM platforms and tools like RITA, users can automate much of the analysis process, allowing for quicker response times to potential threats.

While this skill is powerful for detecting DNS tunneling, it requires a solid understanding of network traffic analysis and the ability to interpret the results effectively. Users should be familiar with Zeek and have the necessary infrastructure in place for log analysis to maximize the benefits of this skill.

When to use it

Use this skill when you suspect data exfiltration over DNS or when threat intelligence indicates potential attacks targeting your organization.

When not to use it

This skill may not be suitable for environments where DNS traffic is not monitored or where Zeek is not deployed, as it relies heavily on dns.log data.

What you can build with it

Investigating Suspicious DNS Queries

Use this skill to analyze dns.log for unusual query patterns after detecting high query volumes to specific domains.

Threat Intelligence Correlation

Employ this skill when threat intelligence indicates potential DNS-based command-and-control frameworks targeting your industry.

Monitoring for Data Exfiltration

Implement this skill during investigations of suspected data theft, particularly when HTTP/S exfiltration is not evident.

How to install DNS Tunneling Detection with Zeek

View source

1. Install with the skills CLI

npx skills add mukul975/anthropic-cybersecurity-skills/hunting-for-dns-tunneling-with-zeek --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by mukul975

Hunting for DNS Tunneling with Zeek

When to Use

  • When hunting for data exfiltration over DNS covert channels
  • After threat intelligence indicates DNS-based C2 frameworks targeting your industry
  • When dns.log shows unusually high query volumes to specific domains
  • During investigation of suspected data theft where no HTTP/S exfiltration is found
  • When monitoring for tools like iodine, dnscat2, DNSExfiltrator, or DNS-over-HTTPS tunneling

Prerequisites

  • Zeek deployed on network tap or SPAN port capturing DNS traffic
  • Zeek dns.log with full query and response fields
  • SIEM platform for dns.log analysis (Splunk, Elastic)
  • RITA (Real Intelligence Threat Analytics) for automated DNS analysis
  • Passive DNS data for historical domain resolution context

Workflow

  1. Analyze Query Length Distribution: DNS tunneling encodes data in subdomain labels, producing queries significantly longer than normal. Normal DNS queries average 20-30 characters; tunneling queries often exceed 50+ characters. Calculate mean and standard deviation of query lengths per domain.
  2. Calculate Subdomain Entropy: Tunneling encodes data using Base32/Base64, producing high-entropy subdomain strings. Calculate Shannon entropy of subdomain labels -- values above 3.5 bits/character strongly suggest encoded data.
  3. Count Unique Subdomains Per Domain: Legitimate domains have relatively few unique subdomains. DNS tunneling generates hundreds or thousands of unique subdomains under a single parent domain.
  4. Monitor DNS Record Type Distribution: TXT, NULL, CNAME, and MX records can carry more data than A records. Excessive TXT queries to a single domain indicate data transfer via DNS.
  5. Detect High Query Volume: Flag domains receiving more than 100 queries per hour from a single source, especially when combined with high subdomain uniqueness.
  6. Analyze Query Timing: DNS tunneling tools produce regular query patterns (beaconing) or burst patterns (data transfer). Apply frequency analysis to DNS query timestamps.
  7. Cross-Reference with conn.log: Correlate DNS queries with connection metadata to identify the process or endpoint generating suspicious queries.
  8. Validate with Domain Intelligence: Check suspicious domains against WHOIS data, certificate transparency, and threat intelligence feeds.

Key Concepts

ConceptDescription
T1071.004Application Layer Protocol: DNS
T1048.003Exfiltration Over Alternative Protocol: DNS
T1572Protocol Tunneling
Shannon EntropyMeasure of randomness in subdomain strings
Zeek dns.logDNS query/response metadata
RITAAutomated DNS tunneling detection from Zeek logs
iodineIPv4-over-DNS tunneling tool
dnscat2DNS-based command-and-control tool
DNSExfiltratorData exfiltration tool using DNS requests

Detection Queries

Zeek Script -- DNS Tunnel Detection

@load base/protocols/dns
module DNSTunnel;

export {
    redef enum Notice::Type += { DNSTunnel::Long_DNS_Query };
    const query_length_threshold = 50 &redef;
    const query_count_threshold = 100 &redef;
}

event dns_request(c: connection, msg: dns_msg, query: string, qtype: count, qclass: count) {
    if ( |query| > query_length_threshold ) {
        NOTICE([$note=DNSTunnel::Long_DNS_Query,
                $msg=fmt("Long DNS query detected: %s (%d chars)", query, |query|),
                $conn=c]);
    }
}

Splunk -- DNS Tunneling Indicators from Zeek

index=zeek sourcetype=bro_dns
| rex field=query "(?<subdomain>[^.]+)\.(?<basedomain>[^.]+\.[^.]+)$"
| stats count dc(subdomain) as unique_subs avg(len(query)) as avg_len max(len(query)) as max_len by src basedomain
| where count > 100 AND (unique_subs > 50 OR avg_len > 40)
| sort -unique_subs

Splunk -- High Entropy Subdomain Detection

index=zeek sourcetype=bro_dns
| rex field=query "^(?<subdomain>[^.]+)"
| where len(subdomain) > 20
| eval char_count=len(subdomain)
| stats count dc(query) as unique_queries avg(char_count) as avg_sub_len by src query_type_name basedomain
| where unique_queries > 30 AND avg_sub_len > 25
| sort -unique_queries

RITA Analysis

rita import /path/to/zeek/logs dataset_name
rita show-dns-fqdn-ips-long dataset_name
rita show-exploded-dns dataset_name
rita show-dns-tunneling dataset_name --csv > dns_tunnel_results.csv

Common Scenarios

  1. dnscat2 C2: Encodes command-and-control traffic in DNS CNAME/TXT queries with Base64-encoded subdomain labels. Produces high query volumes with long, high-entropy subdomains.
  2. iodine IPv4 Tunnel: Creates a virtual network interface tunneling all IP traffic through DNS. Generates massive DNS query volumes with NULL record types.
  3. Data Exfiltration via DNS: Sensitive data encoded in subdomain labels (e.g., aGVsbG8gd29ybGQ.exfil.attacker.com), sent as A or TXT queries. Each query carries ~63 bytes of data.
  4. DNS-over-HTTPS Tunneling: Bypasses traditional DNS monitoring by sending DNS queries over HTTPS to public resolvers (8.8.8.8, 1.1.1.1), requiring TLS inspection for detection.
  5. Cobalt Strike DNS Beacon: Uses DNS A/TXT records for C2 communication with configurable subdomain encoding schemes.

Output Format

Hunt ID: TH-DNSTUNNEL-[DATE]-[SEQ]
Source IP: [Internal IP]
Source Host: [Hostname]
Target Domain: [Base domain]
Query Count: [Total queries in window]
Unique Subdomains: [Count]
Avg Query Length: [Characters]
Max Query Length: [Characters]
Subdomain Entropy: [Bits per character]
Primary Record Type: [A/TXT/CNAME/NULL]
Data Volume Estimate: [Bytes exfiltrated]
Risk Level: [Critical/High/Medium/Low]

Frequently asked questions about DNS Tunneling Detection with Zeek

Similar skills