-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask1.c
34 lines (29 loc) · 837 Bytes
/
task1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* gcc task1.c -o task1 -m32 -ggdb -no-pie -z execstack -fno-stack-protector -fcf-protection=none -std=c89 -Wno-deprecated-declarations */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum UserIds {
Zwiedzajacy = 0,
Administracja = 1,
Dyrektor = 0x1337
};
int main(void) {
char name[0x10];
int userId = (int)Zwiedzajacy;
setbuf(stdout, NULL);
printf("Podaj nick:");
gets(name);
printf("Witaj %s!\n", name);
if(userId == Dyrektor) {
puts("Oto flaga: ");
FILE* f = fopen("flag.txt", "rb");
char* ptr = (char*)malloc(0x100);
memset(ptr, 0, 0x100);
fread(ptr, 1, 0x100, f);
puts(ptr);
free(ptr);
fclose(f);
} else {
puts("Nie masz uprawnien aby zobaczyc flage. Tylko Dyrektor ma do niej dostep.");
}
}