intro_hacking_ctf/crypto/binary/ono.c

37 lines
677 B
C
Raw Normal View History

2024-02-21 17:53:04 +01:00
#include <stdio.h>
#include <stdlib.h>
char *__rdfl() {
FILE *fl = fopen("flag.txt", "r");
fseek(fl, 0, SEEK_END);
unsigned long fs = (unsigned long)ftell(fl);
fseek(fl, 0, SEEK_SET);
char *buf = malloc(fs);
fread(buf, 1, fs, fl);
return buf;
}
int main() {
printf("Input? ");
int input;
scanf("%d", &input);
int f1 = 1;
int f2 = 1;
for(int step = 1; step <= 5; step++) {
f1 = f1 * 2;
if(step % 3 != 0) f2 = f2 * 3;
}
int code = input - f1 * f2;
if(code == 0xC0DE) {
char *__fl = __rdfl();
printf("%s\n", __fl);
free(__fl);
}
else {
return -1;
}
}