# Network Forensics

> Use when investigating network traffic from a packet capture or flow record during an authorized incident response or forensic examination. Covers pcap triage with tshark and tcpdump, Zeek connection and DNS logs, TLS and HTTP artifact recovery, DNS tunneling and beaconing detection, and building a network timeline that corroborates host evidence. Use when a host looks compromised, when data exfiltration is suspected, or when you need to prove what a system sent and received and when.

- Skill: `mizazhaider-ceh/network-forensics` (Agent Skill)
- Install (CLI): `npx get-skill add mizazhaider-ceh/network-forensics`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mizazhaider-ceh/network-forensics/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: mizazhaider-ceh (https://skillmd.com/u/mizazhaider-ceh)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/mizazhaider-ceh/network-forensics

---


Network forensics answers what crossed the wire, and it does so from copies
of captures, never from live interception of traffic you have no authority
to collect. A pcap is a time-ordered record of packets, and Zeek turns that
record into structured logs for connections, DNS, HTTP, TLS, and files. The
discipline is the same as disk forensics. Hash the capture, work on a copy,
normalize timestamps to UTC, and tie every claim to a packet number, a flow,
or a log line. Scope: analyze captures you are authorized to handle, such as
your own lab traffic, captures supplied under an investigation, or CTF
files. Treat captures as sensitive, because they can contain credentials,
private messages, and internal addresses.

## Quick Workflow

1. Hash the capture and record its time range, capture point, and filter.
2. Get the capture summary: protocol hierarchy, top talkers, and endpoints.
3. Extract Zeek logs or tshark fields for connections, DNS, HTTP, and TLS.
4. Hunt the suspicious pattern: beaconing intervals, odd DNS names, large
   uploads, and connections to rare external addresses.
5. Follow the interesting streams: reassemble HTTP objects and DNS queries.
6. Extract files and indicators: hashes, URLs, domains, IPs, and JA3 hashes
   where the TLS handshake is visible.
7. Correlate with host evidence: process start times, log entries, and disk
   artifacts must line up with the network events.
8. Report with UTC timestamps, packet or flow references, and the limits of
   what encryption hid from view.

## 1. Capture integrity and summary

```bash
# Hash the capture before analysis, and keep the original untouched
sha256sum case01_traffic.pcapng
cp case01_traffic.pcapng case01_work.pcapng

# Time range and packet count in one pass
capinfos case01_work.pcapng

# Protocol hierarchy and top talkers
tshark -r case01_work.pcapng -q -z io,phs
tshark -r case01_work.pcapng -q -z endpoints,ip
tshark -r case01_work.pcapng -q -z conv,ip
```

A capture whose time range does not cover the incident window is a finding
in itself. Note the gap, do not silently extrapolate beyond it. If the
capture was truncated by a snapshot length, payloads may be cut off, and
file extraction from it will be incomplete.

## 2. Triage with tshark display filters

```bash
# DNS queries only, with query name and type
tshark -r case01_work.pcapng -Y "dns.flags.response == 0" \
  -T fields -e frame.time_epoch -e ip.src -e dns.qry.name -e dns.qry.type

# HTTP requests and responses, with host, method, and status
tshark -r case01_work.pcapng -Y "http" \
  -T fields -e frame.time_epoch -e ip.src -e http.request.method \
  -e http.host -e http.request.uri -e http.response.code

# TLS handshakes: server name indication and negotiated version
tshark -r case01_work.pcapng -Y "tls.handshake.type == 1 or tls.handshake.type == 2" \
  -T fields -e frame.time_epoch -e ip.src -e ip.dst -e tls.handshake.extensions_server_name \
  -e tls.handshake.version

# Follow one TCP stream to read the full conversation
tshark -r case01_work.pcapng -q -z follow,tcp,ascii,3
```

Read the filter before trusting the output. A filter that is too narrow
hides the surrounding traffic that proves whether a connection was normal
or anomalous. Always check the unfiltered conversation count for the host
before concluding that a single stream was the whole story.

## 3. Zeek logs for structured hunting

```bash
# Generate Zeek logs from a pcap into a separate output directory
mkdir -p /evidence/case01/zeek
zeek -r case01_work.pcapng -C /evidence/case01/zeek

# Top external destinations by connection count
cat /evidence/case01/zeek/conn.log | zeek-cut id.resp_h | sort | uniq -c | sort -nr | head -20

# DNS queries that returned no answer or an unusual type
cat /evidence/case01/zeek/dns.log | zeek-cut ts query qtype_name rcode_name | grep -v "NOERROR" | head -40

# Files seen on the wire, with hashes where Zeek could compute them
cat /evidence/case01/zeek/files.log | zeek-cut ts tx_hosts mime_type md5 sha256 | head -40
```

Zeek logs are only as complete as the capture. Encrypted traffic still
yields connection metadata, DNS, TLS handshake fields, and certificate
details, but not plaintext content. Say so explicitly in the report rather
than implying that encryption was broken.

## 4. Beaconing and exfiltration checks

```bash
# Per-destination connection intervals with Python, to spot regular beacons
python3 - <<'PY'
import collections, statistics
from datetime import datetime, timezone
flows = collections.defaultdict(list)
with open("/evidence/case01/zeek/conn.log") as fh:
    for line in fh:
        if line.startswith("#") or not line.strip():
            continue
        parts = line.rstrip("\n").split("\t")
        if len(parts) < 10:
            continue
        try:
            ts = float(parts[0])
        except ValueError:
            continue
        flows[(parts[2], parts[4])].append(ts)
for (src, dst), times in sorted(flows.items()):
    if len(times) < 10:
        continue
    times.sort()
    gaps = [b - a for a, b in zip(times, times[1:])]
    print(src, dst, "count", len(times),
          "median_gap_s", round(statistics.median(gaps), 1),
          "stdev_s", round(statistics.pstdev(gaps), 1))
PY

# Large uploads: total bytes sent per destination, largest first
tshark -r case01_work.pcapng -q -z conv,ip | sort -k 10 -nr | head -20

# Extract HTTP objects for hashing and further analysis
tshark -r case01_work.pcapng --export-objects http,/evidence/case01/http_objects
ls -l /evidence/case01/http_objects
sha256sum /evidence/case01/http_objects/* 2>/dev/null | head -40
```

Regular intervals with low variance are a beaconing signal, not proof of
malware on their own. Scheduled updates, keepalives, and polling services
beacon too. Compare the destination against known-good traffic from the
same host before calling it malicious, and check whether the beacon
started at the same time as a suspicious process or download.

## Edge cases

- The capture starts after the intrusion. Host logs, proxy logs, and flow
  records may still cover the missing window, so pivot to those sources
  instead of claiming the network was quiet.
- Traffic is fully encrypted and no TLS handshake details survive. Use
  connection size, timing, DNS, and destination reputation, and state the
  plaintext gap plainly.
- The capture contains NAT addresses. Internal hosts behind one public
  address cannot be separated from the pcap alone, so correlate with host
  logs or firewall records to attribute a flow.
- DNS over HTTPS or DNS over TLS hides queries from a passive capture.
  Endpoint DNS cache artifacts and proxy logs become the primary source.
- Clock skew between the capture host and the endpoints shifts times.
  Anchor the timeline with an event seen in both sources, such as a known
  login, and record the offset applied.

## Key references

- NIST SP 800-86 (Guide to Integrating Forensic Techniques into Incident
  Response).
- RFC 3227 (Guidelines for Evidence Collection and Archiving).
- Wireshark documentation on display filters and protocol dissection.
- Zeek documentation on connection, DNS, HTTP, TLS, and files logs.

## See also

- `ctf-forensics-challenges-pcap-analysis`: Use it instead for the competition version, framed around analyzing a packet capture to find a flag.

