1a1 - HTTP requests

HTTP headers are used to transfer information from the client or server.

The client function can be implemented by the cURL program, which is a good tool for pentesting.

We have the following categories of headers

  • General Headers
  • Entity Headers
  • Request Headers
  • Response Headers
  • Security Headers

General Headers are used to describe the message, not its content. They are found in HTTP requests and responses.

HeaderExampleDescription
DateDate: Wed, 16 Feb 2022 10:38:44 GMTMessage creation date
ConnectionConnection: Keep-AliveDetermines whether the connection should remain open or be closed with the following tags: close or Keep-Alive

Entity Headers are used to describe the content of a message and are found in POST and PUT headers.

HeaderExampleDescription
Content-TypeContent-Type: text/htmlDescribes the type of resource being transferred.
Media-TypeMedia-Type: application/pdfSimilar to the content type, but directly conveys the type of information.
Boundaryboundary=“b4e4fbd93540”Used to separate multiple pieces of data in a single message.
Content-LengthContent-Length: 385Contains the size of the information to be transmitted.
Content-EncodingContent-Encoding: gzipIt transmits a way of encoding information.

Request Headers are used for HTTP requests and has no connection to the content of the information. It has the following headers

HeaderExampleDescription
HostHost: www.inlanefreight.comDescribes the address of the server to which the request is sent.
User-AgentUser-Agent: curl/7.77.0It is used to describe the client agent. This header can be used to determine what program the client is using to connect to the server.
RefererReferer: http://www.inlanefreight.com/Describes where the current demand is coming from.
AcceptAccept: */*Describes what types of information the client can accept. */* means all types of data are allowed.
CookieCookie: PHPSESSID=b4e4fbd93540A cookie record consists of a name=value pair. It is data that is stored on the client and server and serves as an identifier. It is sent to the server on each request to identify the client. It can also be used for session tracking. Multiple cookies can be contained in one header and are separated by a ; .
AuthorizationAuthorization: BASIC cGFzc3dvcmQKOne way to identify a client. After authentication, the server assigns the client a unique token, which is stored on the client side and will be retrieved by the server on each request.

Response Headers are used in the HTTP response header and is also unrelated to context. Age, location, and server data are used in the response header to create context.

HeaderExampleDescription
ServerServer: Apache/2.2.14 (Win32)Contains information about the server
Set-CookieSet-Cookie: PHPSESSID=b4e4fbd93540Contains a cookie record about the user.
WWW-AuthenticateWWW-Authenticate: BASIC realm=“localhost”Informs the client about the possible authentication type

Security Headers are used to set rules and policies for the browser.

HeaderExample
Content-Security-PolicyContent-Security-Policy: script-src ‘self’
Strict-Transport-SecurityStrict-Transport-Security: max-age=31536000
Referrer-PolicyReferrer-Policy: origin