Skip to content

Instantly share code, notes, and snippets.

@0awawa0
Created April 6, 2021 07:01
Show Gist options
  • Save 0awawa0/99a13f9430b01b9821467d771af6f1d9 to your computer and use it in GitHub Desktop.
Save 0awawa0/99a13f9430b01b9821467d771af6f1d9 to your computer and use it in GitHub Desktop.
#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