Fragen #26
Replies: 1 comment
-
|
Hi, The picoCTF 2019 "flag shop" challenge is almost identical to the picoCTF 2018 "store" challenge. This is essentially a "integer overflow" challenge, where we need to provide input that will cause an overflow of When #include <stdio.h>
int main()
{
int number_flags = 2222222;
int total_cost = 1000 * number_flags;
printf("%d", total_cost); // Output is: -2072745296 (negative, like we wanted)
return 0;
}But look what happens if we change the price to #include <stdio.h>
int main()
{
int number_flags = 2222222;
int total_cost = 1000 * number_flags;
printf("%d", total_cost); // Output is: 1999999800 (positive - not good for us)
return 0;
}So, we must adjust the number of flags to the price of the flag to cause the overflow: #include <stdio.h>
int main()
{
int number_flags = 3333333;
int total_cost = 900 * number_flags;
printf("%d", total_cost); // Output is -1294967596 (back to negative)
return 0;
}In general, instead of following the 2019 writeup, one can just follow the 2018 writeup which is self-contained. The principal is the same. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, could you please explain what are you trying to do with line 105
root@kali:/media/sf_CTFs/pico/flag_shop# diff store.c ../../pico_2018/store/source.c
Are we doing something here from line 104 where the solution is.
What are you trying to do with
2222222 flags won't do anymore, since that would bring us to a negative balance, we must buy 3333333 instead to trigger the overflow.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions