30 Days of CTF Series | Day 8: How the Web Works (HTTP, Cookies and Your First Web Flags)

Welcome to Day 8 of the 30 Days of CTF series, and welcome to Week 2: Web Exploitation.
Web is the most common category in almost every CTF. The good news is that you already use websites every day. This week, you will learn to look at them the way a hacker does: not just what the page shows, but what is happening behind the page.
Before we break anything, we need to understand how the web actually works. That is today’s goal. By the end of this blog, you will know where developers accidentally hide flags and how to find them in minutes.
Practice labs for Day 8:
Client and Server
Every website has two sides:
- Client: your browser. It sends requests and shows you the result.
- Server: the computer where the website lives. It receives requests and sends back responses.
The most important lesson of web hacking is this: you control the client completely. Anything in your browser (HTML, JavaScript, cookies, hidden fields) can be read and changed by you. If a website trusts the client blindly, it can be hacked.
The Parts of a URL
https://shop.example.com:443/products/view?id=5#reviews
https is the protocol
shop.example.com is the domain (here shop is a subdomain)
443 is the port (usually hidden because it is the default for HTTPS)
/products/view is the path
?id=5 is the query string, a parameter sent to the server
#reviews is the fragment, used only inside the browser
In CTFs, always notice parameters like ?id=5. What happens if you change it to ?id=6 or ?id=1? We will come back to this in Day 14.
HTTP Requests
When you open a page, your browser sends an HTTP request that looks like this:
GET /products/view?id=5 HTTP/1.1
Host: shop.example.com
User-Agent: Mozilla/5.0
Cookie: session=abc123
- Method:
GET, what you want to do
- Path: which page you want
- Headers: extra information like your browser name and cookies
Common HTTP methods:
GET: get a page or data (parameters go in the URL)
POST: send data, like a login form (data goes in the request body)
PUT / DELETE: update or delete data, common in APIs
OPTIONS: ask the server which methods are allowed
Sometimes a page shows nothing with GET, but reveals something with POST or another method. Always keep this in mind.
HTTP Responses and Status Codes
The server replies with a response:
HTTP/1.1 200 OK
Content-Type: text/html
Set-Cookie: session=abc123
Server: Apache/2.4.41
<html> ... page content ... </html>
The number at the top is the status code. Learn these:
200 OK: success
301 / 302: redirect to another page
401 Unauthorized: you need to log in
403 Forbidden: you are not allowed (but the page exists, which is interesting)
404 Not Found: page does not exist
500 Internal Server Error: something broke on the server, often a sign your input caused an error
CTF tip: A 403 is more interesting than a 404. It tells you something is there, you just are not allowed in yet.
Headers: Hidden Information
Headers carry extra information that the browser does not show you. Some useful ones:
Server: tells you the web server and sometimes its version
X-Powered-By: may reveal the backend language (PHP, Express)
Set-Cookie: the server giving you a cookie
User-Agent: tells the server which browser you are using
Referer: tells the server which page you came from
Flags are sometimes placed directly in custom headers like X-Flag. You will only see them if you look.
Cookies and Sessions
HTTP has no memory. Every request is new. So how does a website remember that you are logged in? Cookies.
- You log in.
- The server sends
Set-Cookie: session=xyz789.
- Your browser sends
Cookie: session=xyz789 with every request after that.
- The server sees the cookie and knows it is you.
Sometimes developers store important things directly in cookies, like this:
Cookie: user=guest; admin=false
Since you control the client, what stops you from changing admin=false to admin=true? In a badly built website, nothing. This is one of the most common beginner web challenges.
Cookies can also be encoded. If you see a cookie like dXNlcj1ndWVzdA==, your Day 7 skills tell you it is Base64.
Your Web Hacking Toolkit: Browser DevTools
Press F12 (or right click and choose Inspect) in Chrome or Firefox. These tabs matter most:
- Elements / Inspector: see and edit the live HTML. Find hidden fields and disabled buttons.
- Console: run JavaScript on the page.
- Network: see every request and response, including headers and status codes.
- Application / Storage: see and edit cookies and local storage.
- Sources / Debugger: read all JavaScript files the page loads.
Also remember Ctrl + U, which opens the full page source.
Talking to the Web from the Terminal
On Day 4, you met curl. Here are more options that are perfect for web challenges:
$ curl -i http://target.com # show response headers
$ curl -X POST http://target.com/login # use the POST method
$ curl -X OPTIONS -i http://target.com # ask which methods are allowed
$ curl -d "user=admin&pass=1234" http://target.com/login # send form data
$ curl -b "admin=true" http://target.com/dashboard # send a cookie
$ curl -A "Googlebot" http://target.com # change the User-Agent
$ curl -H "X-Forwarded-For: 127.0.0.1" http://target.com # add a custom header
The Beginner Web Checklist
When you open any web challenge, check these in order. Most beginner web flags are hidden in one of these places:
- Page source (
Ctrl + U): look for HTML comments <!-- --> and hidden inputs
- JavaScript files: read them in DevTools Sources
/robots.txt: a file that tells search engines which pages not to index. It often reveals secret paths
/sitemap.xml: a list of pages on the site
- Response headers: check with
curl -i or the Network tab
- Cookies: check names and values in DevTools Storage
- Different methods: try
POST or OPTIONS on interesting pages
- URL parameters: change values like
?id=1 or ?role=user
Save this checklist. You will use it in every web challenge from now on.
Let’s Solve a Challenge Together
A challenge gives you a website and says:
“Our new admin panel is so secret that even search engines do not know about it.”
Step 1: Read the hint. “Search engines do not know about it” points to robots.txt.
$ curl http://target.com/robots.txt
User-agent: *
Disallow: /super-secret-admin
Step 2: Visit the hidden path.
$ curl -i http://target.com/super-secret-admin
HTTP/1.1 403 Forbidden
Set-Cookie: role=guest
Access denied. Admins only.
A 403, so the page exists. The server also gave us a cookie: role=guest.
Step 3: Change the cookie. The server decides who we are based on a cookie we control. Let’s tell it we are admin.
$ curl -i -b "role=admin" http://target.com/super-secret-admin
HTTP/1.1 200 OK
Welcome, admin!
HackCTF{n3v3r_trust_th3_cl13nt}
Flag captured. You can do the same in the browser: open DevTools, go to Application > Cookies, change guest to admin and refresh.
The lesson: We did not use any exploit. We read robots.txt, noticed a 403, and changed a value the server should never have trusted.
Try It Yourself on Hacklido
1. View Source
A website claims you cannot see the flag. Use the checklist: page source, JavaScript logic, then decode whatever you find. If you solved it on Day 4 with curl, try it again today using only browser DevTools.
Link: learn.hacklido.com/challenges/view-source
2. Obfuscated JavaScript
The flag is hidden inside a JavaScript file. Today, try a new method: paste the code into the browser Console and let the browser run it for you. Check the challenge hints if you get stuck.
Link: learn.hacklido.com/challenges/obfuscated-javascript
3. WebGoat
An interactive teaching environment built by OWASP that teaches web security step by step. Start with the introductory lessons on HTTP basics and using your browser’s developer tools.
Link: open learn.hacklido.com/learn and select WebGoat.
Day 8 Cheat Sheet
Save this in your notes:
- Client is yours: anything in the browser can be read and changed
- GET: data in the URL. POST: data in the body
- 200 OK, 302 redirect, 403 exists but forbidden, 404 not found, 500 server error
- Cookies remember who you are. Check them, decode them, change them
F12: DevTools (Elements, Console, Network, Storage, Sources)
Ctrl + U: view page source
curl -i: see headers
curl -X POST / -X OPTIONS: change method
curl -b "name=value": send a cookie
curl -A "Googlebot": change User-Agent
curl -H "Header: value": add a header
- Checklist: source, JS, robots.txt, sitemap.xml, headers, cookies, methods, parameters
Day 8 Task
What’s Next?
In Day 9, we will learn Burp Suite, the most important tool in web hacking. You will learn to intercept every request between your browser and the server, change it before it reaches the server, and replay it as many times as you want.
See you tomorrow on Day 9. Happy hacking.