UnixDroid

Lesson 05 of 5

Advanced Wireshark: tshark, TLS Decryption and Detecting Suspicious Traffic

4 min read

Analyse captures from the command line, decrypt your own HTTPS traffic, and spot scans, ARP spoofing and DNS tunnelling.

You now know how to capture, filter and read traffic. In this final lesson we go further: analysing captures from the command line with tshark, decrypting your own HTTPS traffic for learning, and spotting the patterns a SOC analyst looks for.

tshark: Wireshark on the command line

tshark comes with Wireshark. It uses the same display filters, which makes it perfect for big files, servers without a GUI and scripts.

tshark -D                                   # list interfaces
tshark -i eth0 -c 100                       # capture 100 packets
tshark -i eth0 -w capture.pcapng            # save to a file
tshark -r capture.pcapng -Y "dns"           # read a file with a display filter
tshark -r capture.pcapng -Y "http.request" -T fields -e ip.src -e http.host -e http.request.uri
tshark -r capture.pcapng -q -z conv,tcp     # TCP conversations table
tshark -r capture.pcapng -q -z io,phs       # protocol hierarchy

For long captures, use a ring buffer so the disk never fills up:

tshark -i eth0 -b filesize:100000 -b files:10 -w ring.pcapng

This keeps the newest ten files of about 100 MB each and deletes the oldest.

Decrypt your own HTTPS traffic (for learning)

Browsers can write their TLS session keys to a file, and Wireshark can use that file to decrypt your own sessions:

export SSLKEYLOGFILE=$HOME/tls-keys.log
firefox &

Then in Wireshark go to Edit → Preferences → Protocols → TLS and set the (Pre)-Master-Secret log filename to that file. Your own HTTPS requests now show up as readable HTTP. Delete the key file when you're done, because anyone who has it can read those sessions.

Detecting suspicious traffic

Detecting an Nmap SYN port scan in Wireshark: many SYN packets to different ports from one source IP
Detecting an Nmap SYN port scan in Wireshark: many SYN packets to different ports from one source IP

Port scans. One source IP sending SYN packets to many different ports in a few seconds, with most of them answered by RST:

tcp.flags.syn == 1 && tcp.flags.ack == 0

Then open Statistics → Conversations and sort by the number of ports or packets. A scanner stands out immediately.

ARP spoofing. An attacker on the local network claims to be the router so traffic flows through them. Wireshark flags it for you:

arp.duplicate-address-detected

You'll also see the router's IP suddenly answered by a different MAC address, or a flood of ARP replies nobody asked for.

DNS tunnelling and exfiltration. Data hidden inside DNS queries makes very long, random-looking names and lots of TXT records:

dns.qry.name.len > 50
dns.qry.type == 16

Beaconing. Malware often "phones home" at regular intervals. In Statistics → I/O Graphs, filtered to one suspicious IP, beaconing shows up as evenly spaced spikes.

Cleartext logins. Check your own network for protocols that send passwords as plain text, so you can replace them:

ftp || telnet || http.authorization || pop || imap

A workflow that works every time

Wireshark packet analysis workflow: capture, filter, follow TCP stream, statistics, export
Wireshark packet analysis workflow: capture, filter, follow TCP stream, statistics, export
  • Capture on the right interface, with a capture filter only if the link is very busy
  • Filter down to the hosts and protocols that matter
  • Follow the stream to read whole conversations
  • Check Statistics for top talkers, odd protocols and spikes
  • Export and report the packets, files and notes that prove what happened

Where to practise

  • wiki.wireshark.org SampleCaptures – hundreds of small captures for every protocol
  • malware-traffic-analysis.net – real infection traffic with exercises. The archives contain live malware, so only open them inside a VM.
  • TryHackMe – Wireshark rooms for beginners and analysts
  • CyberDefenders – free network forensics challenges

Simple words mein (Hinglish)

tshark Wireshark ka command line version hai, bade files aur servers ke liye best. Apne browser ka HTTPS traffic SSLKEYLOGFILE se decrypt karke seekh sakte ho. SOC analyst ki tarah dekho: ek IP bahut saare ports par SYN bhej raha hai matlab port scan, duplicate ARP matlab ARP spoofing, bahut lambe DNS naam matlab DNS tunnelling. Har baar wahi workflow: capture, filter, follow, statistics, export.

FAQ

What is tshark? The command-line version of Wireshark. It uses the same display filters and is great for large files and scripts.

How do I detect a port scan in Wireshark? Filter with tcp.flags.syn == 1 && tcp.flags.ack == 0, then check Statistics → Conversations for one IP hitting many ports.

How do I detect ARP spoofing in Wireshark? Use the arp.duplicate-address-detected filter and look for the router's IP mapped to more than one MAC address.

Can Wireshark decrypt HTTPS? Only when you have the session keys, for example from your own browser via SSLKEYLOGFILE.

What should I learn after Wireshark? Nmap (to see scans from the attacker's side), Zeek or Suricata for automatic network monitoring, and a SIEM like Splunk.

Congratulations – you've finished Wireshark: Basic to Advanced!