Created
April 6, 2021 07:01
-
-
Save 0awawa0/99a13f9430b01b9821467d771af6f1d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
char password[128]; | |
void generate_password() { | |
FILE *file = fopen("/dev/urandom","r"); | |
fgets(password, 128, file); | |
fclose(file); | |
} | |
void main() { | |
puts("Welcome to my ultra secure login service!"); | |
// no way they can guess my password if it's random! | |
generate_password(); | |
char input[128]; | |
printf("Enter the password: "); | |
fgets(input, 128, stdin); | |
if (strcmp(input, password) == 0) { | |
char flag[128]; | |
FILE *file = fopen("flag.txt","r"); | |
if (!file) { | |
puts("Error: missing flag.txt."); | |
exit(1); | |
} | |
fgets(flag, 128, file); | |
puts(flag); | |
} else { | |
puts("Wrong!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment