Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 53 ยท Reconnaissance and Scanning

Packet Analysis with Wireshark

Learn how to capture and read network traffic with Wireshark on your own lab network: capture vs display filters, following streams, spotting cleartext and scan patterns, and ethics.

Logs tell you what a program decided to record. Packets tell you what actually crossed the wire. Wireshark is the most widely used packet analyzer: it listens on a network interface, decodes hundreds of protocols and lets you search, filter and reassemble conversations. For a security practitioner it answers questions like "is this login sent in cleartext?", "who is this host talking to?" and "what did that scan look like from the other side?"

Capturing traffic can expose other people's private data: passwords, messages, browsing. Capture only on networks you own or are explicitly authorized to monitor, and treat capture files as sensitive evidence. Sniffing a shared network you do not control can be illegal in many places. See Law, Ethics and Authorization.

The runnable parts of this lesson are stand-ins: a small list of invented packet records and a tiny filter function that behaves like a display filter. They teach the reading skills without capturing anything.

How capture works

A network card normally hands the computer only frames addressed to it. A capture tool puts the interface into promiscuous mode (or monitor mode on Wi-Fi) to see more. On a modern switched network you still see only your own traffic plus broadcasts, unless you capture on the right point: a mirror (SPAN) port on a switch, a network tap, or the host that actually carries the traffic. That is why lab captures are usually taken on the target VM itself or on a virtual switch you control.

flowchart LR
  A["Client VM"] --> B["Virtual switch"]
  B --> C["Server VM"]
  B -. "mirror port" .-> D["Analyzer VM<br/>(Wireshark)"]

In a lab, mirror a virtual switch to an analyzer VM. Real networks need permission to do the same.

Capture filters and display filters

Two kinds of filter are easy to mix up.

  • A capture filter decides what is recorded at all. It uses the Berkeley Packet Filter (BPF) syntax, for example host 192.168.56.10 and port 80. It reduces file size, but anything not captured is gone.
  • A display filter hides packets in an already captured file. It uses Wireshark's own field syntax, for example http.request.method == "POST", tcp.flags.syn == 1 && tcp.flags.ack == 0 or ip.addr == 192.168.56.10. It is non-destructive and is the one you will use most.

A good habit: capture broadly in the lab (the files are small), then narrow with display filters. In production monitoring, use a capture filter to avoid collecting data you should not have.

Useful display filters to know:

TEXT
ip.addr == 192.168.56.10          traffic to or from a host
tcp.port == 443                   one TCP port
dns                               DNS only
http.request                      HTTP requests
tcp.flags.syn == 1 && tcp.flags.ack == 0    connection attempts (first handshake packet)
frame contains "password"         packets containing a string (careful: sensitive!)

Reading the three panes

The main window has three panes. The packet list shows one row per packet: number, time, source, destination, protocol, length and a summary. The packet details pane shows the layers of the selected packet as a tree: Ethernet, IP, TCP, then the application protocol. The packet bytes pane shows raw hex and ASCII. Read top to bottom: who talked to whom, with which protocol, and what did the application layer carry? The layered tree mirrors the model in Networking Essentials.

Right-click a packet and choose Follow TCP Stream to reassemble the whole conversation into readable text. For cleartext protocols (HTTP, FTP, Telnet, old mail protocols) this reveals credentials immediately, which is the strongest argument for encryption you can show a skeptical manager. For TLS the stream is ciphertext; you see the handshake, server name and certificate details but not the content.

Spotting patterns

Once you can read packets, patterns jump out.

  • Cleartext credentials: an HTTP POST to a login with the password in the body, or an FTP PASS command.
  • Scans: many SYN packets from one source to many ports, with resets coming back (compare port scanning concepts).
  • Spoofing and poisoning: repeated ARP replies claiming different MAC addresses for one IP, covered in network attacks and defenses.
  • Beaconing: a host contacting the same external address at regular intervals, typical of some malware.
  • DNS oddities: very long or random-looking names, huge responses or lots of TXT queries.
  • Retransmissions and resets: performance or firewall problems rather than attacks.

A stand-in capture and display filter

The data below is invented and uses documentation address ranges. The filter function accepts a predicate like a display filter, and the code summarizes what the "capture" contains.

Node.js Filter an invented packet capture

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

This miniature shows the thought process: filter by a signal, then count. The first group is a scan, the second is a cleartext login, and the third is a possibly generated DNS name that deserves a look.

From packets to evidence

Packet analysis is also a reporting skill. A screenshot of a followed stream showing a cleartext password is hard to argue with. When you present evidence:

  • Redact real secrets and personal data in the report; keep the full capture only if the client wants it and storage is secure.
  • Note the capture point, time and filter used so the result can be reproduced.
  • Keep captures encrypted at rest and delete them according to the engagement agreement.

Defenders and Wireshark

Defenders use the same tool for troubleshooting and incident response: comparing what a firewall says it allowed with what actually flowed, finding which host contacted a suspicious address, and extracting files or indicators from a recording. Network monitoring systems automate this at scale, but the manual skill is what lets you question their output. The second stand-in turns the "beaconing" idea into a few lines: regular intervals are suspicious because humans rarely click on a schedule.

Node.js Spot beaconing from timestamps

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Real beacons often add random jitter, so analysts look at distributions and long time spans, not a single number. The idea remains: measure regularity.

The display filter expression dialog

Wireshark has a helper for building display filters without memorizing field names. Open it from the filter bar (Analyze, Display Filter Expression). Choose a protocol and a field from the tree, pick a relation (equal, not equal, greater than, contains, matches), and enter a value, or choose from the predefined values the dissector offers (for example HTTP request methods or TCP flag names). The dialog shows the resulting expression, such as http.request.method == "GET", which you can paste into the filter bar. Use it to learn the field names, then type filters directly.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the difference between a capture filter and a display filter?

    Capture filters (BPF) limit what is saved. Display filters are non-destructive and let you explore a full capture.
  2. 2. You follow a TCP stream and read a password in plain text. What does that show?

    Cleartext protocols expose content to anyone on the path. TLS-protected streams show only encrypted data.
  3. 3. Which situation lets you capture traffic between two other hosts on a switched network?

    Switches forward unicast traffic only to the destination port, so you need a mirror, a tap or a position on the path, and permission.
  4. 4. Which pattern suggests malware beaconing in a capture?

    Automated callbacks tend to be regular in time, unlike human activity.

Summary

  • Wireshark captures and decodes network traffic; capture only where you are authorized, and handle captures as sensitive data.
  • Capture filters (BPF) limit what is recorded; display filters narrow what you view.
  • Read the packet list, details and bytes panes, and use Follow TCP Stream to reassemble conversations.
  • Cleartext protocols expose credentials; TLS hides content but still shows handshakes and server names.
  • Scans, ARP anomalies, odd DNS and regular beacons have recognizable shapes.
  • Record the capture point, filter and time with evidence, and redact secrets in reports.

Next: Vulnerability Scanning and Triage