HTTP POST Requests Explained: Login Forms, Cookies and JSON
How HTTP POST requests work and why they matter for security: login forms, authenticated session cookies and JSON APIs, with the cURL command to send each one.
Mastering HTTP POST Requests: Login Forms, Cookies, and JSON [TryHackMe]
What Makes POST Different?
HTTP POST requests are the go-to when web apps need to send sensitive or large data, like login credentials or file uploads. Unlike GET requests, which tack parameters onto the URL (e.g., ?search=london), POST hides data in the request body. Why? Three big reasons:
- No Logging: POST data isn’t logged in server access logs, unlike GET URLs. Imagine uploading a 10MB file via GET—logging that in the URL would be a nightmare!
- Less Encoding: URLs need to be shareable, so GET parameters are limited to URL-safe characters. POST handles binary data (e.g., images) without strict encoding, making it versatile.
- More Data: URLs have length limits (often ~2000 characters, varying by browser or server). POST can send much larger payloads, like form submissions or JSON data.
Real-world example: In 2023, attackers exploited POST requests in a misconfigured API to upload malicious payloads, bypassing URL logging. SOC analysts caught it by monitoring request bodies in SIEM tools.
TryHackMe context: The room’s POST section uses a PHP-based login form to show how POST handles sensitive data, contrasting with the GET-based search from earlier sections.
POST in Action: Login Forms
In the TryHackMe exercise, you visit http://94.237.50.221:34150/ and see a login form (not basic HTTP auth like in the GET section). Using admin:admin, you log in and access a city search function, similar to the GET section’s demo. Let’s break it down:
- Inspecting the Login: Open browser DevTools (
F12orCtrl+Shift+I), go to the Network tab, clear requests (click the trash icon), and log in withadmin:admin. Filter requests by the server IP to focus on the web app. - Spotting the POST: You’ll see a POST request to the server with the body:
This is URL-encoded form data, sent in the request body, not the URL.username=admin&password=admin
Why it matters: POST keeps credentials private, unlike GET, which might expose them in logs or browser history. For SOC analysts, monitoring POST requests in logs is key to spotting brute-force attacks.
Command: Use cURL to replicate the login:
curl -X POST -d 'username=admin&password=admin' http://94.237.50.221:34150/
-X POST: Specifies the POST method.-d 'username=admin&password=admin': Sends the form data.
The response includes HTML with the search function (<em>Type a city name and hit <strong>Enter</strong></em>), confirming successful authentication.
Pro tip: Add -L to follow redirects, as many login forms redirect to a dashboard (e.g., /dashboard.php).
Real-world vibe: In 2022, attackers used POST requests to brute-force WordPress login forms, exploiting weak passwords. Monitoring POST traffic helped SOCs block IPs sending excessive login attempts.
Authenticated Cookies: Staying Logged In
After a successful login, the server sends a session cookie to keep you authenticated. In the TryHackMe exercise, check the response headers with cURL:
curl -X POST -d 'username=admin&password=admin' http://94.237.50.221:34150/ -i
Output:
HTTP/1.1 200 OK
Date: Tue, 26 Aug 2025 18:43:15 GMT
Server: Apache/2.4.41 (Ubuntu)
Set-Cookie: PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1; path=/
...
<em>Type a city name and hit <strong>Enter</strong></em>
...
The Set-Cookie header provides a session cookie (PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1), which your browser stores to maintain your session.
Testing the Cookie: Use the cookie to access the app without re-authenticating:
curl -b 'PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1' http://94.237.50.221:34150/
Or set it as a header:
curl -H 'Cookie: PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1' http://94.237.50.221:34150/
Both return the search page, proving the cookie authenticates you.
Browser DevTools: Log out, go to the Storage tab (Shift+F9), and check cookies for 94.237.50.221:34150. Delete existing cookies, add a new one with name PHPSESSID and value c1nsa6op7vtk7kdis7bcnbadf1, then refresh. You’re logged in without credentials!
Why it matters: Cookies are prime targets for attacks like Cross-Site Scripting (XSS), where attackers steal session cookies to hijack accounts. SOC analysts monitor for cookie theft in web logs, while pentesters test for insecure cookie handling.
Real-world example: In 2024, a major e-commerce site suffered an XSS attack, leaking session cookies. Pentesters used cURL to simulate cookie-based attacks, exposing the flaw.
Research note: A 2024 OWASP guide emphasized securing cookies with attributes like HttpOnly and Secure to prevent XSS and man-in-the-middle attacks.
JSON Data: Powering Dynamic Apps
The TryHackMe city search function uses POST to send JSON data, not form data. In DevTools, search for “London” in the search bar, and you’ll see a POST request to /search.php with:
{"search":"london"}
The request headers include:
Content-Type: application/json
Cookie: PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1
The response is:
["London (UK)"]
Replicating with cURL:
curl -X POST -d '{"search":"london"}' -b 'PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1' -H 'Content-Type: application/json' http://94.237.50.221:34150/search.php
This returns ["London (UK)"], mimicking the browser’s behavior.
Using Fetch: In DevTools’ Console tab (Ctrl+Shift+K), copy the request as Fetch:
fetch("http://94.237.50.221:34150/search.php", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Cookie": "PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1"
},
body: JSON.stringify({"search":"london"})
})
.then(response => response.json())
.then(data => console.log(data));
This also returns ["London (UK)"].
TryHackMe task: Authenticate with admin:admin to get a session cookie, then use cURL to POST {"search":"flag"} to /search.php. The response reveals the flag: HTB{p0$t_r3p34t3r}.
Exercise: Try the request without the cookie or Content-Type: application/json. Without the cookie, you’ll get a 401 Unauthorized or login page. Without the correct Content-Type, the server may reject the JSON, returning an error.
Real-world vibe: In 2023, attackers exploited a JSON-based API endpoint in a banking app, sending malformed POST requests to bypass authentication. Pentesters used cURL to replicate and fix such flaws.
Research note: A 2024 X post by @WebSecGuru highlighted JSON POST vulnerabilities in APIs, noting that 40% of tested apps lacked proper input validation.
Core Concepts and Commands
Key Concepts
- POST vs. GET: POST hides data in the request body, ideal for sensitive or large data, unlike GET’s URL-based parameters.
- Login Forms: POST sends credentials securely, often returning a session cookie to maintain authentication.
- Cookies: Session cookies (e.g.,
PHPSESSID) persist authentication, but are vulnerable to theft via XSS or insecure handling. - JSON Data: Modern apps use JSON in POST requests for dynamic interactions, requiring correct
Content-Typeheaders. - Security Risks: POST requests can be exploited for brute-forcing, file uploads, or API abuse if not validated.
Essential Commands
- Basic POST Request:
curl -X POST -d 'username=admin&password=admin' http://94.237.50.221:34150/ - POST with Cookie:
curl -b 'PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1' http://94.237.50.221:34150/ - JSON POST Request:
curl -X POST -d '{"search":"flag"}' -b 'PHPSESSID=c1nsa6op7vtk7kdis7bcnbadf1' -H 'Content-Type: application/json' http://94.237.50.221:34150/search.php - Follow Redirects:
curl -L -X POST -d 'username=admin&password=admin' http://94.237.50.221:34150/ - View Headers:
curl -i -X POST -d 'username=admin&password=admin' http://94.237.50.221:34150/
DevTools Tips:
- Network Tab: Filter by server IP, check request body, and copy as cURL/Fetch.
- Storage Tab: Edit cookies to test authentication bypass.
- Console Tab: Run Fetch commands to simulate requests.
Why This Matters for Cybersecurity
For SOC analysts, understanding POST requests is critical for monitoring web traffic. You’ll analyze logs for suspicious POST payloads (e.g., SQL injection attempts) or excessive login attempts. Tools like Splunk or Elastic can parse POST request bodies to detect anomalies.
For pentesters, POST requests are a goldmine. You can:
- Test login forms for weak credentials or brute-force vulnerabilities.
- Manipulate cookies to bypass authentication (e.g., session hijacking).
- Craft JSON POST requests to exploit API endpoints, like the TryHackMe flag task.
Real-world example: The 2021 Microsoft Exchange Server attack involved POST requests to exploit ProxyLogon vulnerabilities, uploading malicious web shells. SOCs used POST request analysis to detect and mitigate these.
Pro tip: Practice with TryHackMe’s tasks, like grabbing the flag with a JSON POST request. It builds skills for real-world web app testing and incident response.
Final Thoughts
The POST section of TryHackMe’s Web Requests room demystifies how web apps handle sensitive data. From login forms to session cookies and JSON payloads, you’ve learned how POST requests power dynamic apps and how to analyze them with cURL and DevTools. Whether you’re a SOC analyst spotting malicious POSTs or a pentester crafting exploits, these skills are your foundation. Keep practicing with commands like curl -X POST and DevTools to master web security. Got a cool cURL trick or POST exploit story? Drop it in the comments, and let’s keep the cyber party going!
Enjoyed this report?
If it helped, like it and pass it on to someone who needs it.
WebFeaturedWeb Requests Cheat Sheet: Mastering cURL, APIs, and DevTools for Bug Bounties
Hey, cyber sleuths! If you're diving into bug bounty hunting or sharpening your skills as a penetration tester, understanding web requests is your secret weapon. Tools like cURL let you poke, prod, and probe web applications with precision, uncovering vulnerabilities that automated scanners might miss. This blog takes the classic web requests cheat sheet—covering cURL commands, API interactions, and Browser DevTools shortcuts—and expands it with in-depth explanations. We'll dive into why each flag or technique is used, its core description, and how it fits into real-world scenarios. Plus, I'll throw in some advanced cURL techniques tailored for bug bounties, drawn from proven methodologies. Whether you're a junior SOC analyst monitoring traffic or a bug hunter chasing bounties, let's break it down step by step!
WebCRUD API Operations HTB
Hey, cyber warriors! Ready to dive into the world of APIs? In the **Web Requests** TryHackMe room, the **CRUD API** section explores how web applications use APIs to interact with databases, letting you create, read, update, and delete data with HTTP methods. This is like wielding a Swiss Army knife for web data manipulation—essential for SOC analysts spotting malicious API calls or pentesters exploiting misconfigured endpoints. We’ll break down the CRUD operations (Create, Read, Update, Delete), walk through TryHackMe’s hands-on tasks, and sprinkle in real-world examples and research to keep it practical. Let’s get started!
WebWeb Request Part 2
Welcome back, cyber crew! In [Part 1](Web_Requests_Blog_Part1.md), we covered **HTTP**, **URLs**, **DNS**, and **cURL**—the basics of how web requests work. Now, in Part 2, we’re diving deeper into the **Web Requests** TryHackMe room to explore **HTTPS**, **HTTP requests and responses**, **headers**, **methods**, and **authentication**. These are the nuts and bolts of secure web communication and common attack vectors. I’ll keep it chill, like we’re geeking out over coffee, with real-world examples and some extra research to make it practical. Let’s get to it!