Wireshark

Darshan & Raj

Wireshark Overview

Wireshark is a network protocol analyzer created by Gerald Combs in 1998. It is used for:

Wireshark captures network information from the Application Layer to the Link Layer.

Wireshark Network Layers

This is Wiresharks landing page.

Starting from the top:

Wireshark Main Page

After you click capture, the following display shows up confirming your selection and offers a few more configurations.

Promiscious Mode enabled means if a packet is not meant for your system, Wireshark will still keep a record of it. Sometimes, packets bounce of various hosts asking for a final destination -- at this point, Wireshark keeps the packet or discards based on this option.

Wireshark Capture Settings

When you begin capturing network packets, the following window will show up.

Wireshark Capture Page

Here's a look at what the buttons on the toolbar do.

Wireshark Toolbar

Right below the toolbar, there are seven columns:

Wireshark Capture Page

Column Headers

  1. No – Each packet is assigned a number.
    • Straight forward, it's just a counter.
  2. Time – The timestamp of the packet.
    • a.k.a how much time passed since you began capturing.
    • You can change this to various other time formats by going to "View > Time Display Format > ...".
  3. Source – Source address of the packet, could be an IP or MAC address.
    • As humans, we find it easier when the IP or MAC address is an actual name, such as 'www.google.com' or 'www.yahoo.ca'. You can enable Wireshark's option to convert these addresses by going to "View > Name Resolution > Resolve Network Addresses".
  4. Destination – Destination address of the packet, could be an IP or MAC address.
  5. Protocol – Protocol name used in the packet.
    • Protocol means "a set of rules governing the format of data sent over the Internet or other network." Click here for a complete list.
  6. Length – Total length of the packet.
  7. Info – Provides additional details about the packet.
    • This Info view is just meant to be a quick view of what the packet is about. For more details, go down to the In-depth panel and the bytes panel for more details on the packet flags, source and destination ports, HTTP form data, and more!


Here's a view of the in-depth and the bytes panel:

Flow Graph

Sometimes it's difficult to grasp a picture of how the packets are flying. Wireshark offers a Flow Graph (under Statistics tab) where you're able to see how the communication works between a server and client.

Colour Coding Packets

Each of the packets in the main view are colour-coded so we can easily understand what they mean. This can be changed by going to View > Colouring Rules. You can also add your own colouring rules in case if you wanted all packets with incoming IP address matching x.x.x.x to be blue.

Wireshark Colouring Rules

Filtering Packets in Wireshark

A lot of network traffic is caught by Wireshark and most will be useless for us right now. With the help of filtering, we can get to the good stuff quickly.

Filter Bar

Try out some of the following filters.

Source IP Filter: ip.src == 192.168.1.1
Destination IP Filter: ip.dst == 192.168.1.1
Filtering with Logic:
    -----------+------------
           AND | and, &&
            OR | or, ||
        EQUALS | eq, ==
    NOT EQUALS | !=

Examples: 
    tcp contains 01:01:04
    tcp.port eq 25 or icmp
    ip.addr == 10.43.54.65
    ! ( ip.addr == 10.43.54.65 )
  
Some popular filters:
    tcp.port == 443
    tcp.analysis.flags
    !(arp or icmp or dns)
    follow tcp stream
    tcp contains facebook
    http.response.code == 200
    http.request
      



Attacking & Defending with Wireshark

Attacking:

Packet Sniffing is a form of attack. You're looking to obtain sensitive information such as credentials when a person logs in or registers at a website. You're also able to find out what websites a person is visiting, files they are transferring, or applications they are using by linking Wireshark to your router.

How to catch a network scan attack?

Step 1: You'll notice a lot of packet drops (labelled  [RST ACK] ).

Wireshark Packet Drops

Step 2: Go to

Statistics > IPv4 Stats > Source and Destination Addresses
and sort by count. If a specific IP address has a high count and you don't know the source IP, they are most likely attacking your system. At this point, you can make the necessary changes to block them.

