Answer the following questions about the HTTP request and response process.
- What type of architecture does the HTTP request and response process occur in?
- Client-server architecture, this is in the Application Layer 7
- What are the different parts of an HTTP request?
-
The Request Line is the first portion of the request.
- Then the HTTP method.
- The request URL.
- HTTP protocol version.
-
Request Header, this is a header that can be used in an HTTP request to provide information about the requested context.
-
Request Body, data sent by the client to the API.
- Which part of an HTTP request is optional?
- Request Body
- What are the three parts of an HTTP response?
- Status Line
- Header
- Body is optional
- Which number class of status codes represents errors?
- 400 codes indicate client-side errors.
- 500 codes indicate server-side errors.
- What are the two most common request methods that a security professional will encounter?
- GET, request that asks for data from a server.
- POST, sends data to specified resource.
- Which type of HTTP request method is used for sending data?
- POST
- Which part of an HTTP request contains the data being sent to the server?
- The request body.
- In which part of an HTTP response does the browser receive the web code to generate and style a web page?
- The response body.
Answer the following questions about curl
:
- What are the advantages of using
curl
over the browser?
- You can use cURL for many beneficial things such as:
- Authentication
- SSL connections.
- HTTP post requests.
- Proxy support.
- FTP uploads.
- Downloading files.
- Which
curl
option is used to change the request method?
- You can use the
-X
or--request
options.
- Which
curl
option is used to set request headers?
- You can use the
-H
or--header
options.
- Which
curl
option is used to view the response header?
- You can use the
-i
or--include
options.
- Which request method might an attacker use to figure out which HTTP requests an HTTP server will accept?
- GET request because the attacker could request data from a server to figure out which HTTP request a server will accept as well as the error codes to see what pages are real or fake.
Recall that HTTP servers need to be able to recognize clients from one another. They do this through sessions and cookies.
Answer the following questions about sessions and cookies:
-
Which response header sends a cookie to the client?
HTTP/1.1 200 OK Content-type: text/html Set-Cookie: cart=Bob
- The set-cookie will send the cookie to the client.
-
Which request header will continue the client's session?
GET /cart HTTP/1.1 Host: www.example.org Cookie: cart=Bob
- The cookie will continue and remember where the clients last place was in the session.
Look through the following example HTTP request and response and answer the following questions:
HTTP Request
POST /login.php HTTP/1.1
Host: example.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 34
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Mobile Safari/537.36
username=Barbara&password=password
- What is the request method?
- POST
- Which header expresses the client's preference for an encrypted response?
- Upgrade-Insecure-Requests: 1
- Does the request have a user session associated with it?
- The session has not been established yet.
- What kind of data is being sent from this request body?
-
Login credntials were sent.
username=barbara password=password
HTTP Response
HTTP/1.1 200 OK
Date: Mon, 16 Mar 2020 17:05:43 GMT
Last-Modified: Sat, 01 Feb 2020 00:00:00 GMT
Content-Encoding: gzip
Expires: Fri, 01 May 2020 00:00:00 GMT
Server: Apache
Set-Cookie: SessionID=5
Content-Type: text/html; charset=UTF-8
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type: NoSniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
[page content]
- What is the response status code?
- 200
- What web server is handling this HTTP response?
- Apache webserver
- Does this response have a user session associated to it?
- Yes, Set-Cookie: SessionID=5
- What kind of content is likely to be in the [page content] response body?
- The code to the website, as seen in Content-Type: text/html (Text / HTML - Detail of the page configuration)_
- If your class covered security headers, what security request headers have been included?
- HTTP Strict Transport Security (HSTS) - Strict-Transport-Security: max-age=31536000; includeSubDomains
- X-Content-Type-Options HTTP - X-Content-Type: NoSniff
- X-Frame-Options HTTP - X-Frame-Options: DENY
- Cross Site Scripting Protection (X-XSS) - X-XSS-Protection: 1; mode=block
Answer the following questions about monoliths and microservices:
- What are the individual components of microservices called?
- There are 8 core components:
- Clients
- Identity Providers
- API Gateway
- Messaging Formats
- Databases
- Static Content
- Management
- Service
- What is a service that writes to a database and communicates to other services?
- API
- What type of underlying technology allows for microservices to become scalable and have redundancy?
- Containers allow microservices to be scalable along with Load Balancing.
Answer the following questions about multi-container deployment:
- What tool can be used to deploy multiple containers at once?
- Docker-compose used to deploy multiple containers.
docker-compose up
used to launch the containers.
- What kind of file format is required for us to deploy a container set?
YAML
- Which type of SQL query would we use to see all of the information within a table called
customers
?
- SELECT * from customers;
-
SELECT * from customers where firstname='Bob' AND lastname='Smith';
-
- Which type of SQL query would we use to enter new data into a table? (You don't need a full query, just the first part of the statement.)
- INSERT INTO customers;
-
INSERT INTO customers (key_1,key_2,...) VALUES ('value_1','value_2',...);
-
- Why would we never run
DELETE FROM <table-name>;
by itself?
- This deletes the enire table if you include
where
then you can specify, with out thewhere
the sql does not know which table(s) and deletes them all.
First, using Docker Compose, navigate to the Day 1 WordPress activity directory and bring up the container set:
/home/sysadmin/Documents/docker_files
Using curl
, you will do the following for the Ryan user:
-
Log into WordPress and save the user's cookies to a cookie jar.
-
Test a WordPress page by using a cookie from the cookie jar.
-
Pipe the output from the cookie with
grep
to check for authenticated page access. -
Attempt to access a privileged WordPress admin page.
Navigate to ~/Documents
in a terminal to save your cookies.
-
Construct a
curl
request that enters two forms:"log={username}"
and"pwd={password}"
and goes tohttp://localhost:8080/wp-login.php
. Enter Ryan's credentials where there are placeholders.- Question: Did you see any obvious confirmation of a login? (Y/N)
-
Construct the same
curl
request, but this time add the option and path to save your cookie:--cookie-jar ./ryancookies.txt
. This option tellscurl
to save the cookies to theryancookies.txt
text file. -
Read the contents of the
ryancookies.txt
file.- Question: How many items exist in this file?
Note that each one of these is a cookie that was granted to Ryan after logging in.
-
Craft a new
curl
command that now uses the--cookie
option, followed by the path to your cookies file. For the URL, usehttp://localhost:8080/wp-admin/index.php
.- Question: Is it obvious that we can access the Dashboard? (Y/N)
-
Press the up arrow on your keyboard to run the same command, but this time, pipe
| grep Dashboard
to the end of your command to return all instances of the wordDashboard
on the page.- Question: Look through the output where
Dashboard
is highlighted. Does any of the wording on this page seem familiar? (Y/N) If so, you should be successfully logged in to your Editor's dashboard.
- Question: Look through the output where
-
Finally, write a
curl
command using the same--cookie ryancookies.txt
option, but attempt to accesshttp://localhost:8080/wp-admin/users.php
.- Question: What happens this time?