CREATIVE CHAOS   ▋ blog

An Impossible Number (misc)

PUBLISHED ON 16/02/2020 — EDITED ON 11/12/2023 — 247CTF, INFOSEC

Intro

This is my write-up of a Misc challenge An Impossible Number on the CTF site 247CTF.com

Instructions

Can you think of a number which at the same time is one more than itself?

Howto

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!

See Also

TAGS: 247CTF, C, CTF, HACK, INTEGER