This is my write-up of a Misc challenge An Impossible Number on the CTF site 247CTF.com
Can you think of a number which at the same time is one more than itself?
The site provides you with C source code:
impossible_number.c
#include <stdio.h>
int main() {
int impossible_number;
FILE *flag;
char c;
if (scanf("%d", &impossible_number)) {
if (impossible_number > 0 && impossible_number > (impossible_number + 1)) {
printf("You did it!\n");
flag = fopen("flag.txt","r");
while((c = getc(flag)) != EOF) {
printf("%c",c);
}
}
}
return 0;
}
If you look at the code, you can see what exactly needs to be true to get the flag.
The greatest signed 32bit integer in C programming language is 2147483647. Adding 1 to it will turn it negative and satisfy the second part of the if condition.
We will use netcat to connect to the provided server:
$ nc 11ceb738fba5614f.247ctf.com 50418
2147483647
Bingo!