跳到正文
Skillpedia
分析与电子表格35k · #7824

detecting-dns-exfiltration-with-dns-query-analysis

它能做什么

这个工具通过分析 DNS 流量来查找数据窃取的企图。它会关注数据如何借助 DNS 查询和响应被发送出去的异常模式,这些模式可能说明有恶意工具在使用。

适用场景

  • ✓调查可能的网络数据泄露时。
  • ✓监控网络安全中的可疑活动时。
  • ✓想了解攻击工具如何利用 DNS 时。

技能链接

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-dns-exfiltration-with-dns-query-analysis/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/detecting-dns-exfiltration-with-dns-query-analysis/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“在 DNS 流量中查找可能表明数据外泄的异常活动。”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具会检查 DNS 查询的特征,比如子域名长度、对同一域名的查询次数,以及使用的 DNS 记录类型。然后将这些特征与正常模式进行比较,找出异常。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Detecting DNS Exfiltration with DNS Query Analysis

Overview

DNS exfiltration exploits the Domain Name System as a covert channel to extract data from compromised networks. Attackers encode stolen data into DNS query names (subdomains) or DNS response records (TXT, CNAME, NULL), bypassing traditional security controls that typically allow DNS traffic unrestricted. Tools like iodine, dnscat2, and dns2tcp enable full TCP tunneling over DNS. Detection requires analyzing DNS query patterns for anomalies including excessive query length, high entropy subdomain strings, abnormal query volumes to single domains, and oversized TXT record responses. This skill covers building a comprehensive DNS exfiltration detection capability using passive DNS analysis, statistical methods, and machine learning approaches.

When to Use

  • When investigating security incidents that require detecting dns exfiltration with dns query analysis
  • When building detection rules or threat hunting queries for this domain
  • When SOC analysts need structured procedures for this analysis type
  • When validating security monitoring coverage for related attack techniques

Prerequisites

  • Access to DNS query logs (passive DNS capture, DNS server logs, or PCAP)
  • Zeek, Suricata, or tcpdump for DNS traffic capture
  • Python 3.8+ with scipy, numpy, pandas, and scikit-learn
  • SIEM platform for alert correlation
  • Baseline of normal DNS traffic patterns for the environment

Core Concepts

DNS Tunneling Mechanics

DNS exfiltration encodes data in different parts of DNS messages:

Outbound (Query-based exfiltration):

Encoded data as subdomain labels:
dGhlIHNlY3JldCBkYXRh.exfil.attacker.com
[base64-encoded data].[tunnel domain]

Query types used: A, AAAA, CNAME, MX, TXT, NULL

Inbound (Response-based command channel):

TXT records carry encoded commands/data in responses
CNAME records chain encoded data through multiple labels
NULL records carry arbitrary binary data

Detection Indicators

Indicator Normal DNS DNS Tunneling
Subdomain length 5-20 chars 40-253 chars
Label count 2-4 labels 5-10+ labels
Shannon entropy 2.5-3.5 bits 4.0-5.5 bits
Query volume (per domain) Variable 100s-1000s/min
TXT response size < 100 bytes 200-4000+ bytes
Unique subdomains Low Very high
Query type distribution Mostly A/AAAA Heavy TXT, NULL, CNAME

Common Tunneling Tools

Tool Protocol Encoding Detection Difficulty
iodine IP-over-DNS Base32/Base64/Raw Medium
dnscat2 TCP-over-DNS Hex encoding Medium
dns2tcp TCP-over-DNS Base64 Medium
DNSExfiltrator Custom Base64 Low
Cobalt Strike DNS C2 over DNS Custom encoding High

Workflow

Step 1: Capture DNS Traffic

Using Zeek:

# Live capture
zeek -i eth0 -C base/protocols/dns

# Offline PCAP analysis
zeek -r traffic.pcap base/protocols/dns

# Output: dns.log with query, qtype, answers, TTL

Using tcpdump:

# Capture all DNS traffic
tcpdump -i eth0 -w dns_capture.pcap port 53

# Capture with size filter (large DNS packets)
tcpdump -i eth0 -w large_dns.pcap 'port 53 and greater 512'

Using Suricata:

# In suricata.yaml, enable DNS logging
outputs:
  - eve-log:
      types:
        - dns:
            query: yes
            answer: yes
            formats: [detailed]

Step 2: Analyze Query Characteristics

Python script for DNS exfiltration detection:

#!/usr/bin/env python3
"""DNS Exfiltration Detector - Analyzes DNS logs for tunneling indicators."""

import json
import math
import re
import sys
from collections import defaultdict
from datetime import datetime, timedelta

import pandas as pd


def calculate_entropy(domain: str) -> float:
    """Calculate Shannon entropy of a string."""
    if not domain:
        return 0.0
    freq = defaultdict(int)
    for char in domain:
        freq[char] += 1
    length = len(domain)
    entropy = -sum(
        (count / length) * math.log2(count / length)
        for count in freq.values()
    )
    return entropy


def extract_subdomain(query: str) -> str:
    """Extract subdomain portion from FQDN."""
    parts = query.rstrip('.').split('.')
    if len(parts) > 2:
        return '.'.join(parts[:-2])
    return ''


def get_base_domain(query: str) -> str:

…
常见问题

什么是 DNS 数据外泄?

这是一种攻击手法:攻击者把窃取的数据隐藏在 DNS 查询或响应中,借此绕过防火墙把数据送出网络。

哪些工具会用到这种技术?

常见的工具包括 iodine、dnscat2 和 dns2tcp,它们会建立隧道,通过 DNS 传输数据。

什么是“TXT/CNAME/NULL 记录”?

这些是可以用来承载数据的 DNS 记录类型。攻击者可能会滥用它们来发送或接收信息。

详情

作者的原始描述

Detect data exfiltration via DNS tunneling (tools like iodine, dnscat2, dns2tcp) by analyzing query entropy, subdomain length, query volume to single domains, TXT/CNAME/NULL record abuse, and oversized response payloads using passive DNS monitoring and statistical/ML methods. Use when hunting for covert DNS-based data exfiltration or building a passive DNS anomaly detection capability.

repo: mukul975/Anthropic-Cybersecurity-Skills

热度

GitHub 星标
35k
排名
#7824
许可证
Apache-2.0
更新时间
2026/8/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能