Wireshark Network Security

5 (3 reviews total)
By Piyush Verma
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies

About this book

Wireshark is the world's foremost network protocol analyzer for network analysis and troubleshooting.

This book will walk you through exploring and harnessing the vast potential of Wireshark, the world's foremost network protocol analyzer.

The book begins by introducing you to the foundations of Wireshark and showing you how to browse the numerous features it provides. You'll be walked through using these features to detect and analyze the different types of attacks that can occur on a network. As you progress through the chapters of this book, you'll learn to perform sniffing on a network, analyze clear-text traffic on the wire, recognize botnet threats, and analyze Layer 2 and Layer 3 attacks along with other common hacks.

By the end of this book, you will be able to fully utilize the features of Wireshark that will help you securely administer your network.

Publication date:
July 2015


Chapter 1. Getting Started with Wireshark – What, Why, and How?

Sniffing and interpreting traffic on the network has been and always will be an integral part of a network analyst's job profile. It is not only restricted to the network analyst's profession, but it also plays a significant role in the fields of software development, network security, and digital forensics. Wireshark is the tool of choice at most workplaces and does not seem to slow down in terms of popularity and features, hence making it a "must-know" tool. This chapter gives a briefing on:

  • Sniffing and its purpose

  • Tools of the trade

  • Getting up and running with Wireshark



Sniffing, by definition, is using our sense of smell to savor something, like a sniff of perfume. In this case, our nose acts as a sniffer. We can perform sniffing on the network using various tools categorized as packet sniffers to capture or collect the packets flowing in our networks. They are simply a way for us to see the network traffic and bandwidth information over the entire IT infrastructure. The technique of using a packet sniffer to sniff the data flowing over the wire or through thin air (wireless) is called packet sniffing.

The purpose of sniffing

Packet sniffing is performed in order to better understand what flows through our networks. Just as a poison flowing through the veins of the human body has the potential to kill an individual, similarly malicious traffic traversing our networks can have a severe and sometimes irreparable effect on the network devices, performance, and business continuity.

Sniffing helps a network analyst verify whether the implementation and functionality of the network and network security devices, such as the router, switch, firewall, IDS, or IPS, are as expected and also confirms that data is traversing through secure channels of communication.

Security analysts use sniffing to gather evidence in the case of a security breach with regard to the source of the attack, time and duration of the attack, protocols and port numbers involved, and data transmitted for the purpose of the attack. It can also help to prove the use of any insecure protocol(s) used to transmit sensitive information.

As Christopher Hitchens, a British-born American author, was once quoted saying:

"That which can be asserted without evidence, can be dismissed without evidence."

Using a packet sniffer helps us get that piece of evidence.

Packet analysis

Now, to figure out whether the smell of the perfume is pleasant, ambrosial, or reeking is the analysis part. Hence, the art of interpreting and analyzing packets flowing through the network is known as packet analysis or network analysis. Mastering this art is a well-honed skill and can be achieved if a network administrator has a solid understanding of the TCP/IP protocol suite, is familiar with packet flows, and has an excellent grasp of any sniffer of choice.

Learning technology at the packet level helps to cement the most difficult concepts. For an easy example, let's say that a user wants to browse a website named example.com. As soon as the user enters the URL in the address bar and hits GO, the packets start to flow on the network with respect to that request. To understand this packet flow, we need to start sniffing to look at the packets in transit. The following screenshot shows the packets that traversed the network when the user opened example.com.

We can analyze the packets after capturing them using a sniffer of choice, and in our case, we notice the columns that tell us about the source and destination IP addresses, the protocol being used, the length of the individual packets, and other relevant information. We will be digging into more detailed analysis as we progress though this book.

When we talk about enterprise networks, at any given point, there is humongous amount of traffic on the wire and analyzing such traffic is not a walk in the park. This traffic may be generated by numerous network devices communicating among each other, servers responding to user requests, or making their own requests over the Internet when required, and end users trying to accomplish their day-to-day tasks at work. There is no better way to understand this flow of information than to perform a packet-level analysis and, as the famous quote about network analysis goes, packets never lie. In addition, Gerald Combs, the man behind Wireshark, once tweeted the following:

""The packets never lie" but as traffic volumes increase you end up with a trillion truths. The trick is finding the important ones."

Learning such tricks comes only with experience, as with anything else in the field of IT. As an example, if you want to improve your programming skills, you have to practice code writing day in and day out to be able to write structured and optimized pieces of code that can perform magic. The same goes for packet analysis.

Packet analysis can further help an administrator to:

  • Monitor and provide a detailed statistics of activities on the network

  • Distinguish between normal and unusual traffic

  • Perform network diagnostics

  • Identify and resolve network performance issues such as excessive bandwidth utilization

  • Conduct deep packet inspection

  • Investigate security breaches


The tools of the trade

There are numerous free and commercial packet sniffers, very often named network analyzers, in the market, and selecting the one that best meets your need is a matter of choice. There are several factors to determine this, such as the operating system in use, supported set of protocols, ease of use, customizability, and of course budget. The following are the popular ones:

  • Tcpdump: Tcpdump is a free and popular command-line packet capture utility, which can come in very handy in the absence of a GUI-based tool. However, even after capturing traffic via tcpdump, one can analyze and interpret the traffic using any GUI-based free or commercial tool, as it is visually easy. Refer to TCPDUMP Overview at http://www.tcpdump.org/manpages/tcpdump.1.html.

  • Nagios Network Analyzer and OmniPeek: These are commercial-grade network analyzers that provide organizations with packet analysis capabilities with some unique features of their own. The pricing for these products can be seen on their individual websites.

  • Wireshark: Wireshark, formerly known as Ethereal, is free and open source, and is the most popular packet analyzer out there. It works across multiple platforms and supports a huge set of protocol families with an easy-to-use GUI. Refer to http://wiki.wireshark.org/ProtocolReference/.

Apart from the dedicated sniffer tools we just introduced, packet sniffing capability and modules come integrated in many of the popular security-related tools, such as Snort, Metasploit, and Scapy, to name a few. Snort started off as a sniffer and later used its sniffing capabilities to develop into what we know today as the popular network intrusion prevention system (NIPS) and network intrusion detection system (NIDS) solution.

Another example is the presence of the sniffer module in Metasploit. After successfully compromising a machine using Metasploit, one can execute this module and start sniffing traffic on that compromised box for further enumeration. Sniffing options available with Metasploit are shown as follows:

Another excellent option is using sniff() in Scapy. Scapy is a packet manipulation tool written in Python and can be used to generate, craft, and decode packets and capture them. It is helpful in many security testing-related activities.

The focus of this book is "Wireshark". So, let's get started.


What is Wireshark?

Wireshark, as discussed earlier, is the most popular packet analyzer, and there is a reason behind its huge fan following. It hosts tons of features, supports a huge list of common and uncommon protocols with an easy-to-navigate GUI, and can be easily installed and used on popular operating systems, such as Windows, Linux, and Mac OS X for absolutely no cost at all.

