Skip to the content.

🔗 Link to the Room

🏷️ Table of Contents

  1. Command-Line Packet Analysis Hints
  2. TShark Fundamentals I
    2.1 Sniffing
  3. TShark Fundamentals I
    3.1 Reading capture files
    3.2 Writing capture data
    3.3 Viewing packet bytes
    3.4 Verbose packet analysis
  4. TShark Fundamentals II
  5. Packet Filtering Parameters
    5.1 Capture filters (live filtering)
    5.2 Display filters (post-capture filtering)
  6. TShark Fundamentals IV
    6.1 Type qualifiers
    6.2 Direction qualifiers
    6.3 Protocol qualifiers
  7. TShark Fundamentals V
    7.1 IP filtering
    7.2 TCP filtering
    7.3 HTTP filtering
    7.4 DNS filtering

📚 Study Notes

Command-Line Packet Analysis Hints

TShark and Supplemental CLI Tools

Tool Purpose
capinfos Displays summary information about a capture file and is usually the first step before analysis
grep Searches for specific text patterns
cut Extracts specific parts of each line
uniq Removes duplicate lines or values
nl Adds line numbers to output
sed Edits and transforms text streams
awk Performs advanced pattern matching and data processing

image

 


❓View the details of the demo.pcapng file with "capinfos". What is the "RIPEMD160" value?6ef5f0c165a1db4a3cad3116b0c5bcc0cf6b9ab7

✅Solution: In [~/Desktop/exercise-files] run [capinfos demo.pcapng] and search for [RIPEMD160]. —

 

TShark Fundamentals I

Main Parameters I

TShark is a command-line (text-based) network analysis tool, which makes it well suited for structured, step-by-step packet analysis. It includes many built-in parameters that help analysts control what information is displayed. Learning these parameters is important to avoid being overwhelmed by TShark’s very detailed output. Superuser (sudo) privileges are required to sniff live traffic and to list available network interfaces.

Common TShark parameters:

Parameter Purpose
-h Displays the help page with commonly used options
-v Shows the TShark version information
-D Lists all available network interfaces
-i Specifies which interface to use for live traffic capture
No parameter Starts sniffing traffic using the default interface (similar to tcpdump)

Sniffing

image

image


❓What is the installed TShark version in the given VM?3.2.3

✅Solution: Run command [tshark -v] —

❓List the available interfaces with TShark. What is the number of available interfaces in the given VM?12

✅Solution: List interfaces with [sudo tshark -D] —

TShark Fundamentals I

Main Parameters II

TShark provides several important parameters that help analysts read, limit, save, and inspect packet data efficiently. These options are essential for controlling output and focusing on relevant traffic during analysis.

Key parameters:

Parameter Purpose
-r Reads packets from a capture (PCAP) file instead of live traffic
-c Limits the number of packets processed or displayed
-w Writes captured or filtered packets to a new PCAP file
-V Enables verbose output with full packet details (similar to Wireshark’s Packet Details pane)
-q Quiet mode; suppresses packet output in the terminal
-x Displays packet contents in hex and ASCII format

Reading capture files

Writing capture data

Viewing packet bytes

Verbose packet analysis

Overall, these parameters highlight TShark’s strength as a command-line alternative to Wireshark, offering strong capabilities for detailed analysis, scripting, and automation when used efficiently.

image


❓Read the "demo.pcapng" file with TShark. What are the assigned TCP flags in the 29th packet?PSH, ACK

✅Solution: Run [tshark -r demo.pcapng] —

❓What is the "Ack" value of the 25th packet?12421

✅Solution: Run [tshark -r demo.pcapng -T fields -e tcp.ack -Y frame.number==25] —

❓What is the "Window size value" of the 9th packet?9660

✅Solution: Run command [tshark -r demo.pcapng -T fields -e tcp.window_size -Y frame.number==9] —

TShark Fundamentals II

Capture Conditions

[!IMPORTANT] Capture condition parameters only work in live capture mode They are used to control file size, duration, and file rotation during sniffing To extract or filter packets from an existing PCAP file, read and write options must be used instead Autostop (-a) and ring buffer (-b) parameters can be combined ?Infinite loops created with ring buffer options must include at least one autostop condition to stop the capture safely

image


❓Which parameter can help analysts to create a continuous capture dump?-b

❓Can we combine autostop and ring buffer parameters with TShark? y/ny

Packet Filtering Parameters

Capture and Display Filters

Capture filters (live filtering):

C- apture filters are applied before or during live traffic capture. Their goal is to save only specific types of traffic into the capture file. Once the capture starts, these filters cannot be changed. Capture filters use Berkeley Packet Filter (BPF) syntax and provide basic filtering based on protocol, IP ranges, ports, and traffic direction. This helps limit file size and keep capture data focused.

Display filters (post-capture filtering):

TShark filtering parameters:

Parameter Purpose
-f Capture filters (BPF syntax, same as Wireshark capture filters)
-Y Display filters (same syntax as Wireshark display filters)

❓Which parameter is used to set "Capture Filters"?-f

❓Which parameter is used to set "Display Filters"?-Y

TShark Fundamentals IV

Packet Filtering Options: Capture Filters

Type qualifiers

Direction qualifiers

Protocol qualifiers

Testing capture filters:

Common capture filter use cases:

Capture Filter Category Details Commands example
Host filtering Capture traffic to or from a specific host curl tryhackme.com; tshark -f “host tryhackme.com”
IP filtering Capture traffic related to a specific IP address nc 10.10.10.10 4444 -vw 5; tshark -f “host 10.10.10.10”
Port filtering Capture traffic on a specific port nc 10.10.10.10 -vw 5l tshark -f “port 4444”
Protocol filtering Capture traffic using a specific protocol nc -u 10.10.10.10 4444 -vw 5; tshark -f “udp”

❓What is the number of packets with SYN bytes?2

✅Solution: Run command [tshark -r demo.pcapng -Y “tcp.flags.syn == 1” | wc -l] —

❓What is the number of packets sent to the IP address "10.10.10.10"?7

✅Solution: Run command [tshark -r demo.pcapng -Y “ip.dst == 10.10.10.10” | wc -l] —

❓What is the number of packets with ACK bytes?8

✅Solution: Run command [tshark -r demo.pcapng -Y “tcp.flags.ack == 1” | wc -l] —

TShark Fundamentals V

Packet Filtering Options: Display Filters

Common display filter examples:

IP filtering

TCP filtering

HTTP filtering

DNS filtering

[!IMPORTANT] TShark does not renumber packets after filtering. It keeps the original packet numbers from the capture file and only displays packets that match the filter. This can make it confusing to determine how many packets matched the filter. To solve this, the nl command can be used to add line numbers to the filtered output, making it easy to count the total number of displayed packets.

image

image

image


❓What is the number of packets with a "65.208.228.223" IP address?34

✅Solution: Run command [tshark -r demo.pcapng -Y “ip.addr == 65.208.228.223” | wc -l] —

❓What is the number of packets with a "TCP port 3371"?7

✅Solution: Run command [tshark -r demo.pcapng -Y “tcp.port == 3371” | wc -l] —

❓What is the number of packets with a "145.254.160.237" IP address as a source address?20

✅Solution: Run command [tshark -r demo.pcapng -Y “ip.src == 145.254.160.237” | wc -l] —

❓Rerun the previous query and look at the output. What is the packet number of the "Duplicate" packet?37

✅Solution: Run command [tshark -r demo.pcapng -Y ‘ip.src == 145.254.160.237 and udp.analysis.duplicate’ -T fields -e frame.number]