Wireshark a network traffic analyzer. It is widely regarded as the de facto tool for capturing and examining network traffic.
In this lab, you'll install Wireshark on your own system and become familiar with a few of its key features: capturing traffic, exploring packets, and extracting data from captures.
There will be a few points in this tutorial where you can demonstrate your progress, which you can include in your homework submission to receive credit.
To install Wireshark:
WinPcap
on Windows or BPF tools on MacOS); you should install these as well.What's next? There are two ways to use wireshark: it can perform live captures, where it reads and displays network traffic observed on your system in real-time, or it can view or save capture files (also called .pcap files), which are files that store captured traffic for later analysis. In this lab, we will briefly work with both.
Now that you have Wireshark running, it's time to use it to capture traffic!
Packet captures are performed by attaching to one of your system's network interfaces (eg. your Wifi card, Ethernet port, etc.). To start a capture:
What you're seeing are all the packets entering or leaving your network interface in real-time. If you have some applications running that are using a lot of network traffic (eg. watching a video), you may see a lot of packets!
Just watching the packets in real-time can be useful: you can observe exactly how your system is interacting with the network as you do things. However, what we see here is a ton of information–this can be overwhelming, and we don't need to understand everything here. In the next section, we'll look at how to narrow this down and examine some packets.
Warning: While you have a live capture running, Wireshark stores all network traffic it captures in your memory or on disk. If you're doing something bandwidth intensive (eg. streaming a movie, Zoom call, etc.) and need to leave the capture running, this could use a lot of resources!
If you need to stop working on this tutorial, you can stop your capture by selecting Capture > Stop from the menu. This will stop Wireshark from saving packets while you're not working.
It's also possible to confiure Wireshark to skip saving certain types of packets to save resources: this is called a capture filter, which is beyond the scope of this tutorial. You can read more about Capture Filters here.
To help us sort through all of the packets, Wireshark has support for filtering traffic based on certain criteria. This can be useful to focus your analysis for certain types of packets.
To demonstrate filters, we'll send some traffic and then look for it in Wireshark's output. To do this:
Start a live capture as described in the previous section (or leave it running if you already had it open)
Open a terminal on your host machine and run one of the following:
ping -c 3 1.1.1.1
ping 1.1.1.1
This will send some ping packets (like in the figure below)–these are really simple messages used to test if a host is online. In this case, we are sending three packets to the address 1.1.1.1 (which happens to be Cloudflare's public DNS server).
When you type the command, you might see some pink packets fly past your Wireshark output. To find them, let's add a filter:
icmp
. This tells Wireshark to show only packets for the ICMP protocol, which is the protocol used by ping packets. Your Wireshark window should now look like this:You should now see six packets (like the figure) in the list: there should be 3 packets sent from your IP address to 1.1.1.1, and a response for each one.
You've now had practice with the most basic Wireshark filters. You can do a lot with filters–this is only the beginning. Here are some more examples of filters you might find useful:
http
: Show all HTTP trafficicmp || dns
: Show all ICMP and DNS packetstcp.port == 80
, udp.port == 1234
: Show traffic on a certain port numberip.len > 1000
: Show all IP packets > 1000 bytes in sizehttp.request.method == "GET"
: Show all HTTP GET requestsTo read more about Wireshark filters, see here.
The main packet list shows the most important information about each packet, but we can also look further to see what each byte of the packet means. Wireshark contains hundreds of packet dissectors, which are programs that know how to decode various network protocols and display the information for you.
For example, Wireshark knows these packets use the ICMP protocol because it has a built-in dissector to recognize these packets.
To explore further:
For example, each ICMP packet has an identifier field, so that it's possible to uniquely differentiate between two ping packets. Here's what it looks like in decoded and bytes view:
Now that we've seen the basics, let's explore some of Wireshark's more powerful features for decoding more complex traffic. To do this:
This file contains a saved capture of a request to an insecure website (you might even find it familiar…) via HTTP. If you scroll through the file, you should see some traffic that represents fetching a web page in a browser.
Recall from the Flag project that a web page contains many elements and resources: browsers fetch an initial web page and then need to issue additional requests for other assets on the page (eg. images, fonts, etc.). Most of the packets here result from loading a single web page! In particular, if you scroll through the capture, you will see:
juice.cs1660.net
), as well as various other domains referenced in URLs. (To see this, filter with dns
)http
or tcp.port == 80
)Wireshark can tell us more about the web page and the HTTP request process. To see this:
GET
request for the URL /assets/public/images/products/fruit_press.jpg
Think back to how you once viewed this same information in your browser's Developer Tools–now you're seeing the actual bytes as they're sent over the network!
Some things to note about this message:
.../images/products/fruit_press.jpg
)In addition to showing us HTTP requests and responses, Wireshark can also export the page elements for us to view! To do this:
This is a view of all the HTTP data that was returned in HTTP responses and would have been loaded by the browser. Since all the data was sent in the clear via HTTP, we can view all of this content!
Click on one of the images. You should see Wireshark jump to the packets where the image appeared in the capture.
Click Save to save the image to your computer.
If you get an error saying the filesystem is read-only, make sure you are saving to a path in your user folder–for some reason, Wireshark might select an unwritable system path by default.
Congrats, you successfully extracted data from a packet capture, just like a network eavesdropper might be able to do!
Now that you've learned some basic skills for exploring capture files, packets and filters, demonstrate your skills by doing the following:
POST
request where a user logs in. Find this request and include the user's credentials (email and password) in your submission. To do this, remember what you learned about filters to search for this request, then look at the request content to find the credentials.There is no particular format for your submission, so long as you include these items.
We hope you found this initial tutorial on Wireshark useful. For more guides and demos, we recommend checking out Wireshark's documentation, which has a lot of guides and tutorial videos to learn more!