Module 10 · Network Security · Lesson 29 of 75
Packet analysis with Wireshark and tcpdump
Capture traffic, use display and capture filters, follow streams, spot scans, clear-text passwords and suspicious DNS, and read an IDS rule.
In this lesson · about 45 minutes
- Capture with tcpdump and analyse with Wireshark or tshark
- Write display filters to find a needle in a capture
- Recognise scan patterns, clear-text credentials and beaconing
Capturing
sudo tcpdump -i eth0 -nn -w capture.pcapcaptures everything to a file (-nnskips name lookups).- Capture filters (BPF syntax) limit what is saved:
host 10.0.0.5,port 53,tcp and not port 22. - Capture where the traffic is: on the host itself, a switch SPAN port, or a network tap. On a switched network you only see your own traffic plus broadcasts unless you mirror a port.
- Only capture on networks you own or are authorised to monitor: packet captures contain private data.
Wireshark display filters
| Filter | Shows |
|---|---|
ip.addr == 10.0.0.5 | Traffic to or from one host |
tcp.port == 445 | SMB traffic |
http.request.method == "POST" | Form submissions (logins) |
dns.qry.name contains "xyz" | DNS lookups containing text |
tcp.flags.syn == 1 && tcp.flags.ack == 0 | New connection attempts (scans stand out) |
tcp.flags.reset == 1 | Resets (closed ports, broken connections) |
ftp || telnet || http.authorization | Likely clear-text credentials |
tls.handshake.extensions_server_name | Which sites TLS clients asked for (SNI) |
Useful features: Follow TCP Stream (read a conversation as text), Statistics → Conversations (who talked most), Statistics → Protocol Hierarchy, and File → Export Objects → HTTP (pull files out of a capture).
Patterns to recognise
- Port scan: one source sending SYNs to many ports, getting RSTs back.
- Ping sweep: ICMP echo requests to every address in a range.
- Brute force: many short connections to 22, 3389 or a login page.
- Beaconing: a host contacting the same external address at regular intervals (every 60 s, say), typical of command and control.
- DNS tunnelling: very long, random-looking subdomains in many queries to one domain.
- Large outbound transfers at odd hours: possible exfiltration.
Reading an IDS rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"Possible beacon to known C2 path";
http.uri; content:"/api/v2/checkin"; http.user_agent; content:"Mozilla/4.0";
threshold: type both, track by_src, count 5, seconds 300; sid:1000101; rev:1;)
Action (alert), protocol, source → destination, then options: a message, what to match in which part of the request, a threshold so one hit does not alert, and a unique rule ID. Suricata and Snort rules share this shape.
Hands-on lab (simulated terminal)
Lab: investigate a suspicious capture with tshark
An IDS flagged host 10.0.8.23. You have a capture, incident.pcap, from your lab network. tshark is the command-line version of Wireshark. Output is simulated.
Step 1 of 3. Type each command and press Enter. Nothing runs on your computer.
1. Show the conversations involving TCP, ranked by bytes (tshark statistics: conv,tcp, quiet mode).
Check your understanding0 of 3 correct
Quiz score: 0 of 3
Written by Noviq Academy in its own words. All labs are simulations: no real systems are touched, and every name, address, password and hash is made up. The offensive techniques taught here are for defending systems and for authorised testing only; never scan, access or test a system without the owner's written permission. Tool and product names belong to their owners, and command output may differ slightly from yours. Read-aloud uses your device's built-in voices.