Enable Hex Dump with -x
In this step, we'll explore how to examine the raw binary content of network packets using Wireshark's command-line tool tshark
. The -x
option is particularly powerful as it reveals the actual hexadecimal data that makes up each packet, which is essential for deep packet analysis.
When working with network traffic, packets are fundamentally just sequences of bytes. The -x
flag tells tshark
to display:
- The standard packet header information (like source/destination addresses)
- The complete hexadecimal representation of the packet's raw data
- An ASCII interpretation of that data (where applicable)
Before proceeding, let's make sure we're in the right working directory where our packet capture file is stored:
cd ~/project
Now we'll analyze our packet capture file (capture.pcap
) with hexadecimal output enabled:
tshark -r capture.pcap -x
This command produces output divided into three main sections for each packet:
- The summary line showing basic packet information
- The hexadecimal dump showing the raw packet bytes
- The ASCII representation of those bytes (displaying printable characters)
Here's what a typical output section looks like (shortened for demonstration):
1 0.000000 192.168.1.1 → 192.168.1.2 TCP 66 443 → 49234 [SYN] Seq=0 Win=64240 Len=0
0000 00 1a 4b 12 34 56 00 1b 11 22 33 44 08 00 45 00 ..K.4V..."3D..E.
0010 00 34 12 34 00 00 80 06 78 9a c0 a8 01 01 c0 a8 .4.4....x.......
0020 01 02 01 bb c0 52 00 00 00 00 00 00 00 00 50 02 .....R........P.
0030 fa f0 00 00 00 00 00 00 00 00 ..........
The hexadecimal display is organized as follows:
- The leftmost column (0000, 0010, etc.) shows the byte offset in hexadecimal
- The middle section displays 16 bytes of packet data per line in hexadecimal format
- The right section shows the ASCII character representation (with unprintable characters displayed as dots)
This view is invaluable when you need to examine protocol headers at the byte level or verify the exact content of network transmissions.