Possible optimisation by requesting how many passwords exist instead of brute forcing all passwords.
This commit is contained in:
parent
2a743c971b
commit
ccb1aa7548
BIN
bin/KeyMaster
BIN
bin/KeyMaster
Binary file not shown.
56
src/main.c
56
src/main.c
@ -169,7 +169,39 @@ int main(void)
|
||||
printf("\nList of existing passwords:\n<------->\n");
|
||||
Request req;
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
// send request with type 4 to get IDs for all passwords
|
||||
req.type = 4;
|
||||
memset(&req.key, 0, sizeof(req.key));
|
||||
req.ID = 1;
|
||||
req.level = 0;
|
||||
|
||||
send(sockfd, &req, sizeof(req), 0);
|
||||
if (req.level == -1)
|
||||
{
|
||||
printf("No passwords found\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < req.level; i++)
|
||||
{
|
||||
Request req1;
|
||||
|
||||
req1.type = 0;
|
||||
memset(&req1.key, 0, sizeof(req1.key));
|
||||
req1.ID = i;
|
||||
req1.level = 0;
|
||||
|
||||
send(sockfd, &req1, sizeof(req1), 0);
|
||||
|
||||
// Receive response from the server
|
||||
recv(sockfd, &req1, sizeof(req1), 0);
|
||||
if (req1.level != -1 && strlen(req1.key) > 0)
|
||||
{
|
||||
printf("ID: %d\tKey: %s\n", req1.ID, req1.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* for (int i = 0; i < 256; i++)
|
||||
{
|
||||
Request req1;
|
||||
|
||||
@ -186,7 +218,7 @@ int main(void)
|
||||
{
|
||||
printf("Level: %d\tKey: %s\n", req1.level, req1.key);
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
printf("<------->\n\n");
|
||||
choice = prompNormalRequest(">> ");
|
||||
@ -240,6 +272,26 @@ int main(void)
|
||||
free(aux);
|
||||
free(aux2);
|
||||
}
|
||||
else if (strcmp(choice, "delpass") == 0)
|
||||
{
|
||||
printf("Please enter the level of security for the password to delete (1-255): ");
|
||||
int level;
|
||||
scanf("%d", &level);
|
||||
clear_input_buffer();
|
||||
|
||||
if (level < 0 && level > 255)
|
||||
{
|
||||
printf("Invalid level of security\nStopping...\n");
|
||||
continue;
|
||||
}
|
||||
// send request with TYPE = 2
|
||||
req.type = 2;
|
||||
memset(&req.key, 0, sizeof(req.key));
|
||||
req.ID = 1;
|
||||
req.level = level;
|
||||
|
||||
send(sockfd, &req, sizeof(req), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Invalid command (%s)\n\"Q\" or \"quit\" or \"exit\" to close the program\n", choice);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user