Skip to main content
skill CX Codex

analyzing-network-covert-channels-in-malware — Claude Code skill

Reads a PCAP for DNS tunneling, ICMP exfiltration and C2 hidden in HTTP. Useful during incident response or a hunt for exfiltration channels.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-network-covert-channels-in-malware -a claude-code
Open on GitHub

What analyzing-network-covert-channels-in-malware does

The skill hands your agent a procedure for finding covert channels in a network capture. It scores domains on subdomain entropy, query length, uniqueness and TXT share, and scores ICMP flows on payload size and frequency. Each suspicious domain or flow comes back with a score and the reasons behind it.

Under the hood is a Python script built on scapy. It loads the capture with rdpcap and prints findings to the console, so a run looks like python script.py <pcap_file>. You need Python 3.9+ with scapy, dpkt and dnslib, plus Wireshark or tshark and Zeek for monitoring. If scapy is missing, the script exits right away and points you at pip install scapy.

A score threshold of 50 filters out noise, but low-throughput exfiltration still slips past this kind of scoring. That is the reason to watch longer windows instead of one short capture. The analysis assumes you can read DNS, ICMP and HTTP at the packet level; without that, the script's output is easy to dismiss as false positives.

What it helps with

  • spot a DNS tunnel inside a traffic capture
  • separate ICMP exfiltration from ordinary ping traffic
  • rank a domain's suspicion by subdomain entropy
  • build evidence for a covert C2 channel
  • validate monitoring coverage for MITRE ATT&CK techniques

Example prompts for the agent

  • Analyze capture.pcap for DNS tunneling and list the highest-scoring domains
  • Check the ICMP flows in this capture for tunneling signs
  • Walk through this suspicious traffic and explain why the domain was flagged

How to install analyzing-network-covert-channels-in-malware

1Skills CLI (Vercel)

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-network-covert-channels-in-malware -a claude-code

2Manually: put the files in place

~/.claude/skills/analyzing-network-covert-channels-in-malware/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/analyzing-network-covert-channels-in-malware/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about analyzing-network-covert-channels-in-malware

How do I install analyzing-network-covert-channels-in-malware in Claude?

Run npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-network-covert-channels-in-malware -a claude-code. The skill lands in ~/.claude/skills/analyzing-network-covert-channels-in-malware/SKILL.md.

What does this skill do?

It looks for covert channel indicators in a network capture: DNS tunnels, ICMP exfiltration, C2 embedded in HTTP. Every suspicious domain or flow gets a score with the reasons listed.

What do I need to run it?

Python 3.9+ with scapy, dpkt and dnslib, plus Wireshark or tshark and Zeek for analysis and monitoring. You also need packet-level familiarity with DNS, ICMP and HTTP.

Source text

SKILL.md · Apache-2.0
---
name: analyzing-network-covert-channels-in-malware
description: Detect and analyze covert communication channels used by malware, including
  DNS tunneling, ICMP exfiltration, steganographic HTTP, and other protocol abuse
  used for C2 and data exfiltration. Use when investigating suspicious DNS/ICMP/HTTP
  traffic patterns, hunting for hidden C2 channels in network captures, or attributing
  exfiltration traffic to a known tunneling toolset.
domain: cybersecurity
subdomain: malware-analysis
tags:
- covert-channels
- dns-tunneling
- icmp-exfiltration
- malware-analysis
- network-forensics
- c2-detection
- data-exfiltration
version: '1.0'
author: mahipal
license: Apache-2.0
d3fend_techniques:
- File Metadata Consistency Validation
- Certificate Analysis
- Application Protocol Command Analysis
- Content Format Conversion
- File Content Analysis
nist_csf:
- DE.AE-02
- RS.AN-03
- ID.RA-01
- DE.CM-01
mitre_attack:
- T1071.001
- T1095
- T1572
- T1001
---
# Analyzing Network Covert Channels in Malware

## Overview

