Tags: misc overflow
Rating:
Let's see what we have here
```
'Demon Guard Flageon: Who dares to disturb my slumber?
...
A human?
what is your name human?
You: yes
Demon Guard Flageon: Listen close, yes.
To pass through you must give me a key of certain shape and size.
I do not expect mere mortals to pass this test and win the Flag of Life.
So here is a hint: the shape of the key is a square.
But I will not tell you the size.
You have 3 tries!
| How lucky! Look in your backpack. You have a square-key-making device.
| huh... weird thing to carry around if you ask me.
| Anyways.
| The problem is the device needs the edge length as input to make the key...
Input edge length: 1
*mechanical whirring*
...
*pop*
Demon Guard Flageon: The size of your key is off by 1 sq cm.
You have 2 more attempts left
Input edge length: 5
*mechanical whirring*
...
*pop*
Demon Guard Flageon: The size of your key is off by 25 sq cm.
You have 1 more attempts left
Input edge length: 9
*mechanical whirring*
...
*pop*
Demon Guard Flageon: The size of your key is off by 81 sq cm.
You have 0 more attempts left
```
Seems like we need to reach the size of 0 somehow, let's see what we are able to do
```
'Demon Guard Flageon: Who dares to disturb my slumber?
...
A human?
what is your name human?
You: kokos
Demon Guard Flageon: Listen close, kokos.
To pass through you must give me a key of certain shape and size.
I do not expect mere mortals to pass this test and win the Flag of Life.
So here is a hint: the shape of the key is a square.
But I will not tell you the size.
You have 3 tries!
| How lucky! Look in your backpack. You have a square-key-making device.
| huh... weird thing to carry around if you ask me.
| Anyways.
| The problem is the device needs the edge length as input to make the key...
Input edge length: 0
| Device only takes positive integers as input |
Input edge length: -1
| Device only takes positive integers as input |
Input edge length: 50000
*mechanical whirring*
...
*pop*
Demon Guard Flageon: The size of your key is off by -1794967296 sq cm.
You have 0 more attempts left
```
Whoopa seems like we have an 32bit integer overflow here. Knowing that sqrt(4294967295) ~= 65536, we should have everything needed to solve this challenge.
```
'Demon Guard Flageon: Who dares to disturb my slumber?
...
A human?
what is your name human?
You: kokos
Demon Guard Flageon: Listen close, kokos.
To pass through you must give me a key of certain shape and size.
I do not expect mere mortals to pass this test and win the Flag of Life.
So here is a hint: the shape of the key is a square.
But I will not tell you the size.
You have 3 tries!
| How lucky! Look in your backpack. You have a square-key-making device.
| huh... weird thing to carry around if you ask me.
| Anyways.
| The problem is the device needs the edge length as input to make the key...
Input edge length: 65536
*mechanical whirring*
...
*pop*
Demon Guard Flageon: Congratulation! You have completed this task.
The Flag of Life is now your's
===============================================
| darkCTF{-2147483648_c0m3s_aft3r_2147483647} |
===============================================
```
Nice :)