Перейти к основному содержимому
Wireshark Deep Packet Inspection & Stream Reassembly
Урок 3 из 12

Wireshark Deep Packet Inspection & Stream Reassembly

Learn how to isolate conversations with Wireshark display filters, reassemble fragmented TCP streams, and safely extract transferred HTTP and SMB objects using Wireshark and tshark.

Средний 28 мин Сети
Этого урока пока нет на выбранном языке — показана версия на другом языке. Перевод готовится.
Только в разрешённой среде — Описанные здесь приёмы применяются только в учебных лабораториях и в системах, которые принадлежат вам или на которые есть письменное разрешение.

Цели обучения

  • Narrow large packet captures to relevant hosts and protocols using Wireshark display filters
  • Explain how TCP sequence numbers enable accurate stream reassembly
  • Reconstruct application conversations with Follow TCP Stream and Follow HTTP Stream
  • Extract transferred HTTP and SMB objects safely with Wireshark and tshark

Рекомендуется заранее: Network Security Fundamentals & Protocol WeaknessesСканирование сети и перечисление сервисов с помощью Nmap

#Why this matters

Real packet captures rarely contain one neat request and one neat response. A single capture from a lab host or network tap can hold thousands of ARP broadcasts, DNS lookups, and TLS handshakes, while the file transfer you actually need to inspect is split across dozens of TCP segments.

Reading frames one by one wastes time and hides context. Deep packet inspection (DPI) and stream reassembly let analysts filter out background noise, put fragmented segments back in order, and recover transferred payloads cleanly.

#Taming noisy captures with display filters

Before filtering, get an overview of what is inside the capture. In Wireshark, Statistics -> Protocol Hierarchy lists every protocol by percentage of packets and bytes, and Statistics -> Conversations reveals which IP pairs exchanged the most data.

Once you know the target hosts or protocols, apply a display filter. Unlike capture filters, display filters inspect decoded protocol fields and can be adjusted repeatedly without modifying the file.

Display filter What it isolates
ip.addr == 10.10.10.14 && tcp.port == 445 Traffic to or from 10.10.10.14 over SMB port 445
http.request.method == "POST" HTTP POST uploads or form submissions
smb2.filename SMB2 frames referencing a shared file path
tcp.stream eq 4 Only the fourth TCP conversation in the capture
`!(arp
frame contains "manifest" Case-sensitive byte match anywhere in a frame
  1. TriageProtocol Hierarchy and Conversations
  2. FilterApply display filter to cut noise
  3. ReassembleFollow TCP or HTTP stream
  4. ExtractExport objects and verify SHA-256 hash

#How TCP stream reassembly works

IP networks can split a large response into multiple Maximum Transmission Unit (MTU) segments, deliver them out of order, or trigger retransmissions. TCP solves this with sequence numbers (seq), which track each byte offset in the sender's stream, and acknowledgment numbers (ack), which confirm received bytes.

Reassembling a segmented HTTP responseReassembling a segmented HTTP responseClientServerGET /updates/manifest.json HTTP/1.1[TCP Segment 1, seq=1, len=1460][TCP Segment 2, seq=1461, len=620]Wireshark orders segments by seq and drops duplicate retransmissions

Wireshark groups packets sharing the same four-tuple (source IP, source port, destination IP, destination port) and assigns each conversation a zero-based tcp.stream index. Right-clicking a packet and selecting Follow -> TCP Stream displays the reassembled raw bytes, coloring client data in red and server data in blue.

When analyzing web traffic, Follow -> HTTP Stream goes one step further: it automatically removes chunked transfer-encoding boundaries and decompresses Content-Encoding: gzip bodies so readable text appears instead of binary gibberish.

#Extracting objects with Wireshark and tshark

When you need the exact transferred file rather than a text preview, use object export. In the Wireshark GUI, File -> Export Objects -> HTTP (or SMB) lists every reconstructed file with its hostname, content type, and size, allowing you to save individual files or all objects at once.

For repeatable forensic triage or large captures, tshark performs conversation summaries, stream reconstruction, and object carving directly from the terminal.

Listing conversations, following stream 0, and exporting HTTP objects
$ tshark -r lab_traffic.pcapng -q -z conv,tcp
================================================================================
TCP Conversations
Filter:<No Filter>
                                               |       <-      | |       ->      |
10.10.10.14:51422   <-> 192.0.2.80:80             18      14820    12       1044
$ tshark -r lab_traffic.pcapng -q -z follow,tcp,ascii,0 | head -n 10
===================================================================
Follow: tcp,ascii
Node 0: 10.10.10.14:51422
Node 1: 192.0.2.80:80
102
GET /updates/manifest.json HTTP/1.1
Host: lab.local
User-Agent: curl/8.5.0
Accept: */*

$ tshark -r lab_traffic.pcapng --export-objects http,extracted_http/
$ ls -1 extracted_http/
manifest.json

The same workflow applies to Windows file-share captures using --export-objects smb,extracted_smb/ when SMB traffic is unencrypted. Always check tcp.analysis.lost_segment as well: if packets were dropped during capture, a carved file may be truncated or corrupt.

#Defending and avoiding analysis mistakes

Deep packet inspection has clear limits when modern encryption is enabled. HTTPS with TLS 1.3 and encrypted SMBv3 conceal application headers, filenames, and payloads; without authorised server or client session keys (such as SSLKEYLOGFILE in a controlled test lab), analysts inspect metadata like IP pairs, SNI, ALPN, and byte volumes rather than file contents.

Common analysis mistakes include:

  • Confusing BPF and display filters: Writing port 80 in the display filter bar fails; use tcp.port == 80.
  • Reading compressed HTTP as raw TCP: Selecting Follow TCP Stream on a gzip-encoded response shows unreadable bytes; switch to Follow HTTP Stream or export the object.
  • Ignoring packet loss: Failing to check tcp.analysis.lost_segment can cause analysts to misread truncated files as corrupted originals.
  • Unsafe artifact handling: Double-clicking carved files on the analyst workstation instead of inspecting headers and hashes in an isolated directory.

#Summary

Display filters and conversation statistics cut noisy captures down to the exact hosts and protocols under investigation. Wireshark uses TCP sequence numbers and four-tuples to reassemble fragmented streams into coherent sessions. Combining Follow HTTP Stream with Wireshark or tshark --export-objects lets analysts carve HTTP and SMB files cleanly while verifying capture completeness and maintaining safe artifact handling.

Проверка знаний

Войдите, чтобы проходить тест, завершать уроки и сохранять прогресс. Войти в систему

Практика: проверьте свои знания