Malware uses covert channels to disguise C2 communication and data exfiltration within legitimate-looking network traffic. DNS tunneling encodes data in DNS queries and responses (used by tools like iodine, dnscat2, and malware families like FrameworkPOS). ICMP tunneling hides data in echo request/reply payloads (icmpsh, ptunnel). HTTP covert channels embed C2 data in headers, cookies, or steganographic images. Protocol abuse exploits allowed protocols to bypass firewalls. DNS tunneling detection achieves 99%+ recall with modern ML-based approaches, though low-throughput exfiltration remains challenging. Palo Alto Unit42 tracked three major DNS tunneling campaigns (TrkCdn, SecShow, Savvy Seahorse) through 2024, showing the technique's continued prevalence.


## When to Use

- When investigating security incidents that require analyzing network covert channels in malware
- 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

- Python 3.9+ with `scapy`, `dpkt`, `dnslib`
- Wireshark/tshark for PCAP analysis
- Zeek (formerly Bro) for network monitoring
- DNS query logging infrastructure
- Understanding of DNS, ICMP, HTTP protocols at packet level

## Workflow

### Step 1: DNS Tunneling Detection

```python
#!/usr/bin/env python3
"""Detect DNS tunneling and covert channels in network traffic."""
import sys
import json
import math
from collections import Counter, defaultdict

try:
    from scapy.all import rdpcap, DNS, DNSQR, DNSRR, IP, ICMP
except ImportError:
    print("pip install scapy")
    sys.exit(1)


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


def analyze_dns_tunneling(pcap_path):
    """Detect DNS tunneling indicators in PCAP."""
    packets = rdpcap(pcap_path)
    domain_stats = defaultdict(lambda: {
        "queries": 0, "total_qname_len": 0, "subdomain_lengths": [],
        "query_types": Counter(), "unique_subdomains": set(),
    })

    for pkt in packets:
        if pkt.haslayer(DNS) and pkt.haslayer(DNSQR):
            qname = pkt[DNSQR].qname.decode('utf-8', errors='replace').rstrip('.')
            qtype = pkt[DNSQR].qtype

            parts = qname.split('.')
            if len(parts) >= 3:
                base_domain = '.'.join(parts[-2:])
                subdomain = '.'.join(parts[:-2])

                stats = domain_stats[base_domain]
                stats["queries"] += 1
                stats["total_qname_len"] += len(qname)
                stats["subdomain_lengths"].append(len(subdomain))
                stats["query_types"][qtype] += 1
                stats["unique_subdomains"].add(subdomain)

    # Score domains for tunneling indicators
    suspicious = []
    for domain, stats in domain_stats.items():
        if stats["queries"] < 5:
            continue

        avg_subdomain_len = (sum(stats["subdomain_lengths"]) /
                             len(stats["subdomain_lengths"]))
        unique_ratio = len(stats["unique_subdomains"]) / stats["queries"]

        # Calculate subdomain entropy
        all_subdomains = ''.join(stats["unique_subdomains"])
        sub_entropy = entropy(all_subdomains)

        score = 0
        reasons = []

        if avg_subdomain_len > 30:
            score += 30
            reasons.append(f"Long subdomains (avg {avg_subdomain_len:.0f} chars)")
        if unique_ratio > 0.9:
            score += 25
            reasons.append(f"High uniqueness ({unique_ratio:.2%})")
        if sub_entropy > 4.0:
            score += 25
            reasons.append(f"High entropy ({sub_entropy:.2f})")
        if stats["query_types"].get(16, 0) > 10:  # TXT records
            score += 20
            reasons.append(f"Many TXT queries ({stats['query_types'][16]})")

        if score >= 50:
            suspicious.append({
                "domain": domain,
                "score": score,
                "queries": stats["queries"],
                "avg_subdomain_length": round(avg_subdomain_len, 1),
                "unique_subdomains": len(stats["unique_subdomains"]),
                "subdomain_entropy": round(sub_entropy, 2),
                "reasons": reasons,
            })

    return sorted(suspicious, key=lambda x: -x["score"])


def analyze_icmp_tunneling(pcap_path):
    """Detect ICMP tunneling in PCAP."""
    packets = rdpcap(pcap_path)
    icmp_stats = defaultdict(lambda: {"count": 0, "payload_sizes": [], "payloads": []})

    for pkt in packets:
        if pkt.haslayer(ICMP) and pkt.haslayer(IP):
            src = pkt[IP].src
            dst = pkt[IP].dst
            key = f"{src}->{dst}"

            payload = bytes(pkt[ICMP].payload)
            icmp_stats[key]["count"] += 1
            icmp_stats[key]["payload_sizes"].append(len(payload))
            if len(payload) > 64:
                icmp_stats[key]["payloads"].append(payload[:100])

    suspicious = []
    for flow, stats in icmp_stats.items():
        if stats["count"] < 5:
            continue
        avg_size = sum(stats["payload_sizes"]) / len(stats["payload_sizes"])
        if avg_size > 64 or stats["count"] > 100:
            suspicious.append({
                "flow": flow,
                "packets": stats["count"],
                "avg_payload_size": round(avg_size, 1),
                "reason": "Large/frequent ICMP payloads suggest tunneling",
            })

    return suspicious


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print(f"Usage: {sys.argv[0]} <pcap_file>")
        sys.exit(1)

    print("[+] DNS Tunneling Analysis")
    dns_results = analyze_dns_tunneling(sys.argv[1])
    for r in dns_results:
        print(f"  {r['domain']} (score: {r['score']})")
        for reason in r['reasons']:
            print(f"    - {reason}")

    print("\n[+] ICMP Tunneling Analysis")
    icmp_results = analyze_icmp_tunneling(sys.argv[1])
    for r in icmp_results:
        print(f"  {r['flow']}: {r['reason']}")
```

