Giraffe notes was an easy beginner challenge for Patriot CTF 2024, but I thought it was a solid puzzle to warmup on. The team performed really well, and this was a challenge that I worked on alone when I had some time. I don’t usually do web, but I read the challenge file and realized it would be pretty quick to complete.
Here is the challenge description:
The challenge PHP file contents:
Click here for code
Steps
1.) Obviously, start by visiting the web page. It taunts us with a message: “Hah! Bet you cant access my notes on giraffes! They’re super secure!” Well, I will be the judge of that…
2.) Take this bit of information, download the html file and open it in a text editor. The very top of this file defines a variable, ‘allowed,’ whose value is either true or false depending on the presense of HTTP_X_FORWARDED_FOR.
Click here for code
Later in the code, we can see that if the variable is ‘allowed’ has the value of ‘True,’ then the lovely giraffe notes will be returned with the flag.
3.) HTTP_X_FORWARDED_FOR is referencing the HTTP header which defines an IP address or servername that a request is being forwarded on behalf of, and the actual HTTP header for the request appears as X-Forwarded-For: [IP]. In this particular instance, the only option to make the variable ‘allowed’ a true value is localhost, or 127.0.0.1.
4.) In Caido, I started by intercepting requests and visiting the challenge URL to capture the request so I can edit the headers.
5.) After adding the header, my request looked like the following:
Click here for text
6.) I sent the request, which met the criteria of setting ‘allowed’ to ‘True,’ so I got my flag and submitted the solve: CACI{1_lik3_g1raff3s_4_l0t}
Lessons Learned
1.) Caido is a great tool… very comparable to Burp of course, but nice.
2.) I should leave the beginner challenges for beginners.