Introduction
In the world of web security and network troubleshooting, understanding how HTTP traffic flows between a client (like your web browser) and a server is a fundamental skill. An intercepting web proxy sits between the client and the server, allowing you to pause, inspect, and modify web traffic in real-time.
This is a foundational shift for beginners: web applications are not magic pages, but structured HTTP conversations. Once you can read and reason about requests and responses, many later vulnerabilities become much easier to understand.
Before using complex graphical proxy tools, it is crucial to understand the raw components of an HTTP request. In this lab, you will act as your own manual "interceptor." Using the powerful command-line tool curl, you will craft custom HTTP requests, manipulate headers, and send raw data to a local test server. This hands-on approach will demystify how web traffic truly functions under the hood.
Inspect Default HTTP Requests
In this step, you will learn how to inspect the raw details of a standard HTTP request. When you type a URL into your browser, it sends a formatted text message to the server behind the scenes. We will use curl, a command-line tool for transferring data with URLs, to simulate this process and view the hidden text.
To see exactly what curl sends and what the server replies, we use the verbose flag (-v). A local test server has already been started for you in the background on port 8080.
Verbose mode is useful because it exposes the protocol as text. Instead of thinking "the page loaded," you can see which method was used, which path was requested, which headers were sent, and how the server replied.
Run the following command in your terminal to send a default GET request to the local server:
curl -v http://127.0.0.1:8080/
You will see an output similar to this:
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.10.12
< Date: Thu, 12 Mar 2026 00:08:20 GMT
< Content-type: text/plain
<
Method: GET
Path: /
Headers:
Host: 127.0.0.1:8080
User-Agent: curl/7.81.0
Accept: */*
* Closing connection 0
Let's break down what happened: Lines starting with > represent the Request sent by your machine. It includes the HTTP method (GET), the path (/), and default headers like Host and User-Agent.
Lines starting with < represent the Response headers from the server, including the status code (200 OK).
The text at the very bottom is the Response Body. Our test server is designed to echo back exactly what it received, which helps you verify that your request was formatted correctly.
Craft Custom GET Requests
In this step, you will learn how to craft custom GET requests by modifying the URL path and adding query parameters.
When you search for something on a website, the search terms are often appended directly to the URL. These are called query parameters. They start with a question mark ?, and multiple parameters are separated by an ampersand &.
Let's simulate a search request. We will ask the server for the path /search and pass two parameters: q (for query) and lang (for language).
Run the following command. Notice that we wrap the URL in quotes (") to prevent the Linux terminal from misinterpreting the & symbol as a background process command:
curl -v "http://127.0.0.1:8080/search?q=labex&lang=en"
Look at the response body returned by the server:
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /search?q=labex&lang=en HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.10.12
< Date: Thu, 12 Mar 2026 00:08:26 GMT
< Content-type: text/plain
<
Method: GET
Path: /search?q=labex&lang=en
Headers:
Host: 127.0.0.1:8080
User-Agent: curl/7.81.0
Accept: */*
* Closing connection 0
The server successfully received the custom path and the query parameters. In a real-world scenario, a web application would parse q=labex and lang=en from this path to fetch the appropriate search results from its database.
Modify HTTP Headers (User-Agent, Cookie)
In this step, you will learn how to manipulate HTTP headers. Headers are key-value pairs sent in the request that provide metadata about the client or the request itself.
Headers matter because web applications often make trust decisions based on them. Authentication, content negotiation, caching, origin checks, and session state are all heavily influenced by request metadata.
Two very common headers are:
- User-Agent: Tells the server what browser and operating system you are using.
- Cookie: Sends stored session data back to the server to keep you logged in.
Sometimes, servers block requests from command-line tools like curl. To bypass this, you can spoof (fake) your User-Agent to look like a regular web browser. You can also manually inject a Cookie to simulate an authenticated session.
Use the -H flag in curl to add or modify headers. Run the following command to send a custom User-Agent and a fake session Cookie:
curl -v -H "User-Agent: SecretBrowser/1.0" -H "Cookie: session_id=xyz123" http://127.0.0.1:8080/profile
Examine the output:
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /profile HTTP/1.1
> Host: 127.0.0.1:8080
> Accept: */*
> User-Agent: SecretBrowser/1.0
> Cookie: session_id=xyz123
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.10.12
< Date: Thu, 12 Mar 2026 00:08:41 GMT
< Content-type: text/plain
<
Method: GET
Path: /profile
Headers:
Host: 127.0.0.1:8080
Accept: */*
User-Agent: SecretBrowser/1.0
Cookie: session_id=xyz123
* Closing connection 0
Notice how the > lines show that your custom headers replaced the default ones. The server's echo response confirms that it received SecretBrowser/1.0 and your injected cookie. This technique is heavily used in web security testing to test how applications handle unexpected or manipulated header values.
Send Raw POST Data
In this step, you will learn how to send data using the POST method. While GET requests append data to the URL, POST requests send data hidden within the "body" of the HTTP request. This is typically used for submitting login forms, uploading files, or sending sensitive data that shouldn't be visible in the URL.
To send a POST request with curl, you use the -X POST flag to specify the method, and the -d (data) flag to specify the raw body content.
Let's simulate submitting a login form with a username and password. Run the following command:
curl -v -X POST -d "username=admin&password=password123" http://127.0.0.1:8080/login
Review the detailed output:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /login HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Length: 35
> Content-Type: application/x-www-form-urlencoded
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.10.12
< Date: Thu, 12 Mar 2026 00:08:52 GMT
< Content-type: text/plain
<
Method: POST
Path: /login
Headers:
Host: 127.0.0.1:8080
User-Agent: curl/7.81.0
Accept: */*
Content-Length: 35
Content-Type: application/x-www-form-urlencoded
Body:
* Closing connection 0
username=admin&password=password123
Observe a few new things here. First, the method changed to POST. Additionally, curl automatically added a Content-Length header (telling the server the size of the data) and a Content-Type header. Finally, the server's echo response now includes a Body section containing your raw credentials.
Understanding how to manually construct these POST bodies is essential for interacting with APIs and testing web application authentication mechanisms.
Summary
Congratulations! You have successfully completed the HTTP Interception Basics lab.
In this lab, you learned how to:
- Inspect the raw components of an HTTP request and response using
curl. - Craft custom GET requests by appending query parameters to the URL path.
- Manipulate HTTP headers to spoof your User-Agent and inject session Cookies.
- Send raw data securely in the body of an HTTP request using the POST method.
By manually crafting these requests, you now have a solid understanding of the underlying text-based protocol that powers the web. This foundational knowledge is crucial for using advanced intercepting proxies, debugging APIs, and performing web security assessments.



