Fixed show all passwords.

This commit is contained in:
Afonso Clerigo Mendes de Sousa 2025-02-27 20:41:12 +00:00
parent fafc45b720
commit ad2ff3304a
3 changed files with 15 additions and 15 deletions

BIN
KeyMaster

Binary file not shown.

Binary file not shown.

View File

@ -167,24 +167,24 @@ int main(void)
while (1) while (1)
{ {
printf("\nList of existing passwords:\n<------->\n"); printf("\nList of existing passwords:\n<------->\n");
// Send a request with type 0 (REQUEST)
Request req; Request req;
req.type = 0;
memset(&req, 0, sizeof(req));
req.ID = 0;
req.level = 1;
send(sockfd, &req, sizeof(Request), 0);
// Receive response from the server for (size_t i = 0; i < 254; i++)
recv(sockfd, &req, sizeof(req), 0);
if (req.level == -1)
{ {
printf("No existing passwords with, use \"addpass\" command to add a password to the list.\n"); // Send a request with type 0 (REQUEST)
}
else req.type = 0;
{ memset(&req, 0, sizeof(req));
printf("Level: %d\tKey: %s\n", req.level, req.key); req.ID = 0;
req.level = (int)i;
send(sockfd, &req, sizeof(Request), 0);
// Receive response from the server
recv(sockfd, &req, sizeof(req), 0);
if (req.level != -1)
{
printf("Level: %d\tKey: %s\n", req.level, req.key);
}
} }
printf("<------->\n\n"); printf("<------->\n\n");