0% found this document useful (0 votes)
36 views17 pages

HTTP in Detail 1690850720

Uploaded by

sa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views17 pages

HTTP in Detail 1690850720

Uploaded by

sa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

CyberHost Assignment No: 01

Name: Ishwar Bundele


Email ID: [email protected]
Mob No: 7775999686
 HTTP In Detail

Task 1: What is HTTP? (Hyper Text Transfer Protocol)


 HTTP is what's used whenever you view a website, developed by Tim
Berners-Lee and his team between 1989-1991. HTTP is the set of rules
used for communicating with web servers for the transmitting of webpage
data, whether that is HTML, Images, Videos, etc. The client-server model
used by HTTP is known as the request-response model. A web server
replies to an HTTP request from a client (often a web browser) by
providing the requested data or resource. HTTP is a stateless protocol,
which means that each request made by a client to a server is
independent of one another and that the server does not keep track of
prior requests. Web applications can scale more easily as a result, but
maintaining user state over many requests necessitates the adoption of
extra strategies like cookies or sessions. The HTTP protocol specifies a
number of methods (sometimes referred to as verbs) that describe the
kind of action to be taken on the requested resource. GET (retrieve data),

1
CyberHost Assignment No: 01

POST (submit data to be processed), PUT (update a resource), and


DELETE (delete a resource) are common HTTP methods.
Q. What is HTTPS? (Hyper Text Transfer Protocol Secure)
 HTTPS is the secure version of HTTP. HTTPS data is encrypted so it not
only stops people from seeing the data you are receiving and sending, but
it also gives you assurances that you're talking to the correct web server
and not something impersonating it. By encrypting the data transferred
between the client and the server, HTTPS adds an extra degree of
security by guaranteeing the confidentiality, integrity, and authenticity of
the data sent.Encryption: HTTPS encrypts data sent between the client
and the server using cryptographic protocols like SSL (Secure Socket
Layer) or TLS (Transport Layer Security). Through the use of encryption,
it is made impossible for anyone to access or alter the data even if it is
intercepted while in transit. HTTPS also makes guarantee that the data
sent by the server and received by the client are same. It employs
message authentication codes (MACs) and digital signatures to identify
any unauthorised data damage or change. A website owner must obtain
an SSL/TLS certificate from a reputable certificate authority (CA) in order
to enable HTTPS on their website. Installed on the server, this certificate
is used to confirm the legitimacy of the website. The server displays its
SSL/TLS certificate to the client when they access an HTTPS website,
and the client's browser checks the certificate against a list of trustworthy
CAs. A secure connection is made and data exchanged through an
encrypted channel if the certificate is reliable and trusted.

 Answer the following questions given below.


1. What does HTTP stand for?
 Hyper Text Transfer Protocol.

2. What does the S in HTTPS stand for?


 Secure

3. On the mock webpage on the right there is an issue, once


you've found it, click on it. What is the challenge flag?

2
CyberHost Assignment No: 01

 THM{INVALID_HTTP_CERT}

Task 2: Requests And Responses.


 A website owner must obtain an SSL/TLS certificate from a reputable
certificate authority (CA) in order to enable HTTPS on their website.
Installed on the server, this certificate is used to confirm the legitimacy of
the website. The server displays its SSL/TLS certificate to the client when
they access an HTTPS website, and the client's browser checks the
certificate against a list of trustworthy CAs. A secure connection is made
and data exchanged through an encrypted channel if the certificate is
reliable and trusted.

Q. What is URL? (Uniform Resource Locator)


 Uniform Resource Locator, or URL, is a term. It serves as a pointer or
address for finding resources on the Internet. Users can access a variety
of resources, including web pages, photographs, videos, documents, and
more, using a URL, which is a standardised structure. The protocol
specifies the type of communication to be utilised in order to access the
resource. The most widely used protocols are "http://" for unencrypted
web pages, "https://" for secure encrypted web pages, "ftp://" for file
transfers, and "mailto:" for email addresses. The domain name is the
resource's server's name that can be read by humans. For instance, the
domain name "www.example.com" appears in the URL
"https://www.example.com". The server's specific communication
channel that the client should connect to is indicated by the port number.
The resource's precise location on the server's file system or inside its
web directory structure is indicated by its path. Typically, it comes after
the domain name and is divided by slashes (/). For instance, the route in
"https://www.example.com/products/shoes" is "/products/shoes". When
requesting a resource, query parameters are used to communicate extra
information to the server. A question mark (?) separates them from the
path, while commas (&) are used to separate multiple arguments. For
instance, the query parameters "q=shoes" and "category=footwear" are
used in the URL
"https://www.example.com/search?q=shoes&category=footwear".

3
CyberHost Assignment No: 01

 Scheme: This instructs on what protocol to use for accessing the


resource such as HTTP, HTTPS, FTP (File Transfer Protocol).
 User: Some services require authentication to log in, you can put a
username and password into the URL to log in.
 Host: The domain name or IP address of the server you wish to access.
 Port: The Port that you are going to connect to, usually 80 for HTTP and
443 for HTTPS, but this can be hosted on any port between 1 - 65535.
 Path: The file name or location of the resource you are trying to access.
 Query String: Extra bits of information that can be sent to the requested
path. For example, /blog?id=1 would tell the blog path that you wish to
receive the blog article with the id of 1.
 Fragment: This is a reference to a location on the actual page
requested. This is commonly used for pages with long content and can
have a certain part of the page directly linked to it, so it is viewable to the
user as soon as they access the page.

 Making a Request:

4
CyberHost Assignment No: 01

 It's possible to make a request to a web server with just one line "GET /
HTTP/1.1"

But for a much richer web experience, you’ll need to send other data as
well. This other data is sent in what is called headers, where headers
contain extra information to give to the web server you’re communicating
with, but we’ll go more into this in the Header task.

Example Request:
 GET / HTTP/1.1
Host: tryhackme.com
User-Agent: Mozilla/5.0 Firefox/87.0
Referer: https://tryhackme.com/

To breakdown each line of this request:

5
CyberHost Assignment No: 01

Line 1: This request is sending the GET method ( more on this in


the HTTP Methods task ), request the home page with / and telling the
web server we are using HTTP protocol version 1.1.
Line 2: We tell the web server we want the website tryhackme.com
Line 3: We tell the web server we are using the Firefox version 87
Browser
Line 4: We are telling the web server that the web page that referred us
to this one is https://tryhackme.com
Line 5: HTTP requests always end with a blank line to inform the web
server that the request has finished.
 Example Response:

HTTP/1.1 200 OK
 Server: nginx/1.15.8
 Date: Fri, 09 Apr 2021 13:34:03 GMT
 Content-Type: text/html
 Content-Length: 98

 <html>
 <head>
 <title>TryHackMe</title>
 </head>
 <body>
 Welcome To TryHackMe.com
 </body>
 </html>
 To breakdown each line of the response:

Line 1: HTTP 1.1 is the version of the HTTP protocol the server is using
and then followed by the HTTP Status Code in this case "200 Ok" which
tells us the request has completed successfully.

Line 2: This tells us the web server software and version number.

6
CyberHost Assignment No: 01

Line 3: The current date, time and timezone of the web server.

Line 4: The Content-Type header tells the client what sort of information
is going to be sent, such as HTML, images, videos, pdf, XML.

Line 5: Content-Length tells the client how long the response is, this way
we can confirm no data is missing.

Line 6: HTTP response contains a blank line to confirm the end of the
HTTP response.

Lines 7-14: The information that has been requested, in this instance
the homepage.

 Answer the following questions given below.


1. What HTTP protocol is being used in the above example?
 HTTP/1.1

2. What response header tells the browser how much data to expect?
 Content-Length

Task 3: HTTP Methods


Several methods, also referred to as HTTP verbs, are defined by HTTP to
describe the kind of operation to be carried out on a resource. Each HTTP
method has a defined function and is used to communicate with the web
server's resources. The most popular HTTP methods are listed here in
full.
 GET Requests: Use the GET technique to get information from the server.
It is a secure and idempotent method, meaning that it shouldn't have any
negative impacts on the server and that multiple, identical GET requests
will result in the same outcome. A web browser normally sends a GET
request to the server to retrieve the associated web page or resource when
it enters a URL or clicks on a link.

 POST: To send data to the server for processing, use the POST method.
