courses

Network Forensics: Acquisition, Analysis, and Detection

Network Evidence Acquisition

Application-Layer Protocols

Understanding common application-layer protocols is necessary to recognize what traffic contains and to reconstruct user activity from packet captures.

HTTP uses a request-response model. Key methods:

Method Purpose
GET Retrieve a resource
POST Submit data to a server
HEAD Retrieve headers only (no body)
PUT Upload a resource
DELETE Delete a resource
OPTIONS Query supported methods

HTTP is cleartext; all headers, URLs, and payloads are readable in a capture without decryption. Response codes (200 OK, 301 Redirect, 404 Not Found, 500 Server Error) provide behavioral context.

DHCP assigns IP addresses dynamically via a four-step handshake:

  1. DISCOVER — client broadcasts to find DHCP servers
  2. OFFER — server offers an IP address
  3. REQUEST — client requests the offered address
  4. ACK — server confirms the lease

DHCP logs link an IP address to a MAC address at a specific time, allowing an investigator to identify which physical device used an IP seen in other logs.

SMTP (Simple Mail Transfer Protocol) uses human-readable commands to transfer email:

Command Function
HELO / EHLO Identify sending server
MAIL FROM Specify sender address
RCPT TO Specify recipient address
DATA Begin message body
QUIT End session

SMTP traffic may carry email body content and attachments encoded in Base64. These can be decoded directly from a packet capture.

Case study: In a network investigation, an analyst used Wireshark to capture SMTP traffic and observed Base64-encoded content in the DATA portion of a session. Decoding the content revealed an attachment that constituted evidence of data exfiltration.

Physical Acquisition Methods

Wired networks:

Wireless networks:

Hub vs. switch considerations:

libpcap and BPF

libpcap (and its Windows counterpart WinPcap/Npcap) is the standard capture library. It provides a portable API for capturing packets from a network interface and applies BPF (Berkeley Packet Filter) expressions to filter which packets are captured.

BPF filters are evaluated in-kernel before packets are copied to user space, minimizing overhead. Common primitives:

host 10.0.0.1
net 192.168.0.0/24
port 80
tcp
udp
src host 10.0.0.5 and dst port 443
not broadcast and not multicast

tcpdump is the primary command-line tool built on libpcap:

tcpdump -i eth0 -w capture.pcap 'host 10.0.0.1 and port 80'
tcpdump -r capture.pcap -nn 'tcp[tcpflags] & tcp-syn != 0'

Active Acquisition

When passive capture is not feasible, investigators may collect logs and configurations directly from network devices using remote access protocols:

Active acquisition involves authenticating to the target device, which creates log entries and may alert administrators. It requires proper authorization.

Evidence Collection Strategy

Priority hierarchy: collect in order of decreasing value and decreasing volatility.

Priority Source Why
1 (highest) Full packet capture (pcap) Contains everything — payloads, exact timing, reassembly possible
2 NetFlow / IPFIX records Header-only; payloads gone but flow metadata survives
3 Application and system logs Summarized events; richness depends on logging configuration
4 (lowest) Firewall/router ACL hit counters Only indicates traffic was permitted or denied; no content

Protocol and Statistical Flow Analysis

Protocol Analysis

Protocol analysis reconstructs what happened on a network by examining the content and structure of individual packets.

Header identification: each protocol header appears at a predictable offset. Given raw packet bytes, an analyst can identify the Ethernet, IP, TCP/UDP, and application headers sequentially and extract fields of interest.

Port numbers: well-known ports identify the application protocol in use (port 80 = HTTP, 443 = HTTPS, 25 = SMTP, 53 = DNS, 22 = SSH). Non-standard ports may indicate tunneling or obfuscation. IANA maintains the authoritative port registry.

WHOIS: a query tool for IP address and domain name registration records. Useful for identifying who owns an IP address range or domain seen in captured traffic.

Packet dissection example — reading hex dumps:

A raw IP packet begins with the IP header (version, IHL, DSCP, length, ID, flags, fragment offset, TTL, protocol, checksum, source IP, destination IP), followed by the transport header (TCP or UDP), followed by the payload. Forensics tools and tcpdump -X display packets in hex+ASCII format, allowing manual field identification.

Packet Analysis Techniques

Pattern matching: search packet payloads for specific strings or byte sequences. Unlike packet filtering (which decides whether to capture a packet), pattern matching searches inside captured packets for content of interest.

ngrep: a packet capture tool that applies regular expressions to packet payloads. Useful for finding specific strings in cleartext protocols:

ngrep -d eth0 'password' 'tcp port 23'
ngrep -I capture.pcap 'USER|PASS'

tcpdump with byte offsets: BPF allows filtering on specific byte values at specific offsets. For example, to match HTTP GET requests:

tcp[20:4] = 0x47455420

(0x47455420 is the ASCII encoding of “GET “)

Flow Analysis

A flow (or session) is defined by a 5-tuple:

  1. Source IP address
  2. Destination IP address
  3. Source port
  4. Destination port
  5. Protocol (TCP/UDP/ICMP)

Flow analysis aggregates packets into sessions, allowing analysis at a higher level of abstraction than individual packets. It is more scalable — flow records are far smaller than full packet captures.

Tools for flow reconstruction from pcap files:

Flow Record Processing Architecture

Large networks use a distributed architecture for flow collection:

[Sensors] → [Collectors] → [Aggregators] → [Analysis]

Flow Analysis Techniques

Common Malicious Traffic Patterns

Pattern Description Example
Many-to-one Multiple sources targeting one destination DDoS attack
One-to-many One source contacting many destinations Port scan, network worm
Many-to-many Many sources, many destinations P2P file sharing, virus spreading
One-to-one (sustained) Persistent session between two hosts Targeted exfiltration, C2 channel

Network Intrusion Detection and Prevention Systems

Functionality

A Network Intrusion Detection System (NIDS) monitors network traffic and generates alerts when it detects patterns matching known attacks or policy violations. A NIPS goes further, blocking or modifying suspicious traffic inline.

A NIDS typically provides:

Detection Modes

Signature-based detection: compares packets or streams against a database of known attack patterns. Fast and precise for known threats; blind to novel attacks.

Protocol awareness: the NIDS understands application protocol structure and can detect anomalies — e.g., HTTP requests with invalid headers, DNS responses that exceed expected sizes, or FTP commands used in unusual sequences.

Behavioral/statistical detection: establishes a baseline of normal traffic and alerts on deviations — e.g., a sudden spike in outbound connections, unusual port activity, or traffic to known-malicious IP ranges.

Evidence from NIDS/NIPS

A NIDS deployment provides several categories of forensic evidence:

Comprehensive packet logging: many NIDS deployments are configured to log all packets, not just alerting ones. This creates a full packet capture of all network traffic, which is the most complete possible forensic record — but requires significant storage.

Snort

Snort is the most widely deployed open-source NIDS. It has three operational modes:

  1. Sniffer mode: displays packets to the console (like tcpdump)
  2. Packet logger mode: writes packets to disk
  3. NIDS mode: applies rules and generates alerts

Snort architecture:

Packet capture (libpcap)
        ↓
Packet decoder
        ↓
Preprocessors (stream reassembly, protocol normalization)
        ↓
Detection engine (rule matching)
        ↓
Output plugins (alert logs, pcap, syslog, database)

Snort Rule Language

A Snort rule has two parts: a header and a body (rule options).

Rule header:

action  protocol  src_ip  src_port  direction  dst_ip  dst_port

Example:

alert tcp any any -> 192.168.1.0/24 80 (msg:"HTTP traffic"; sid:1000001;)
Field Values / Notes
action alert, log, pass, drop (NIPS), reject (NIPS)
protocol tcp, udp, icmp, ip
direction -> (unidirectional), <> (bidirectional)
src/dst IP IP address, CIDR range, any, negation with !
src/dst port port number, range (1:1024), any

Rule body options (selected):

General options:

Option Purpose
msg Human-readable alert message
sid Snort rule ID (unique identifier)
rev Rule revision number
classtype Attack classification (e.g., trojan-activity)
priority Alert severity (1 = highest)

Detection options:

Option Purpose
content Match a literal byte string in the payload
pcre Match a Perl-compatible regular expression
offset Start searching at this byte offset
depth Search only within this many bytes
nocase Case-insensitive content match
flags Match specific TCP flags
ttl Match a specific IP TTL value
dsize Match payload size

Post-detection options:

Option Purpose
logto Write alert to a specific log file
react Block and send a response (NIPS)
tag Continue logging packets after the alert

Example rule analysis:

alert tcp $EXTERNAL_NET any -> $HOME_NET 445 \
(msg:"MS17-010 EternalBlue SMB RCE attempt"; \
flow:to_server,established; \
content:"|FF|SMB|73|"; depth:8; offset:4; \
content:"PC NETWORK PROGRAM"; \
pcre:"/\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\x53\x4d\x42/"; \
classtype:attempted-admin; sid:41978; rev:5;)

Reading this rule:

Other NIDS Platforms


Summary

Topic Key Tools / Concepts
Passive capture libpcap, tcpdump, Wireshark, hardware taps
Active acquisition SSH, SNMP, SCP, TFTP
Wireless capture Monitor mode, promiscuous mode
Switch bypass Mirror/SPAN port, MAC flooding, ARP spoofing
Protocol analysis tcpdump, Wireshark, ngrep, byte-offset BPF filters
Flow analysis tcpflow, Argus, SiLK, Nfdump
NIDS Snort, Zeek/Bro, Suricata
Pattern matching Snort rules: content, pcre, flags, dsize
Traffic patterns DDoS (many→one), scan (one→many), P2P (many→many), exfil (one→one)