Challenge Author: CHENG ZHANG
Difficulty: Easy
Description
Can you use your knowledge of format strings to make the customers happy?
Process / Notes
- In the source code file, I see that
BUFFSIZE 32, FLAGSIZE 64 - It looks like we’ll first be presented with a menu, then serving Patrick, then serving Sponge Bob
- With Patrick it looks like choosing the breakfast burger will result in the script returning that that item is unavailable
- If the item is greater than 2, maybe meaning the third option? No it’s 2x the buffer size, then we’ll go on to serving Sponge Bob, otherwise Patrick will still be hungry
- Neo Vim has syntax-highlighted the
%114din the second option - the Grilled Cheese. I think that that indicates the program will detect the format specifier (like the%slittered everywhere seem to be format specifiers) and that will affect the buffer size, exceed it, and allow us to move on to working with Sponge Bob. - It says Sponge Bob is super hungry and wants something that will “break the shop.” In the third option, there are three
%s, which may get the string read three times, but it doesn’t seem large enough to exceed the buffer size - The
%tothat’s in the “Pesto Portobello” option may indicate that it will go to some undefined end - Before actually running things, I believe the answer will be to get Patrick the “Grilled Cheese’ option that contains the
%114dformat string, which will allow us to work with Sponge Bob, I believe getting Sponge Bob the “Pesto Portobello” option that contains the%towill be the option that “breaks the shop” and then get use the flag. We’ll see in a moment! - Use
ncto start the challenge instance - When entering the “Grilled Cheese” option, it displayed a huge number of blank spaces. This was likely due to the
%114d. If the last challenge was about exceeding buffer size, and this is similar, then the huge amount of blank spaces would definitely exceed the buffer size of 32 (or the doubled size of 64) - The Pesto Portobello option kicked me out of the challenge instance, so I think it’s the last option
- After reconnecting, I chose the option with three
%sfor Sponge Bob - I’m not quite sure what that option did, but it returned the flag. Clearly there’s more to learn!
36 minutes 20 seconds to complete
Hints
- This is an introduction of format string vulnerabilities. Look up “format specifiers” if you have never see them before
- Just try out the different options
Core Lessons
- Understanding buffer size in the source code and what each “success condition” was
- Understanding what format string specifiers do and how they behave