UnixDroid

Lesson 1 of 5 · 7 min

How HTTP works

Read a real HTTP request and response line by line, and learn the methods, headers and status codes that matter for security.

Every web attack you'll ever learn, SQL injection, XSS, broken logins, travels inside HTTP. So before attacking web apps, you need to read HTTP as easily as a sentence.

A request and a response

Use curl against your lab's web server and ask it to show everything:

curl -v http://192.168.56.102/

The lines starting with > are what you sent:

> GET / HTTP/1.1
> Host: 192.168.56.102
> User-Agent: curl/8.5.0
> Accept: */*

And the lines starting with < are what came back:

< HTTP/1.1 200 OK
< Server: Apache/2.2.8 (Ubuntu) DAV/2
< Content-Type: text/html

The first request line has three parts: the method (GET), the path (/) and the protocol version. Then come headers, then an empty line, then an optional body.

Methods

MethodUsed for
GETAsking for a page or data
POSTSending data, like a login form
PUT / PATCHUpdating something
DELETERemoving something

Status codes

Common HTTP status codes and what they mean
Common HTTP status codes and what they mean

For testers, 403 is interesting: something exists there, you just aren't allowed. And a 500 after strange input can mean you broke the app's logic, a common first sign of injection.

Headers worth reading

HeaderWhy it matters
ServerOften reveals software and version, like Apache/2.2.8
Set-CookieYour session ID, and its security flags
Strict-Transport-SecurityForces browsers to use HTTPS
Content-Security-PolicyLimits which scripts can run (helps against XSS)

HTTP vs HTTPS

HTTPS is the same HTTP, wrapped in TLS encryption. The requests look identical once decrypted. That's why tools like Burp Suite sit in the middle, decrypt your own traffic, and let you read and change it.

Use curl -I to fetch only the headers. It's a fast way to fingerprint a web server.

Try it yourself
  1. Run curl -v http://192.168.56.102/ and label the method, path, status code and Server header.
  2. Run curl -I https://example.com and list every header you get back.
  3. Request a page that doesn't exist on your lab server. What status code do you get?

Quick check

Which HTTP status code means "not found"?

Need a hint?

The most famous error page on the web.

Finished this lesson?

Done lessons keep your daily streak going 🔥

0 day streak

0 lessons done

best 0 days

Log in to keep your streak on every device →