Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. #define PASSFILE   "/home/passtest/flag"
  6. #define MAX_SIZE   100
  7.  
  8. int main(int argc, char **argv)
  9. {
  10.     FILE * f;
  11.     char password[MAX_SIZE + 1] = {0};
  12.  
  13.     if (argc < 2 || (f=fopen(PASSFILE, "r")) == NULL || fgets(password, MAX_SIZE, f) == NULL)
  14.     {
  15.         printf("Fail.\n");
  16.         exit(1);
  17.     }
  18.  
  19.     if (strncmp(argv[1], password, MAX_SIZE) == 0)
  20.     {
  21.         printf("Good Job =)\n");
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement