Learn · Tier 1 · Module 1 of 10

Reading a pcap

What a packet capture holds, how to filter it, and how to follow one conversation from start to end.

The idea

A packet capture (pcap) is a recording of network traffic: every packet a machine sent or received while the capture ran, with the time it was seen. Malware has to talk to someone, so a capture is often the clearest record of what it did.

Layers

Each packet is wrapped several times, and a capture viewer shows every layer:

LayerAnswersExample fields
Ethernetwhich network card, on the local networketh.src
IPwhich machine, anywhereip.src, ip.dst
TCP or UDPwhich program on that machine (the port)tcp.port, udp.port
Applicationwhat was actually saidhttp.host, http.request.uri, dns.qry.name

The puzzles here are about the top layer: HTTP. The layers under it say who talked to whom.

Conversations, not packets

A web request is not one packet. It is a TCP conversation:

  1. Three packets open the connection (SYN, SYN-ACK, ACK): the handshake.
  2. The client sends the request. A large one is split across several packets.
  3. The server sends the response, also split up.
  4. A few packets close the connection (FIN).

Before that, the client usually asks DNS for the server's address: a UDP query and its answer.

Reading packets one by one is slow. Follow stream puts a conversation's bytes back together in order and shows them as text: the request, then the response, as the two programs saw them.

Filters

A capture of a few minutes can hold thousands of packets. A display filter hides everything that does not match. Display filters name a field and a value:

  • http.request: packets that carry an HTTP request.
  • http.response.code == 404: responses with status 404.
  • ip.addr == 192.0.2.77: anything to or from that address.
  • tcp.stream == 3: the fourth TCP conversation (numbering starts at 0).
  • dns.qry.name contains "share": DNS queries for names with "share" in them.

Combine with && (and), || (or) and ! (not).

An HTTP request

GET /s/8fk2Lq/invoice_0921.zip HTTP/1.1
Host: dl.quickdocs-share.test
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) ...
Referer: http://mail.corp-portal.test/inbox?folder=new

The first line is the method, the path and the version. Then headers, one per line: Host is the server's name, User-Agent the program that sent it, Referer the page the user came from. A blank line ends the headers; a body, if there is one, follows.

Walkthrough: in the browser

Showing the browser path.

You need nothing installed: the workspace runs Wireshark's own dissectors in your browser.

  1. Open the practice puzzle, then Open the workspace. The Pcap tab loads Wireshark once (about 20 MB) and opens capture.pcap.
  2. The packet list has Wireshark's columns: number, time, source, destination, protocol, length, info. Scroll it: DNS lookups, TCP handshakes, HTTP.
  3. Type http.request in Display filter and press Apply. Only the requests are left, with their method and path in the Info column.
  4. Under the filter, the Terminal line shows the tshark command that gives the same list. You will use it in module 8.
  5. Click a request. Its protocol tree opens below: Frame, Ethernet II, Internet Protocol, Transmission Control Protocol, Hypertext Transfer Protocol. Open the HTTP part to see each header.
  6. Every field in the tree has Filter next to it, which makes a filter from that field. Try it on the Host line.
  7. Press Follow HTTP stream. The request and the response appear as text, the way the two programs saw them. Follow TCP stream shows the raw bytes of the same conversation.
  8. Clear the filter and filter on dns. Each query has an answer with the address the name resolved to.

Now solve the practice puzzle: find the request that downloaded a zip file, and the host it went to.

Practice

More at this level

Checkpoint

Answers from either path count.