Created
October 22, 2021 10:19
-
-
Save vient/0264b17c517edc86c7ba211f4e3a8d58 to your computer and use it in GitHub Desktop.
Cyberschool 2021 C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <dlfcn.h> | |
int strcmp(const char *a, const char *b) { | |
printf("strcmp %s %s\n", a, b); | |
((int(*)(const char *, const char *))(dlsym(RTLD_NEXT, "strcmp")))(a, b); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
int main() { | |
FILE* f = fopen("/tmp/kek", "r"); | |
if (f == NULL) { | |
fprintf(stderr, "fopen failed\n"); | |
return -1; | |
} | |
char buf[1024]; | |
fgets(buf, sizeof(buf), f); | |
if (strcmp(buf, "[secret]\n")) { | |
fprintf(stderr, "1\n"); | |
return -1; | |
} | |
fgets(buf, sizeof(buf), f); | |
char *it = strchr(buf, '\n'); | |
if (it != 0) { | |
*it = '\0'; | |
} | |
if (strcmp(buf, "JLJPMzknyLbj39VaaYitC79KmXEYzH4wzdzafzCYdziskECfe4R7bUPUmq7Cqi3c")) { | |
fprintf(stderr, "2\n"); | |
return -1; | |
} | |
it = buf; | |
while (*it) { | |
if (*it > '9') { | |
*it ^= 0x20; | |
} | |
it++; | |
} | |
printf("CS{%s}\n", buf); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: nopie pie static hook clean | |
nopie: | |
gcc -no-pie main.c -o main | |
pie: | |
gcc main.c -o main | |
static: | |
gcc -static main.c -o main | |
hook: | |
gcc -shared hook.c -ldl -o libhook.so | |
clean: | |
rm main libhook.so 2>/dev/null; true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment