Skip to main content

Deep Dive into Network Monitoring

·1489 words·7 mins· loading · loading ·
Aditya Hebballe
Author
Aditya Hebballe
OSCP Certified Penetration Tester
Table of Contents

Network monitoring is essential for ensuring the reliability, security, and performance of computer networks. It involves continuously observing network traffic to detect and respond to anomalies, optimize resource allocation, and maintain uptime.

It also helps keep a network secure by helping us identify suspicious activity occurring in the network.

We will use WireShark which is a powerful open-source network protocol analyzer.
This blog assumes you have a basic idea about computer networks. If not I would recommend learning about various networking protocols, difference between hubs and switches, and the OSI model.

What are Packets
#

Packets are used in various networking protocols (like TCP/IP) to enable efficient and reliable communication between devices on a network.
Packets contain 2 main components:

  1. Header: - This part includes metadata such as the source and destination IP addresses, protocol information, and other control data necessary for routing the packet through the network.
  2. Payload: This part contains the actual data being transmitted, such as a portion of a file, a message, or any other type of data

Wireshark is a packet capture tool and captures packets as they travel across a network, providing detailed information about each packet, including:

  • Source and destination IP addresses
  • Protocols (e.g., TCP, UDP, HTTP, LDAP)
  • Packet sizes
  • Data payloads

Spoofing To Obtain Traffic
#

If you want to look at only the traffic originating from your interface and coming back to you then you don’t have to do this. You also don’t need to do this if you can set up Port spanning on your switch.

We are going to use ettercap to perform ARP spoofing (pretending to be another device), this will let us intercept the communication between two devices on the network.

Install ettercap and follow along.

Deep Dive into Network Monitoring_5.png
Select an interface and click on the tick mark

Deep Dive into Network Monitoring_7.png
Now we can scan for hosts

Deep Dive into Network Monitoring_8.png
Click on the Host List button to view all the hosts available
Deep Dive into Network Monitoring_9.png
We can see the hosts available

Deep Dive into Network Monitoring_10.png
Now u can select multiple hosts and add them as targets

Make sure that your gateway is in a different target pool than the hosts that you actually want to do some ARP Spoofing on, this is because we want both ends of the communication stream i.e response and request. No problem if you did not understand this as I will demonstrate this.

To find your gateway:

ip route | grep default

Deep Dive into Network Monitoring_11.png
This will be your gateway.

Deep Dive into Network Monitoring_12.png
Now that we know our gateway we will add it to target pool 1

Deep Dive into Network Monitoring_13.png
Then we will add the target host to target pool 2

Deep Dive into Network Monitoring_14.png
After this we can proceed with starting the ARP Spoofing

Now we can intercept these ARP requests in Wireshark. We can also use arpspoof instead of ettercap.

ARP spoofing is rare today due to network security improvements like dynamic ARP inspection, encrypted traffic, secure protocols, and intrusion detection systems, all of which make it harder for attackers to exploit ARP vulnerabilities. I have included this section for the sake of completeness.

Familiarizing With WireShark
#

First things first to make your life easier set the Main Toolbar style to Icons & Text:

Deep Dive into Network Monitoring.png
This will help you learn what each button in the toolbar does by labeling it. Feel free to adjust the appearance to your liking.

In the home page you will see all the available interfaces and the activity occurring in that interface next to it. Choosing any will show packets captured from all interfaces

Deep Dive into Network Monitoring_1.png
Loopback interface helps capture packets from for example a web server on localhost.

Deep Dive into Network Monitoring_15.png
We can also check out other options

  • Resolve MAC addresses -> Vendor names resolved from MAC addresses
  • Resolve network names -> Resolve IP to DNS (This will generate a flood of DNS lookups in the packet list).
  • Resolve transport names -> Instead of port 80 show http or instead of 22 show SSH
    Beware that these options might slow down the capture so it is personal preference.

Now that we are familiar with it we will see how to use it.

Wireshark - Basic Usage
#

Now I will show some traffic occurring in eth0 interface on my VM

Deep Dive into Network Monitoring_2.png
This information can be quite overwhelming, wireshark does deep protocol decoding and a lot of translating to English from binary to make this data human readable. What we are capturing here are actually frames.

  • Before we dive into this data we will find how to save this packet capture data:

    Deep Dive into Network Monitoring_3.png

  • We can save the packet capture in various formats like pcapng, pcap, etc.

    Deep Dive into Network Monitoring_4.png

These are the most used and you can see the pros and cons:

Deep Dive into Network Monitoring_29.png

Searching & Sorting
#

We can see various ways to filter the data that we can capture.

Deep Dive into Network Monitoring_16.png
We can filter with host IP

This will filter the packets that either have source or destination of the host IP I have mentioned

  • We can also sort based on protocol, source or destination so play around with it:

    Deep Dive into Network Monitoring_17.png
    Note that the protocols are color coded and you can see the colors in the scrollbar.

  • We can also search for packets using the shortcut ctrl + F :

    Deep Dive into Network Monitoring_20.png
    We can see that we get a packet containing the word we searched for.

  • Now we can begin analyzing the data, click on it to bring up the data related to that specific packet.

    Deep Dive into Network Monitoring_21.png

    Now in the data we can see:

  • Frame - Layer 1 header and we can see that we captured 1712 bits

  • Ethernet - Layer 2 and we can see that the type is IPv4, this tells us that we are looking at IPv4 data and in the next header we can see the IPv4 content

  • IPv4 - Layer 3 and we can see the source and destination and various IP headers as well.

Deep Dive into Network Monitoring_22.png

We can also see that the protocol is UDP and that is the next header as well.

Deep Dive into Network Monitoring_23.png

  • UDP - Layer 4 and we can see the Destination and Source Ports
  • SSDP - This particular packet uses SSDP but you might see HTTP, DHCP, etc. This occurs at the application layer(layer 7).This is the SSDP data:
    Deep Dive into Network Monitoring_24.png

    And that is how you pull apart a frame to look at the individual headers and also the data from the application layer.

This is an example from a machine called Support from HTB where we could see clear text password in LDAP:

Deep Dive into Network Monitoring_19.png

Some other filters
#

  • ip.addr == x.x.x.x - Sets a filter for any packet that has x.x.x.x as the source or destination IP address
    • Can also apply not filter like so !(ip.addr == x.x.x.x)
  • http or dns - Narrow down to http protocol or DNS.
  • ftp - For FTP protocol only obviously.
  • tcp.port==xxx - Sets filters for any TCP packet with a specific source or destination port
  • tcp.flags.reset==1 - Indicates a TCP RST (Reset) packet, which is used to abruptly terminate a connection. Use this filter to identify when a connection was forcefully closed(Troubleshooting for example).
  • tcp contains xxx - Display all TCP packets that contain a certain term.
  • !(arp or icmp or dns) - Filter out certain protocols
  • dns.flags.rcode != 0 - Indicates which dns requests couldn’t be correctly resolved.
  • http.request - Filters all HTTP GET and POST requests

Streams
#

Whenever you start communicating with a particular website what happens is that you have started a conversation of requests and responses and this can be tracked.

  • Now we will open our browser and open a website like http://example.com

    Deep Dive into Network Monitoring_25.png

  • Now right click on a packet and click on Follow then TCP Stream:

    Deep Dive into Network Monitoring_26.png
    We can see the TCP messages. This is the entire conversation

  • This is another example:

    Deep Dive into Network Monitoring_27.png
    As we can see Wireshark makes it very easy to keep track of the entire conversation occurring. This really helpful for tracking web activity in particular.

We can also use the Follow HTTP Stream option to get the HTTP conversation:

Deep Dive into Network Monitoring_28.png

Analysis
#

Now for some analysis we can use these Sample captures from here

I will use this. Download and unzip it and open it in wireshark using the toolbar File -> Open or just Ctrl + O.

  • Now click on the circle icon in the bottom left corner of wireshark.

    Deep Dive into Network Monitoring_30.png

  • We can see that there are few warnings, notes, and chat, we can even see errors sometimes

    Deep Dive into Network Monitoring_31.png

  • Errors can look like so in the packet list so they can be easily recognized:

    Deep Dive into Network Monitoring_32.png

What’s next
#

To wrap things up, if you’re looking to expand your skills in network traffic analysis, I highly recommend exploring more pcap files at http://www.pcapr.net/. By diving into Wireshark and gaining a deep understanding of network traffic, you’ll not only improve your ability to spot vulnerabilities but also elevate your overall pentesting expertise.

The more familiar you become with network protocols, traffic patterns, and potential exploits, the sharper your pentesting skills will be. I will conclude this blog here as I don’t want to go on and on about Wireshark. Also check out tcpdump which is a CLI tool similar to Wireshark. Thank you for reading and bye!

Related

Which Linux Distro is the best for you?
·1113 words·6 mins· loading · loading
This is a quick little blog about my Linux journey and how you could start yours. I started my Linux journey when I realized how much easier it was to install packages, but the real game-changer came from the significant performance boost.
How I Passed the OSCP in Just 6 Months
·2549 words·12 mins· loading · loading
I am a student pursuing a Bachelor’s degree in Computer Science and Engineering and I passed the OSCP just six months into my cybersecurity journey, despite having limited prior experience.
About
·60 words·1 min· loading · loading
As a certified OSCP and a Computer Science student, I’m passionate about ethical hacking and cybersecurity. Join me as I continue pushing boundaries, exploring new vulnerabilities, and breaking limits (and warranties).