Network Monitoring Using Wireshark
Network Monitoring Using Wireshark
Network Monitoring Using Wireshark
Rich Macfarlane
5.1 Details
Aim: This lab introduces packet capture (packet sniffing) and network traffic analysis with the Wireshark
tool, and basic network scanning using Nmap.
Wireshark
Eve
Internet
Bob Alice
Packet Analysis
Wireshark is an open source cross-platform packet capture and analysis tool, with versions for Windows and
Linux. The GUI window gives a detailed breakdown of the network protocol stack for each packet, colorising
packet details based on protocol, as well as having functionality to filter and search the traffic, and pick out
TCP streams. Wireshark can also save packet data to files for offline analysis and export/import packet
captures to/from other tools. Statistics can also be generated for packet capture files.
Wireshark is a GUI based network capture tool. There is a command line based version of the packet capture
utility, called TShark. TShark provides many of the same features as it’s big brother, but is console-based. It
can be a good alternative if only command line access is available, and also uses less resources as it has no
GUI to generate.
.
Figure 1 Wireshark Installation
Click the I Agree button to the License agreement, then select options (or accept defaults) clicking the
Next button on each screen when prompted.
Host PC
Internet
DESKTOP
Windows 7
Wireshark
Filters
Physical Network
Card
Napier
Wireshark app
Network
Uses WinPcap
WinPcap to read network
Network
Filters traffic
Traffic
Start the Wireshark application. When Wireshark is first run, a default, or blank window is shown.
To list the available network interfaces, select the Capture->Interfaces menu option.
Wireshark should display a popup window such as the one shown in Figure 2. To capture network
traffic click the Start button for the network interface you want to capture traffic on. Windows can
have a long list of virtual interfaces, before the Ethernet Network Interface Card (NIC).
Generate some network traffic with a Web Browser, such as Internet Explorer or Chrome. Your
Wireshark window should show the packets, and now look something like.
Packet
List Panel
Packet
Details
Panel
Packet
Bytes
Panel
To stop the capture, select the Capture->Stop menu option, Ctrl+E, or the Stop toolbar button. What
you have created is a Packet Capture or ‘pcap’, which you can now view and analyse using the
Wireshark interface, or save to disk to analyse later.
Questions
Q: From the Packet Details Panel, within the GET command, what is the value of the Host?
Q: Can you see the Hex and ASCII representations of the packet in the Packet Bytes Panel?
Q: From the Packet Bytes Panel, what are the first 4 bytes of the Hex value of the Host parameter?
To select more detailed options when starting a capture, select the Capture->Options menu option,
or Ctrl+K, or the Capture Options button on the toolbar (the wrench). This should show a window
such as shown in Figure 4.
Make sure the MAC name resolution is selected. Start the capture, and generate some Web traffic
again, then stop the capture.
Search through your capture, and find an HTTP packet coming back from the server (TCP Source Port == 80).
Expand the Ethernet layer in the Packet Details Panel.
Q: What are the manufacturers of your PC’s Network Interface Card (NIC), and the servers NIC?
Q: What are the Hex values (shown the raw bytes panel) of the two NICS Manufacturers OUIs?
Wireshark automatically generates a Display Filter, and applies it to the capture. The filter is shown
in the Filter Bar, below the button toolbar. Only packets captured with a Source Port of the value
selected should be displayed. The window should be similar to that shown in Figure 6. This same
process can be performed on most fields within Wireshark, and can be used to include or exclude
traffic.
If your having trouble finding the first SYN packet, select the Edit->Find Packet menu option. Select
the Display Filter radio button and enter a filter of tcp.flags. (at this point you should get a list of the
flags to choose from). Choose the correct flag, tcp.flags.syn and add == 1. Hit the Find button, and
the first SYN packet in the trace should be highlighted.
Note: Find Packet can also be used to search for a Hex signature, such as a malware signature, or to
search for a string – such as a protocol command - in the Packet Capture (pcap).
Questions
Q: Can you identify the rest of the TCP 3-way handshake easily? (if not read on)
Change to Hex Dump Mode and view the payloads in raw Hex, as shown below.
Close the popup window. Wireshark now only shows the packets from the selected TCP Stream. You
should be able to identify the 3-way handshake easily now.
Questions
Q: From your Wireshark Capture, fill in the diagram below with the IP Addresses and Port Numbers for the
Client and the Server
Q: For each packet in the TCP 3-way handshake, fill in the Sequence and Acknowledgement numbers, on the
diagram below.
Client
Server
Flags: SYN, Seq: ______
_____________ _____________
Questions
Q: Copy the Display Filter into the clipboard, and close and start Wireshark again, then reload the file. Was
the whole capture saved or just the displayed packets?
Paste the display filter back into the Filter Bar, and Apply it.
To save only the displayed packets, select File-> Export Specified Packets, and make sure the
Displayed radio button is selected rather than the Captured option. This creates a pcap file, with
only the packets filtered by the current display filter.
Questions
Q: Close and start Wireshark again, then reload the file. Was the whole capture saved or just the displayed
packets?
Questions
Q: What percentage of packets in your capture are TCP, and give an example of the higher level protocol
which uses TCP?
Q: What percentage of packets in your capture are UDP, and give an example of the higher level protocol
which uses UDP? (use the figure below)
Application
Session
Data Link
Ethernet, ATM Network
Physical
Stop the capture and Wireshark should now look something like Figure 10.
The Address Resoloution Protocol (ARP) and ICMP packets are difficult to pick out, create a display filter
to only show ARP or ICMP packets.
Note the results in Wireshark. The initial ARP request broadcast from your PC determines the physical
MAC address of the network IP Address 192.168.1.1, and the ARP reply from the neighbouring system.
After the ARP request, the pings (ICMP echo request and replies) can be seen.
Questions
Q: After the first ping command, are the ARP and ICMP packets captured by WIreshark?
YES/NO
Q: After a second or third ping command, is the ARP and ICMP packets captured by WIreshark?
ARP: YES/NO
ICMP: YES/NO
Q: Why is this?
If pinging the same system more than once, delete the ARP cache on your system, using the arp
command, as shoen below, so an new ARP request will be generated.
Note the results in Wireshark. The initial ARP request broadcast from your PC determines the physical
MAC address of the network IP Address 192.168.1.1, and the ARP reply from the neighbouring system.
After the ARP request, the pings (ICMP echo request and replies) can be seen.
A host scan is typically done over an entire network, and reports machines which are alive on the network. A
port scan is performed on a single, remote, host system, via its IP Address, and gives information on services
running on the machine. Typically an attacker is also looking for which OS the system is running as well as
any open TCP and UDP ports (services) which the attacker may be able to exploit. A network scanning tool,
such as nmap, can be used to automatically probe the system for open ports, and give a report back to the
attacker.
To mitigate open ports which attackers could use to compromise the system, make sure only services which
are necessary are running. Some server OSs have services running by default, such as HTTP (port 80) and FTP
(ports 20 & 21) which should be removed when systems are installed. (The command line network utility
netstat can be used to check which services are running on the same host).
Eve
Internet
Scanning …
Port 20 - closed
Port 21 - closed
Port 22 - open
Port 23 - closed
…
Port 65,000
Bob DMZ
Scans system for
open ports
(services running
on the system)
Web
Server
Figure 11 Port Scanning a System
Start a Wireshark capture. Open a Windows command window, and perform a Host Scan (using
ICMP packets) on a neighbours machine using nmap –sP [neighbours ip address] (do not
scan the entire subnet). Stop the capture and filter the traffic for ARP and ICMP packets if necessary.
Compare the capture with the saved ICMP capture from the previous section.
Questions
Q: Are the packets the same as the ping packets from the capture in the previous section?
Q: Are any other packets sent by nmap, during the ICMP probe?
Start a new Wireshark capture, and then perform a host scan (ICMP scan) on a system outwith the
subnet, such as
nmap –sP scanme.nmap.org
(do not perform any other type of scan outside the lab subnet). Stop the capture and filter the traffic
for ARP and ICMP packets if necessary. Compare the capture with the saved ICMP capture from
section 6.
Questions
Q: Are the packets the same as the ping packets from the capture in section 6?
Q: Are any other packets sent by nmap, during the host scan? Which protocol and to which port?
(do not scan more than a single machine). The –O option should provide the OS running on the
scanned machine. Stop the capture and filter for source address == your machines address if
necessary. Notice the number and types of ports tried by the nmap port scan. The capture should
look something like Figure 13.
Questions
Q: How many ports have been scanned in total? How many are open?
Q: Give an explanation of the following nmap command, and what implications it might have for an IDS?
nmap –T paranoid