forked from RPISEC/MBE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab3C.c
49 lines (39 loc) · 1.05 KB
/
lab3C.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
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* gcc -z execstack -fno-stack-protector -o lab3C lab3C.c */
char a_user_name[100];
int verify_user_name()
{
puts("verifying username....\n");
return strncmp(a_user_name, "rpisec", 6);
}
int verify_user_pass(char *a_user_pass)
{
return strncmp(a_user_pass, "admin", 5);
}
int main()
{
char a_user_pass[64] = {0};
int x = 0;
/* prompt for the username - read 100 byes */
printf("********* ADMIN LOGIN PROMPT *********\n");
printf("Enter Username: ");
fgets(a_user_name, 0x100, stdin);
/* verify input username */
x = verify_user_name();
if (x != 0){
puts("nope, incorrect username...\n");
return EXIT_FAILURE;
}
/* prompt for admin password - read 64 bytes */
printf("Enter Password: \n");
fgets(a_user_pass, 0x64, stdin);
/* verify input password */
x = verify_user_pass(a_user_pass);
if (x == 0 || x != 0){
puts("nope, incorrect password...\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}