It can have unintended consequences for the server (such as data creation,

7
CyberHost Assignment No: 01

modifications, or other state changes) and is not idempotent, which means


that many identical POST requests can result in different results. When
filling out forms on websites, such as those used to submit login information
or make comments on forums, make is frequently used to transmit data to
the server for processing.

 PUT: A resource on the server can be updated using the PUT technique. It
is idempotent, which means that repeated PUT requests that are exactly
the same should have the same effect. PUT is typically used to create a
new resource at a specific URL or to completely replace an existing
resource with a new version.

 DELETE: To remove a resource from the server, use the DELETE method.
The server should delete the associated resource when a client sends a
DELETE request to a certain URL.

 PATCH: A resource on the server can be partially updated using the


PATCH method. Although it is less frequently used than PUT, it
nonetheless enables clients to transmit a set of modifications to be applied
to the resource rather than replacing it entirely. When you wish to change
a resource's individual fields or characteristics without changing the
resource as a whole, PATCH can be helpful.

 Answer the questions below.


1. What method would be used to create a new user account?
 POST
2. What method would be used to update your email address?

 PUT
3. What method would be used to remove a picture you've uploaded to
your account?
 DELETE
4. What method would be used to view a news article?
 GET
8
CyberHost Assignment No: 01

HTTP Status Codes:


 In the previous task, you learnt that when a HTTP server responds, the
first line always contains a status code informing the client of the outcome
of their request and also potentially how to handle it. These status codes
can be broken down into 5 different ranges:

These are sent to tell the client the first part of their request has been
100-199 - Information Response accepted and they should continue sending the rest of their request. These
codes are no longer very common.

This range of status codes is used to tell the client their request was
200-299 - Success
successful.

These are used to redirect the client's request to another resource. This can
300-399 - Redirection
be either to a different webpage or a different website altogether.

400-499 - Client Errors Used to inform the client that there was an error with their request.

This is reserved for errors happening on the server-side and usually indicate
500-599 - Server Errors
quite a major problem with the server handling the request.

Common HTTP Status Codes:


 There are a lot of different HTTP status codes and that's not including
the fact that applications can even define their own, we'll go over the
most common HTTP responses you are likely to come across:
200 - OK The request was completed successfully.

201 - Created A resource has been created (for example a new user or new blog post).

9
CyberHost Assignment No: 01

This redirects the client's browser to a new webpage or tells search engines
301 - Permanent Redirect
that the page has moved somewhere else and to look there instead.

Similar to the above permanent redirect, but as the name suggests, this is
302 - Temporary Redirect
only a temporary change and it may change again in the near future.

This tells the browser that something was either wrong or missing in their
400 - Bad Request request. This could sometimes be used if the web server resource that is
being requested expected a certain parameter that the client didn't send.

You are not currently allowed to view this resource until you have
401 - Not Authorised authorised with the web application, most commonly with a username and
password.

You do not have permission to view this resource whether you are logged in
403 - Forbidden
or not.

The resource does not allow this method request, for example, you send a
405 - Method Not Allowed GET request to the resource /create-account when it was expecting a POST
request instead.

404 - Page Not Found The page/resource you requested does not exist.

The server has encountered some kind of error with your request that it
500 - Internal Service Error
doesn't know how to handle properly.

This server cannot handle your request as it's either overloaded or down for
503 - Service Unavailable
maintenance.

Click the "View Site" button on the right to see what some of these HTTP status
messages look like in a browser.

10
CyberHost Assignment No: 01

 Answer the questions below.


1. What response code might you receive if you've created a new user
or blog post article?
 201
2. What response code might you receive if you've tried to access a
page that doesn't exist?
 404
3. What response code might you receive if the web server cannot
access its database and the application crashes?
 503
4. What response code might you receive if you try to edit your profile
without logging in first?
 401

11
CyberHost Assignment No: 01

Headers:
 HTTP headers are parts of the messages used for HTTP requests and
responses that contain extra data about the request or answer. They
inform the server or client of metadata or instructions that will affect how
the message should be processed or handled. In order to identify
content categories, enable authentication, control caching behaviour,
and manage cookies, among other things, HTTP headers are crucial.
Below are a few typical headers in more detail.
Common Request Headers:
 These are headers that are sent from the client (usually your browser) to