## Validation Criteria

- DNS tunneling detected via entropy, subdomain length, and query volume analysis
- ICMP covert channels identified through payload size anomalies
- Tunneling domains distinguished from legitimate CDN/cloud traffic
- Data exfiltration volume estimated from captured traffic
- C2 communication patterns and beaconing intervals extracted

## References

- [Palo Alto Unit42 - DNS Tunneling Campaigns](https://unit42.paloaltonetworks.com/three-dns-tunneling-campaigns/)
- [Elastic - Detecting Covert Data Exfiltration](https://www.elastic.co/blog/elastic-security-detecting-covert-data-exfiltration)
- [Vectra AI - ICMP Tunnel Detection](https://www.vectra.ai/detections/icmp-tunnel)
- [MITRE ATT&CK T1071 - Application Layer Protocol](https://attack.mitre.org/techniques/T1071/)

© mahipal · Apache-2.0 · mukul975/Anthropic-Cybersecurity-Skills

Similar skills

Everything for Security →

From the same set89

analyzing-cobalt-strike-beacon-configuration This skill extracts Cobalt Strike Beacon configuration from PE files and memory dumps. Use it to inspect C2 infrastructure, malleable C2 settings, and operator clues. CX Codex +1 404installs analyzing-ethereum-smart-contract-vulnerabilities Runs static and symbolic analysis on Solidity smart contracts using Slither and Mythril. Catches reentrancy, integer overflows, and access flaws before deployment. CX Codex +1 393installs analyzing-malicious-pdf-with-peepdf This skill statically inspects suspicious PDFs with peepdf, pdfid.py, and pdf-parser.py. Use it to triage attachments, inspect exploit documents, and collect detection indicators. CX Codex +1 387installs testing-api-for-mass-assignment-vulnerability Tests APIs for mass assignment by adding undocumented request fields and checking whether they persist. Use it for profile, registration, and object-creation endpoints. CX Codex +1 385installs analyzing-network-flow-data-with-netflow This skill parses NetFlow v9 and IPFIX records to spot volumetric anomalies, port scanning, data exfiltration and C2 beaconing. CX Codex +1 372installs analyzing-heap-spray-exploitation A skill that reads memory dumps and finds heap spray artifacts: NOP sleds, executable injected regions and embedded shellcode. CX Codex +1 372installs analyzing-malware-sandbox-evasion-techniques Reads Cuckoo and AnyRun behavioral reports and flags the signs that a sample spotted the sandbox and played dead. CX Codex +1 363installs exploiting-idor-vulnerabilities Guides authorized testing of IDOR vulnerabilities across API endpoints using Burp Suite, the Authorize extension, and curl scripts. CX Codex +1 365installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor