How Web Applications Work
Muneer Ahmad
SOC Analyst | Blue Team | Data Analyst | AI & Machine Learning Enthusiast | Bug Hunter | Penetration Tester |
To identify an anomaly, we should first understand how the technology works. Applications use specific protocols to communicate with each other. In this case, web applications communicate using the Hyper-Text Transfer Protocol (HTTP). Let's take a look at how the HTTP protocol works.
First of all, it's important to know that the HTTP protocol is on layer 7 of the OSI model. This means that protocols such as Ethernet, IP, TCP, and SSL are used before the HTTP protocol.
HTTP communication is between the server and the client. First, the client requests a specific resource from the server. The server receives the HTTP request and sends an (HTTP response) back to the client after passing the request through certain controls and processes. The client's device receives the response and displays the requested resource in an appropriate format.
Let's take a closer look at HTTP requests and HTTP responses.
HTTP Requests
An HTTP request is used to retrieve a specific resource from a web server. This resource can be an HTML file, a video, JSON data, etc. The web server's job is to process the response received and present it to the user.
All requests must conform to a standard HTTP format so that web servers can understand the request. If the request is sent in a different format, the web server will not recognize it and will return an error to the user, or the web server may not be able to provide service (which is another type of attack).
An HTTP request consists of a request line, request headers, and a request message body. The request line consists of the HTTP method and the resource requested from the web server. The request headers contain certain headers that the server will process. The request message body contains the data to be sent to the server.
The image above shows an example of an HTTP request. Let's examine this HTTP request line by line.
HTTP Responses
When the web server receives an HTTP request, it performs the necessary checks and processes and then sends the requested resource to the client. There is no standard process, as there are many technologies and designs involved. The server may pull data from the database depending on what the requested resource is, or it may process the incoming data. However, the HTTP Response Message must reach the client after all the processing.
An HTTP response message contains a Status Line, Response Headers, and a Response Body. The Status line contains the status code (e.g. 200: OK) and HTTP protocol information. Within the Response Header, some headers are used for a variety of purposes. The Response Body contains information about the requested resource.
If a web page has been requested, there will usually be HTML code in the Response Body. When the client receives the HTML code, the web browser will process the HTML code and display the web page.
You can see an HTTP response request in the image above. Let's examine an HTTP response request using this image.
领英推荐
Status Line
The Status Line contains information about the HTTP version and the HTTP Response Status Code. The HTTP Response Status Code is used to describe the status of the request. There are many HTTP response status codes, but they can be summarized as follows:
●? ? ? 100-199: Informational responses
●? ? ? 200-299: Successful responses
●? ? ? 300-399: Redirection messages
●? ? ? 400-499: Client error responses
●? ? ? 500-599: Server error responses
Response Headers
Here are some HTTP Response Headers that you may encounter frequently:
●? ? ? Date: The exact time the server sent the HTTP Response to the client.
●? ? ? Connection: This indicates how the connection is handled, just like the HTTP Request header.
●? ? ? Server: It informs about the operating system of the server and the version of the web server.
●? ? ? Last-Modified: It provides information about when the requested resource was modified. This header is used by the caching mechanism.
●? ? ? Content-Type:? The type of data being sent.
●? ? ? Content-Length: The size of the data sent.?
Response Body
The HTTP response body contains the resource sent by the server and requested by the client.