Video summary
pwn.college - Talking Web - Making HTTP Requests
Main summary
Key takeaways
Main ideas / lessons
-
Web browsing works by sending HTTP requests and receiving HTTP responses.
- When you type a URL in a browser and hit Enter, the browser sends an HTTP request to a server.
- A server responds with an HTTP response, often containing HTML that the browser renders.
-
You can inspect or manually create HTTP traffic.
- The video shows a local web server (listening on 127.0.0.1:80) and demonstrates what an incoming HTTP request looks like (method line like
GET / HTTP/1.1, plus headers). - It also shows responding by manually writing an HTTP/1.0 200 OK response including headers (e.g.,
Content-Type: text/html) and an HTML body.
- The video shows a local web server (listening on 127.0.0.1:80) and demonstrates what an incoming HTTP request looks like (method line like
-
HTTP requests can be made from the command line using
curl.curltakes a URL and performs an HTTP request.- By default, it uses GET.
- The server/user-agent observed in requests reflects the client:
- Example: Firefox user-agent vs
curluser-agent.
- Example: Firefox user-agent vs
- You can customize requests via options/flags:
- Send POST requests (e.g., with a
--post-style flag). - Set custom headers like
User-Agent.
- Send POST requests (e.g., with a
-
Documentation is the key skill for learning unfamiliar tools/protocols.
- The presenter emphasizes reading:
curl’s man pagerequestsdocumentation- HTTP specifications like RFC 1945
- Options/behavior aren’t “pulled from thin air”—they’re learned by checking documentation.
- The presenter emphasizes reading:
-
You can view what you actually sent using
curl -v(verbose).-vshows:- request details
- response headers and raw protocol exchange
-
You can send raw HTTP over TCP using
netcat.netcatcan connect to an HTTP server (e.g.,example.comon port 80).- Then you type raw HTTP bytes yourself.
- Important detail: you must format properly, including using two newlines to end the HTTP headers and trigger the request.
- The video demonstrates:
- GET
/returning the normal HTML content - requesting
/testreturning 404 Not Found
- GET
-
You can interact with web servers programmatically (example: Python
requests).- Use
requests.get(url)to send an HTTP request. - It returns a response object.
- You can inspect:
response.text(response body)response.headers(iterate key/value pairs)
- You can also:
- send POST requests with
requests.post(...) - provide headers via a
headers=dictionary
- send POST requests with
- Use
-
Example programming task: extract links from HTML.
- HTML links are commonly represented with anchor tags (
<a href="...">...</a>). - A simple approach shown:
- fetch HTML with
requests.get - split response text into lines
- find lines containing
<a - extract the URL by splitting the line on double quotes and taking the appropriate field
- fetch HTML with
- HTML links are commonly represented with anchor tags (
Methodologies / instruction lists (detailed)
1) Manually crafting an HTTP response (server-side demo)
- Start from an incoming HTTP request observed by a local server.
- Send a valid HTTP response:
- Write a status line like:
HTTP/1.0 200 OK - Include headers, e.g.:
Content-Type: text/html
- Leave a blank line to separate headers from body
- Provide an HTML body, e.g.:
Hello <b>world</b>
- Write a status line like:
2) Making HTTP requests from the terminal with curl
- Basic usage:
curl <url>- Default HTTP method is GET
- POST requests:
- Use the appropriate
curloption for sending POST (the video references using flags discovered via the man page). - Example behavior shown:
curl --post ... <url>results in a POST being received by the server.
- Use the appropriate
- Custom headers:
- Use
curloptions to set header values, such as setting:User-Agent: Connor(so the server sees that header in the request)
- Use
- Inspecting request/response details:
- Use verbose mode:
curl -v <url>
- This prints raw request/response headers and details.
- Use verbose mode:
3) Sending raw HTTP with netcat
- Connect to an HTTP server over TCP:
nc <host> <port>(e.g.,example.com 80)
- Manually type a request in raw HTTP format:
- Example GET request line:
GET / HTTP/1.0
- Include a
Host:header:Host: example.com
- Example GET request line:
- Terminate headers properly:
- Press Enter after headers, then add an extra blank line (two newlines total) to indicate end of headers.
- Read the server’s raw HTTP response until it ends (including status like
200 OKor404 Not Found).
4) HTTP requests in Python with the requests library
- Import and GET:
import requestsresponse = requests.get("http://example.com")
- Use the response object:
response.textfor the bodyresponse.headersto inspect headers (iterate key/value pairs)
- POST:
response = requests.post("http://example.com", ...)(the video shows the concept)
- Custom headers:
- Create a headers dictionary, e.g.:
headers = {"User-Agent": "Connor"}
- Pass it to
get/postviaheaders=...
- Create a headers dictionary, e.g.:
5) Extracting links from HTML (simple parsing logic shown)
- Fetch HTML:
response = requests.get("http://example.com")
- Get text:
response_text = response.text(implied by use ofresponse.text/response.extin subtitles)
- Split into lines:
lines = response_text.splitlines()
- For each line:
- If the line contains an anchor tag marker (e.g.,
"<a"):- Print the line containing the anchor
- Extract the URL by splitting the line on double quotes (
"):- The video’s approach:
line.split('"')[1](first quoted item after splitting)
- The video’s approach:
- If the line contains an anchor tag marker (e.g.,
Speakers / sources featured (as named in the subtitles)
-
Speaker/Instructor: “pwn.college” (unnamed presenter; subtitles refer to a user-agent name “Connor” as a custom header value)
-
Software/library sources:
- HTTP
- curl (including its man page)
- netcat
- Python
requests(documentation at requests.readthedocs.io)
-
Standards source:
- RFC 1945 (referenced as HTTP documentation to read)
-
Demo site mentioned:
- example.com (illustrative HTTP server)