Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <openssl/sha.h>
  5.  
  6. int
  7. main(void) {
  8.     FILE *file;
  9.     unsigned char flag[128];
  10.     unsigned char correct_hash[20] = {
  11.         0x4a, 0xc9, 0xb0, 0x57, 0xf8, 0x02, 0x12, 0x60, 0x6c, 0xea,
  12.         0xab, 0xf3, 0xc6, 0x50, 0x5d, 0xaf, 0xed, 0x40, 0xa4, 0x50
  13.     };
  14.     unsigned char password[20];
  15.  
  16.     printf("Insert your password: ");
  17.     scanf("%37s", password);
  18.     SHA1(password, strlen((char *)password), password);
  19.     if(memcmp(password, correct_hash, 20) == 0) {
  20.         printf("CORRECT PASSWORD!\n");
  21.         file = fopen("/challenges/overshade/flag", "r");
  22.         if(file != NULL) {
  23.             fscanf(file, "%s", flag);
  24.             fclose(file);
  25.             printf("Flag: %s\n", flag);
  26.         } else {
  27.             printf("Error while opening the flag file\n");
  28.         }
  29.     } else {
  30.         printf("WRONG PASSWORD!\n");
  31.     }
  32.     fflush(stdout);
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement