-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathflagfinder.c
48 lines (37 loc) · 1.06 KB
/
flagfinder.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
#include <stdio.h>
#include <unistd.h>
#include <string.h>
__attribute__((constructor)) void ignore_me(){
setbuf(stdin, NULL);
setbuf(stdout, NULL);
setbuf(stderr, NULL);
}
int main()
{
char user[101];
printf("What is the password: ");
scanf("%s", user);
//Flag
//pctf{Tim3ingI8N3at}
//length: 13
char flag[] = "pctf{Tim3ingI8N3at}";
if(strlen(user) < strlen(flag)){
printf("%s is not long enough", user);
}else if(strlen(user) > strlen(flag)){
printf("%s is too long", user);
}else{
for(int i = 0; i < strlen(flag); i++){
if(user[i] == flag[i]){
//testing
printf("User input: %d\nFlag input: %d\n", user[i], flag[i]);
sleep(0.5);
}else{
printf("There's been an error");
break;
}
}
}
//printf("%s", flag);
printf("\n%s", user);
return 0;
}