Advertisement
Guest User

Untitled

a guest
Sep 10th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. typedef struct {
  7.     char username[20];
  8.     char password[16];
  9. } Login;
  10.  
  11. char password[] = "follow_@wtfsper";
  12.  
  13. int check_password(Login *login) {
  14.  
  15.     int result = 0;
  16.     char buff[16];
  17.  
  18.     printf("password: ");
  19.     scanf("%s", buff);
  20.  
  21.     strcpy(login->password, buff);
  22.     if(strncmp(login->password, password, sizeof(password)) == 0)
  23.         result = 1;
  24.  
  25.     return result;
  26.  
  27.  
  28. }
  29.  
  30. int main(int argc, char** argv) {
  31.  
  32.     Login l;
  33.  
  34.     printf("*****************************************************************\n");
  35.     printf("*                WELCOME TO UNIVERSITY OF TEXAS(S)              *\n");
  36.     printf("*                  GRADE REPORT SYSTEM - 3.2.1                  *\n");
  37.     printf("*                                                               *\n");
  38.     printf("*                      PLEASE LOGIN TO                          *\n");
  39.     printf("*                       ACCESS GRADES                           *\n");
  40.     printf("*****************************************************************\n");
  41.  
  42.     printf("username: ");
  43.  
  44.     scanf("%20s", l.username);
  45.     int auth = check_password(&l);
  46.     printf("%d\n", auth);
  47.     if (auth == 0) {
  48.         printf("auth failed :( \n");
  49.         return 0;
  50.     } else if (auth == 1) {
  51.         system("cat grades.txt");
  52.     } else if (auth == 2) {
  53.         system("/bin/sh");
  54.     }
  55.  
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement