mcpField
P
performing-dns-tunneling-detection

performing-dns-tunneling-detection

github.com/mukul975Security35.2k59 installsUpdated 8w ago
Repository

About performing-dns-tunneling-detection

A DNS tunneling detection skill for security operations and incident response teams. It uses entropy and statistical analysis of DNS query names to flag suspicious traffic, with Python and packet-capture examples.

Key features

  1. 01Calculate Shannon entropy of query names
  2. 02Detect unusually long query names
  3. 03Count TXT requests and unique subdomains
  4. 04Inspect character distributions in labels
  5. 05Analyze PCAP files with Scapy

Use cases

  1. 01Investigate suspicious DNS traffic during incident response
  2. 02Validate detection controls in an authorized test environment

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-dns-tunneling-detection

After installing, type/performing-dns-tunneling-detectionin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

LICENSE
references/
api-reference.md
scripts/
agent.py

Details

From the project README

Performing DNS Tunneling Detection

When to Use

  • When conducting security assessments that involve performing dns tunneling detection
  • When following incident response procedures for related security events
  • When performing scheduled security testing or auditing activities
  • When validating security controls through hands-on testing

Prerequisites

  • Familiarity with security operations concepts and tools
  • Access to a test or lab environment for safe execution
  • Python 3.8+ with required dependencies installed
  • Appropriate authorization for any testing activities

Instructions

Analyze DNS traffic for indicators of DNS tunneling using entropy analysis and statistical methods on query name characteristics.

import math
from collections import Counter

def shannon_entropy(data):
    if not data:
        return 0
    counter = Counter(data)
    length = len(data)
    return -sum((c/length) * math.log2(c/length) for c in counter.values())

# Legitimate domain: low entropy (~3.0-3.5)
print(shannon_entropy("www.google.com"))
# DNS tunnel: high entropy (~4.0-5.0)
print(shannon_entropy("aGVsbG8gd29ybGQ.tunnel.example.com"))

Key detection indicators:

  1. High Shannon entropy in query names (> 3.5 for subdomain labels)
  2. Unusually long query names (> 50 characters)
  3. High volume of TXT record requests to a single domain
  4. High unique subdomain count per parent domain
  5. Non-standard character distribution in labels

Examples

from scapy.all import rdpcap, DNS, DNSQR
packets = rdpcap("dns_traffic.pcap")
for pkt in packets:
    if pkt.haslayer(DNSQR):
        query = pkt[DNSQR].qname.decode()
        entropy = shannon_entropy(query)
        if entropy > 4.0:
            print(f"Suspicious: {query} (entropy={entropy:.2f})")

Comments

Markdown supported