Wireshark IPv4 Statistics Page How to detect which local services are running (accessible to the web)?
  1. Find Destination Port ID in packet details > Transmission Control Protocol
  2. Open terminal, run the following
    sudo lsof -i:PORT#
    (replace 'PORT#' with actual port number).
    • lsof
      meaning 'LiSt Open Files' is used to find out which files are open by which process.
  3. Find PID, open Activity Monitor (Mac) and find the PID.


Building Firewall Rules

Select a packet that you'd like to create a firewall rule for. Then click on Tools > Firewall ACL Rules. The first rule is generated by Wireshark. Feel free to modify this to fit your needs.


Tracking Your Packets for Development Purposes

For CSC490, we are building a Chrome extension that sends messages through Firebase to your phone (think of 2FA) and requests for credentials. Wireshark is helpful in identifying where our data packets were dropping.

For fun, explore the 'Statistics' tab and 'Analyze' tab for a boat-load of interesting features! Some that we found were interesting include:



Time for Demos

  1. Logging on unsecure website.
    • We created a simple HTML/PHP login page on HTTP. First, we start a capture and then visit the page. After logging into the website, the capture is stopped.
    • "http.request.method == 'POST'" filter is applied to get all packets that are of a POST type.
    • When we submitted the form on the website, we sent a POST request which Wireshark caught.
    • In the in-depth panel, under HTTP section, we are able to see the form values in plain text -- this includes the username and password.
  2. Logging on secure website.
    • Same process, start a capture, and we used 'www.vfemail.net' as our website this time. However this time, there are no packets of type HTTP. This is because the website uses HTTPS.
    • In this case, we are able to see a secure handshake being performed. Click on 'View > Find Packet'. In the drop down menu, select 'String' and search for vfemail.
    • Once you've found a vfemail.net packet, right click on it > Follow > TCP stream. Now all the packets in your view are filtered down to anything related to vfemail. Go all the way to the top and you'll see the client (you) and the host (vfemail) establishing a secure connection.
    • In the image above, you can see the 'Client Hello', 'Server Hello', exchange of keys, the handshake, and then finally, application data which is encrypted.
    • And as before, always visit the in-depth panel for more information such as the image below:
  3. Various filtering examples.
  4. Incognito mode.
    • Wireshark captures packets so whether you're on incognito mode or not, it doesn't matter -- the network traffic will be captured.
  5. Pinging / (Network Scan) DDoS attacks.

Additional Demos

  1. Exporting / Importing Wireshark capture files.
  2. https://db-ip.com/ : searching up IP location



Explore Wireshark Yourself.

True or False: Incognito Browser Mode can hide packets from Wireshark.
Answer:
False
WireShark can sniff packets from which OSI Layers?
Answer:
Application, Transport, Network, Link Layer
What is the filter expression for finding all HTTP GET request with destination port 8080
Answer:
http.request.method == "GET" && tcp.dstport eq 8080
Further Thinking:

Where else can you see Wireshark being useful?

How do we make Wireshark safe for testing and development, and stop it from being used for negative purposes?





Resources:

Wireshark Website: https://www.wireshark.org
Wireshark Wikipedia: https://en.wikipedia.org/wiki/Wireshark
Setup apache (on Mac): https://medium.com/@JohnFoderaro/set-up-apache
Wireshark GUI Overview: https://networksecuritytools.com/wireshark-interface-gui-overview/
Wireshark Filtering: https://www.thegeekstuff.com/2012/07/wireshark-filter/
Wireshark Filtering 2: https://wiki.wireshark.org/DisplayFilters
Wireshark User Guide: https://www.wireshark.org/download/docs/user-guide.pdf
Wireshark Walkthrough: https://www.youtube.com/watch?v=TkCSr30UojM
DDOS Attack: https://www.youtube.com/watch?v=MphYj90_eJA
Network Layer Protocols: http://www.cs.toronto.edu/~ylzhang/csc358/files/lec01.pdf