This commit is contained in:
2025-12-20 16:49:47 +00:00
parent ef11ce0307
commit 555b9062f3
19 changed files with 234 additions and 1 deletions

30
pa/lab6/check.c Normal file
View File

@@ -0,0 +1,30 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include "general.h"
int check_password(char* password) {
char buffer[32];
strcpy(buffer, password);
if(strcmp(buffer, getflag()) == 0)
return 1;
return 0;
}
int main() {
init();
char pass[64] = {0};
// we know how to make this secure. No gets in here.
read(0, pass, 63);
if(check_password(pass)){
printf("Welcome back! Here is the secret flag that you already knew: %s\n", getflag());
} else {
printf("Unauthorized user/passwd\n");
}
}