🌐 Cookies
A detailed write-up of the Web challenge 'Cookies' from PicoCTF - 2022
📊 Challenge Overview
Category Details Additional Info 🏆 Event PicoGym Event Link 🔰 Category Web 🌐 💎 Points Out of 500 total ⭐ Difficulty 🟢 Easy Personal Rating: 1/10 👤 Author madStacks Profile 🎮 Solves 77.985 solve rate 📅 Date 30-01-2025 PicoGym 🦾 Solved By mH4ck3r0n3 Team:
📝 Challenge Information
Who doesn’t love cookies? Try to figure out the best one. http://mercury.picoctf.net:54219/
🎯 Challenge Files & Infrastructure
Provided Files
1
Files: None
🔍 Initial Analysis
First Steps
Initially, the website appears as follows:
The first thing I did was click the
search
button to see what would happen. However, the only thing I received was aninvalid search
, so, as suggested by the challenge title, I decided to inspect the cookies from thatinvalid search
.As we can see, the cookie
name=-1
immediately stands out. From there, I thought there might ben
cookies saved, and that I needed to find the correct one. In fact, after trying to search forsnickerdoodle
, which was the placeholder content in the input box, I got a valid search.When I tried inspecting the cookies again using
ChromeDevTools
, I noticed that thename
cookie had changed its value to0
.So, I immediately tried changing the value of the cookie to
1
, and by refreshing the page withF5
, I got this:As we can see, we performed a search for another cookie since the name of the cookie at the center of the page changed from
snickerdoodle
tochocolate
. Now that we understand how the page works, all we need to do is find the correct index of the flag cookie to extract it. Let’s move on to the exploitation.
🎯 Solution Path
Exploitation Steps
Initial setup
The first thing I did, instead of doing it manually, was extract the index by writing a Python script. The script makes a maximum of 100 requests to the
/check
route, passingname=request_number
. This way, the value of thename
cookie changes with each iteration of the loop: the first request has0
, the second has1
, and so on. I then added a regex check, so that once the response to the request was obtained, if the regex matched the response, it would print the request index and break out of the loop.
Exploitation
So, for the exploitation, I just ran the script:
1
python3 exploit.py
And I waited to get the correct
name
cookie value (the one that contained the flag). Once I obtained it, I changed thename
value to18
(since that was the valid index), and after refreshing the page, I found the flag.
Flag capture
🛠️ Exploitation Process
Approach
The exploit was based on setting a maximum limit of 100 POST requests, changing the value of the
name
cookie with the index from the request loop. Once I found the correct index (18
) that contained the flag, I extracted it from the response using a regex and broke the loop.
🚩 Flag Capture
Flag
Proof of Execution
🔧 Tools Used
Tool Purpose Python Exploit
💡 Key Learnings
Time Optimization
If there is a placeholder, try the input suggested by the placeholder as the first input to understand how the web application works.
Skills Improved
- Binary Exploitation
- Reverse Engineering
- Web Exploitation
- Cryptography
- Forensics
- OSINT
- Miscellaneous
📊 Final Statistics
Metric | Value | Notes |
---|---|---|
Time to Solve | 00:03 | From start to flag |
Global Ranking | Challenge ranking | |
Points Earned | Team contribution |
Created: 30-01-2025 • Last Modified: 30-01-2025 *Author: mH4ck3r0n3 • Team: *