Protocol analysis is examination of one or more fields within a protocol’s data structure during a network investigation. Understanding the bits and pieces of a network protocol can greatly help during an investigation. This article discusses analyzing some high level network protocols that are commonly used by applications. We will specifically use wireshark to do protocol analysis in this article. Wireshark has the ability to decode the stream of bits flowing across a network and show us those bits in the structured format of the protocol.
What is a Network Protocol
As protocol is a set of standards and rules that has to be followed in order to accomplish a certain task, in the same way network protocol is a set of standards and rules that defines how a network communication should be done.The standards that are used for the Internet are called Requests For Comment (RFC). RFCs are numbered from 1 onwards.There are more than 4,500 RFCs today. Many of them have become out of date, so only a handful of the first thousand RFCs are still used today. The International Standardization Office (ISO) has standardized a system of network protocols called ISO OSI. I am sure you must be already knowing or would have already heard about the OSI Layers.
The OSI model breaks the various aspects of a computer network into seven distinct layers, each depending on one another. The following section briefly discusses each layer in the OSI model.
The physical layer is responsible for activating the physical circuit between the Data Terminal Equipment and Data Circuit-terminating Equipment, communicating through it, and then deactivating it. To put it differently, the physical layer describes the electric or optical signals used for communicating between two computers. Physical circuits are created on the physical layer.
Data Link Layer
The data link layer is responsible for the node to node delivery of the message. The main function of this layer is to make sure data transfer is error-free from one node to another, over the physical layer. When a packet arrives in a network, it is the responsibility of the Data Link Layer to transmit it to the Host using its MAC address.
Data Link Layer is divided into two sub layers :
– Logical Link Control (LLC)
– Media Access Control (MAC)
The network layer ensures the data transfer between two hosts located in different networks. The basic unit of transfer is a datagram that is wrapped (encapsulated) in a frame. The datagram is also composed of a header and data field.
Transport layer provides services to the application layer and takes services from the network layer. The data in the transport layer is referred to as Segments. It is responsible for the End to End Delivery of the complete message. The transport layer also provides the acknowledgement of the successful data transmission and re-transmits the data if an error is found.
This layer is responsible for establishment of connection, maintenance of sessions, authentication and also ensures security.
Presentation layer is also called the Translation layer. The data from the application layer is extracted here and manipulated as per the required format to transmit over the network.
The application layer defines the format in which the data should be received from or handed over to the applications. For example, the OSI Virtual Terminal protocol describes how data should be formatted as well as the dialogue used between the two ends of the connection.
A look into common protocols in Wireshark
We discussed various layers in the OSI model. Now, let’s go through some examples and see how these look in the real world. As mentioned earlier, we are going to use wireshark to see what these packets look like.
Open Wireshark on the analysis laptop/Virtual Machine(Kali Linux Virtual Machine in this case). To listen on every available interface, select any as shown in the figure below.
Once Wireshark is launched, we should see a lot of packets being captured since we chose all interfaces. Enter http as the filter which will tell wireshark to only show http packets although still it’ll capture the other protocol packets as well.
Visit demo.testfire.net/login.jsp, which is a demo website that uses http instead of https, so we will be able to capture the clear text credentials if we login using the login page.
Enter some random credentials into the login form and click the Login button.
Now switch back to the Wireshark window and you will see that it’s now populated with some http packets. It should be noted that, currently Wireshark shows only http packets as we have applied the http filter earlier.
Let us look for the packets with POST method as POST is a method commonly used for login. Following is a good candidate to check if any credentials are being sent over the network.
Right click on this packet and navigate to follow | TCP Stream. You will be able to see the full http data, which also contains the clear text credentials. This looks as follows.
Data sent using any protocol without encryption can be captured and analysed the same way to obtain some interesting details. Depending on the protocol being used, the data may be located in a different format. Let us see another example with File transfer protocol.
Once again launch Wireshark and listen on all interfaces and apply the filter as ftp this time as shown below.
To be able to capture some FTP traffic using Wireshark, open your terminal and connect to the ftp.slackware.com as shown below.
Specify the user: anonymous and any password of your choice and then hit enter and go back to the wireshark window. The captured FTP traffic should look as follows.
As we can observe in the preceding picture, Wireshark has captured a lot of ftp traffic. Now, let’s analyze the packet we are interested in. This the request packet which contains the username we had specified, right click on that packet and navigate to follow | TCP Stream to get the full details of it.
As we can see, we have captured and obtained FTP credentials using Wireshark.
When traffic contains clear text protocols such as HTTP and FTP, analysis is easier as the data we are looking for is typically available in clear text as we have seen in our examples. When traffic contains encrypted communications, traffic analysis becomes much harder. The following example shows some encrypted traffic being captured using Wireshark. For the demo purposes, we’ll see how the sftp connection looks like, which uses ssh protocol for handling the secure connection. We will be using a free public sftp server test.rebex.net. The credentials for it are demo:password. Before logging in, open wireshark and listen on all interfaces and then open a new terminal and connect to the sftp server.
Switch back to the Wireshark window and observe the traffic being generated. As we can see in the following figure, we have a lot of ssh traffic going on.
If we try to select any packet and navigate to follow | tcp stream as usual, we’ll notice that we are not able to read the clear text traffic since it’s encrypted. This looks as follows.
The preceding figure shows the tcp stream of an SSH packet and it appears as gibberish the traffic is encrypted.
During network forensic investigations, we often come across various protocols being used by malicious actors. For instance, a malicious actor may choose to use HTTP(S) or DNS for data exfiltration and it is worth understanding how these protocols may look like when analysed using a tool like Wireshark. This will give some insights into what attacker controlled domain the compromised machine is communicating with and what kind of data is being exfiltrated if the traffic is being sent in clear text. However, the use of clear text traffic is highly unlikely in modern day attacks. In such cases, we may have to rely on techniques like reverse engineering if the attack happened through a malicious binary.
Network Forensics by Ric Messier – https://www.amazon.com/Network-Forensics-Ric-Messier/dp/1119328284
Internet Forensics by R Jones – https://www.amazon.com/Internet-Forensics-Digital-Evidence-Computer/dp/059610006X
Network Forensics by Sheriff Davidoff, Jonathan Ham – https://www.amazon.com/Network-Forensics-Tracking-Hackers-Cyberspace/dp/0132564718
We've encountered a new and totally unexpected error.
Get instant boot camp pricing
A new tab for your requested boot camp pricing will open in 5 seconds. If it doesn't open, click here.