-
Notifications
You must be signed in to change notification settings - Fork 0
/
part1.c
51 lines (43 loc) · 1.07 KB
/
part1.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#define MY_FILE "./destination.txt"
int main(){
printf("%s", "HIWORLD! gpg...\n");
char str[1000];
FILE * f;
if(access(MY_FILE, F_OK) != 0){
printf("File doesn't exist!\n");
return -1;
}
if ((f = fopen(MY_FILE, "r")) == NULL) {
printf("Error! File cannot be opened.\n");
return -1;
}
char check[] = "";
fscanf(f, "%[^\n]", check);
if(strcmp(check, "a") == 0){
printf("%s", "Terminated!");
fclose(f);
return -1;
}
fclose(f);
printf("%s", "Sleeping for 5 seconds...\n");
sleep(5);
printf("%s", "Back awake\n");
if ((f = fopen(MY_FILE, "r")) == NULL) {
printf("Error! File cannot be opened.\n");
return -1;
}
fscanf(f, "%[^\n]", str);
if(strcmp(str, "a") != 0){
printf("%s", "Terminated!\n\n");
fclose(f);
return -1;
}else{
printf("%s", "CTF_SDaT{Tr!m0_i5_dA_G0@t}\n\n");
fclose(f);
return 0;
}
}