30 Mins

1. Foundations of Packet Capture & Wireshark GUI

Understanding PCAP File Formats

Packet capture files (.pcap and .pcapng) are the digital footprints of network traffic. A .pcap file is the legacy standard, storing raw packet data captured from the wire. The .pcapng (Next Generation) format is the modern successor, capable of storing additional metadata like hardware descriptions, interface settings, and OS details.

When an analyst examines these files, they are looking at the raw byte stream as seen by the Network Interface Card (NIC). Understanding the file structure allows for better forensic data manipulation using tools like TShark.

Security Operator Note: Always prioritize .pcapng for modern captures as it retains critical metadata that .pcap strips away.
Text
tcpdump -i eth0 -w traffic_capture.pcap count 100
tshark -r traffic_capture.pcap -z io,phs
Packet Anatomy Inspector • Encapsulated Frame Protocol Breakdown
Ethernet II Header (14 Bytes) Dst MAC: 00:11:22:33:44:55 | Src MAC: AA:BB:CC:DD:EE:FF | Type: IPv4 (0x0800)
IPv4 Header (20 Bytes) Src IP: 192.168.1.50 | Dst IP: 10.0.0.1 | TTL: 64 | Proto: TCP (6)
TCP Header (20 Bytes) Src Port: 54321 | Dst Port: 80 (HTTP) | Flags: [SYN] | Win: 64240
Application Data Payload (HTTP/1.1 POST Body) Content-Length: 35

POST /login HTTP/1.1\r\nHost: voidx.io\r\n\r\nusername=admin&password=Secret123

Wireshark Interface Layout

The Wireshark GUI is partitioned into three primary panes. The Packet List pane displays the summary of packets in order of capture. The Packet Details pane provides a hierarchical view of the protocols involved (OSI model layers). The Packet Bytes pane provides a hexadecimal and ASCII representation of the selected packet's raw data.

Mastering these panes is essential for identifying anomalies, such as hidden data payloads embedded in ICMP packets or malformed header flags used in DDoS attacks.

Security Operator Note: Use the Display Filter bar at the top with syntax like 'ip.addr == 192.168.1.1' to ignore irrelevant traffic.
Python 3
import struct

def analyze_packet(hex_data):
    # Simulate parsing a simple TCP header (first 20 bytes)
    header = struct.unpack('!HHIIBBHHH', hex_data[:20])
    print(f'Source Port: {header[0]}, Dest Port: {header[1]}')

raw_data = bytes.fromhex('0050005000000001000000005002721000000000')
analyze_packet(raw_data)

Promiscuous Mode vs Normal Capture

Normal capture mode allows your NIC to intercept traffic destined explicitly for your hardware. Promiscuous mode instructs the NIC to pass all traffic it sees on the network segment to the CPU, regardless of the destination MAC address. This is a fundamental requirement for passive network sniffing.

ModeBehavior
NormalCaptures only traffic addressed to the host.
PromiscuousCaptures all visible broadcast and local segment traffic.
Security Operator Note: Promiscuous mode only works on shared segments or hub-based networks; on modern switched networks, you need port mirroring (SPAN) to see traffic not intended for your host.
Text
ip link set eth0 promisc on
# Verify status
ip -d link show eth0 | grep promisc

Installing and Configuring Wireshark & TShark

Deploying Wireshark requires proper permissions because network sniffing is a privileged operation. On Linux, adding your user to the wireshark group is required to grant raw socket access without needing root/sudo permissions for every capture.

TShark is the command-line equivalent of Wireshark, ideal for headless servers or automated incident response pipelines where GUI environments are not available.

Security Operator Note: Never run Wireshark as root. Use group permissions instead to maintain system security hygiene.
Text
# Adding user to capture group on Linux
sudo usermod -aG wireshark $USER
# Verifying TShark installation
tshark --version

Knowledge Check

Ready to test your understanding of 1. Foundations of Packet Capture & Wireshark GUI?

Back