Wireshark can be downloaded and installed from the official website (http://www.wireshark.org). The installation setup is comparatively simple, and within a few clicks, you will be up and running with Wireshark on a Windows machine.


Installation guidelines for Windows, Unix, and Mac OS X can be found at https://www.wireshark.org/docs/wsug_html_chunked/ChapterBuildInstall.html.

As of writing this, the most recent version is Wireshark 1.12.6. Once downloaded and installed, you should be able to start Wireshark and will be presented with a screen similar to the one shown here:


The Wireshark interface – Before starting the capture

Let's get started with various aspects of the Wireshark interface.


This contains the default title of Wireshark along with the current version in use. To enable or disable the title, navigate to Edit | Preferences | User Interface and modify the option Welcome screen and title bar shows version to suit your requirement. To modify the title, navigate to Edit | Preferences | User Interface | Layout and enter a suitable title in the Custom window title field as shown in the following figure:


Note: This will be appended to the current title as shown in the preceding screenshot.


The Menu bar hosts the features of Wireshark, all categorized under suitable titles. These options will be taken up as and when required during the course of this book. As an example, you can look at the authors involved in the development of Wireshark by navigating to Help | About Wireshark and selecting the Authors tab.

This is how it will look:

Main toolbar

The main toolbar contains the icons for more frequently used items in Wireshark. You will note that some options are grayed out. This is because not all the options are available in the current context. Once we start the capture, we will see most of them highlighted and available for use.

Filter toolbar

Filtering the traffic can help analysts find a needle in a haystack. There are two types of filtering options available in Wireshark. One is called capture filters, and the second is called display filters.

Capture filters define which frames will be captured and sent to Wireshark's capture engine for processing and later displayed in Wireshark, while display filters define which frames are displayed after they are captured. We can redefine display filters without restarting the capture, which is not the case for capture filters; hence, we need to be cautious with their usage. The Expression option on the side helps us create the filter expressions in an easy way, as there is a huge list of filters, and we don't need to waste our time memorizing them.

Wireshark aids by providing visual indicators whether or not a filter used by us is correct (accepted by Wireshark), by changing the background color to red (wrong filter expression) and to green (correct filter expression) as shown in the following screenshot:

Wrong filter

This is the correct filter will look something like this:

Correct filter


You may notice that sometimes the filter shows a yellow background. This might be due to the fact that the filter expression which you entered is not working as expected. An example could be using instead of the correct filter, that is, .

Once the filter expression is ready, you can either press ENTER, or click on Apply for that filter to be applied on the selected list of packets, and you can remove the current filter expression by clicking on Clear.


Applying display filters on a large capture might take some time, and the progress is visible.

After spending some time creating filters, you will notice that you are combining a lot of them using multiple AND (&&) and OR (||) statements and would also want to use the same filter expression in another capture file. For this purpose, you can save your filters in Wireshark, using the Save button at the extreme right of filter toolbar.

Filter to see only HTTP GET requests made by

Capture frame

This frame helps in identifying the interface to start capturing packets from and the associated options with those interfaces.

Here, at the capture frame, we have three ways to start capturing:

  • Interface List: If you're not sure about the active interface to use for capture, selecting this option is a good choice as it gives you a complete list of the available interfaces, IP addresses in use, and the number of packets transmitted per interface. Using this information, we can easily figure out which interface to use to capture traffic.

    Simply the interface, and click on Start to begin the capture.


    You may choose to click on Options before starting the capture. However, this will open the same capture options discussed in Capture Options.

  • Start: This is the simplest and quickest way to start the capture if you know the network interface(s) in question. All you need to do is select the interface(s) from the available list of interfaces and click on Start.

  • Capture Options: This is an advanced way to start a capture, as it provides tweaking capabilities before a capture is even started.

    Here you can an individual interface to capture or Capture on all interfaces, to do exactly what it says.

    By clicking on Capture Filter, you can select/create any filter before capturing begins. After this, you have some options that can be tweaked to perform unattended captures. For example, we want to create multiple files of 200 KB and stop the capture automatically after 2 minutes. The following screenshot shows how this is done:

    Configuring for multiple files

    The following are the resultant files:

    Multiple files


Wireshark saves the filename in FileName_FileNumber_YEARMMDDHRMINSEC.pcap format.

For details regarding the other options on this frame please go to https://www.wireshark.org/docs/wsug_html_chunked/ChCapCaptureOptions.html.

Capture Help

The following is how the Capture Help menu looks and later on we will see a description of the available options under this menu.

Here, we have two options that can help us with capturing using Wireshark in an efficient manner. Clicking on these options will redirect the user to:

The Files menu

The following is how the Files menu looks and later on we will see a description of the available options under this menu.

This menu provides options to:

  1. Browse and open an already captured trace file.

  2. Click and open any recently opened file. The number of recent files to be listed here can be modified by going to Edit | Preferences | User Interface and then editing the Maximum recent files option to the value of choice.

  3. Download sample capture files available at the official site (http://wiki.wireshark.org/SampleCaptures).


As the name suggests, clicking on the options listed under this category redirects us to Wireshark's online resources.

The Status bar

The Status bar is used to display informational messages. It is divided into the following three sections:

  • The left side of the Status bar shows context-related information, which includes the colorized bullet indicating the current expert-info level and an option to edit or add capture comments.

  • The middle part shows the current number of packets and the load time.

  • The right side of the Status bar shows the current configuration profile in use. By default, there are three profiles present [Default, Bluetooth, and Classic], and one can always create and use new configuration profiles as required.

    Status bar


First packet capture

Let's get started with our first packet capture using Wireshark by following these steps:

  1. Launch Wireshark

  2. Select the correct interface to capture traffic. This can be done by navigating to the Menu bar and clicking on Capture | Interfaces (As a shortcut, we may choose Ctrl + I). Once we have the Wireshark: Capture Interfaces window open, perform the following steps:

    1. Select the Internet-facing interface (for example, Wi-Fi in my case). A good indication of the active interface is the Packets and Packets/s column on the right-hand side of the window as shown in the following screenshot:

    2. After selecting the interface, click on the Options button, as highlighted in the screenshot, and the Wireshark: Capture Options window pops up as shown in the following screenshot:


      Enter host example.com in the Capture Filter field, as we only want to capture traffic to and from the domain example.com, and click on the ENTER key. We will discuss capture filters in detail in the next chapter.

  3. The next step is to let Wireshark run in the background and open a browser of your choice (for example, Mozilla Firefox in my case) and browse example.com.

  4. Once example.com loads, navigate to Wireshark, and stop the packet capture, by clicking on the Stop button in the main toolbar.

    Once stopped, the capture appears as shown in the following screenshot:

    In the preceding screenshot, we can see Wireshark's menu bar, main toolbar and filter toolbar followed by three different panes and the Status bar. The three panes are as follows:

    1. Packet List pane: This pane reflects the packets captured by Wireshark and some basic details about those packets. For example, the first packet in our capture is an SYN packet of the three-way handshake from the client to the server.


      Please note that the packets displayed under this pane could be affected by the display filter, if any, used in the filter toolbar.

    2. Packet Details pane: If we select any packet in the Packet List pane, its details are shown under this pane. For example, after selecting the first packet in our capture, we can look at the packet at a more granular level, that is, the changes it undergoes at different layers of networking (for example, source and destination ports under the Transmission Control Protocol (TCP), that is, the Transport layer of the TCP/IP model).

      This pane shows the protocols and protocol fields in a tree format and also displays any links when the current packet in question has a relationship to another packet in the same capture (for example, a request and response relationship for a single communication).

    3. Packet Bytes pane: This pane displays the bytes of the selected packet in a hex dump format and is affected by what is selected in the previous pane, that is, the Packet Details pane.

  5. The final step is to save the captured packets. We can do this by navigating to the menu bar, clicking on File | Save and saving it with an appropriate name in the directory of your choice.

Congratulations! With this, we have successfully captured and saved our first trace file.



In this chapter, we went over the foundations of sniffing and its practical importance in the real world, the different tools available at our disposal to perform sniffing, and understanding the Wireshark GUI to quickly get started with sniffing and perform our first packet capture. We shall begin the analysis part in the next chapter.

About the Author

  • Piyush Verma

    Piyush Verma currently serves as a senior security analyst at NII Consulting, India, and enjoys hacking his way into organizations (legally) and fixing the vulnerabilities encountered. He strongly values hands-on experience over certifications; however, here are a few certifications he has earned so far: OSCP, CEH, CHFI, CCNA Security, and CompTIA Security+. He is a highly sought-after professional speaker and has delivered security training to folks working in public, private, and "secret" sectors. He can be contacted at https://in.linkedin.com/in/infosecpiyushverma.

    Browse publications by this author

Latest Reviews

(3 reviews total)
A good intermediate discussion of how Wireshark can be used to ensure the security of your network.

Recommended For You

Book Title
Access this book, plus 7,500 other titles for FREE
Access now