the server.
 Host: Some web servers host multiple websites so by providing
the host headers you can tell it which one you require, otherwise
you'll just receive the default website for the server.
 User-Agent: This is your browser software and version number,
telling the web server your browser software helps it format the
website properly for your browser and also some elements of
HTML, JavaScript and CSS are only available in certain browsers.
 Content-Length: When sending data to a web server such as in a
form, the content length tells the web server how much data to
expect in the web request. This way the server can ensure it isn't
missing any data.
 Accept-Encoding: Tells the web server what types of
compression methods the browser supports so the data can be
made smaller for transmitting over the internet.
 Cookie: Data sent to the server to help remember your information
(see cookies task for more information).

Common Response Headers

These are the headers that are returned to the client from the server after a
request.
 Set-Cookie: Information to store which gets sent back to the web
server on each request (see cookies task for more information).

 Cache-Control: How long to store the content of the response in


the browser's cache before it requests it again.

12
CyberHost Assignment No: 01

 Content-Type: This tells the client what type of data is being


returned, i.e., HTML, CSS, JavaScript, Images, PDF, Video, etc.
Using the content-type header the browser then knows how to
process the data.

 Content-Encoding: What method has been used to compress the


data to make it smaller when sending it over the internet.

Cookies
Cookies are little data files that websites place on users' devices (such
computers or smartphones) when they visit them. These text files have
several uses and are crucial to contemporary web browsing. Websites
may track user behaviour, remember user preferences, and improve user
experiences with the aid of cookies. Cookies assist in the maintenance of
user sessions during sessions. A session cookie is created when you
check in to a website to keep you logged in as you visit different pages.
You won't need to log in to each page separately this way. It's important
to keep in mind that while cookies are useful for enhancing user
experiences and enabling various website activities, they have also raised
privacy issues. Modern online browsers offer improved transparency and
control over cookies in response to these worries, enabling users to alter
their privacy preferences. Additionally, laws have been put in place in
some jurisdictions (such as the GDPR in the European Union) to control
cookie usage and safeguard user privacy. Cookies keep track of user
choices and settings, including language, theme, and text size. This
makes it possible for websites to show visitors personalised content
depending on their choices. Only the server has access to and control
over HttpOnly cookies. This improves security by preventing client-side
scripts from accessing private cookie information.
To add an extra layer of protection and prevent unauthorised parties from
intercepting them, secure cookies are only transferred via encrypted
HTTPS connections. When making cross-site queries, the SameSite
property specifies how cookies are transmitted. To regulate cookie
behaviour and stop specific types of attacks like Cross-Site Request
Forgery (CSRF), it can be set to "Strict," "Lax," or "None."

 Types of Cookies
13
CyberHost Assignment No: 01

 Session Cookies: Cookies used during a user's session on a website are


known as session cookies. They are transient and disappear when a
person closes their browser or leaves a website.
 Persistent Cookies: Cookies that remain on the user's device after the
session has ended are known as persistent cookies, in contrast to session
cookies. They are kept on the website until their set expiration date or
unless the user voluntarily
deletes them.
 First-party Cookies: The
website you are currently
viewing is the one who sets
these cookies. They belong to
the same domain as the
website's URL displayed in the
address bar of the browser.
 Third-Party Cookies:
Cookies from other parties:
Cookies from websites other
than the one you are viewing
are known as third-party
cookies. External services like
analytics tools or advertising
networks frequently use them
for tracking and advertising
purposes.

14
CyberHost Assignment No: 01

Q. Which header is used to save cookies to your computer?


 Set-Cookie
Q. Make a GET request to /room?
 THM{YOU'RE_IN_THE_ROOM}
Q. Make a GET request to /blog and using the gear icon set the id
parameter to 1 in the URL field?
 THM{YOU_FOUND_THE_BLOG}

15
CyberHost Assignment No: 01

Q. Make a DELETE request to /user/1?


 THM{USER_IS_DELETED}
Q. Make a PUT request to /user/2 with the username parameter set to
admin?
 THM{USER_HAS_UPDATED}
Q. POST the username of thm and a password of letmein to /login
 THM{HTTP_REQUEST_MASTER}

16
CyberHost Assignment No: 01

This is an emulator for making demo HTTP requests.

17

You might also like