本文へスキップ
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に貼り付けるだけ。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をインストール。1行で、作業の前に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

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル