Add sleep between wrong password attempts

This is required for #1
This commit is contained in:
sw1tchbl4d3 2021-07-13 23:42:11 +02:00
parent a12c72a26a
commit 9fa1190f7d
2 changed files with 10 additions and 2 deletions

11
rdo.c
View file

@ -4,6 +4,7 @@
#include <crypt.h> #include <crypt.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <bsd/readpassphrase.h> #include <bsd/readpassphrase.h>
@ -40,6 +41,10 @@ void runprog(int argc, char** argv) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
char username[64];
char wrong_pw_sleep[64];
unsigned int sleep_ms;
if (argc < 2) if (argc < 2)
errx(1, "Please specify a program to run"); errx(1, "Please specify a program to run");
@ -54,9 +59,10 @@ int main(int argc, char** argv) {
runprog(argc, argv); runprog(argc, argv);
return 0; return 0;
} }
char username[64];
getconf(fp, "username", username, sizeof(username)); getconf(fp, "username", username, sizeof(username));
getconf(fp, "wrong_pw_sleep", wrong_pw_sleep, sizeof(wrong_pw_sleep));
sleep_ms = atoi(wrong_pw_sleep) * 1000;
struct passwd* p = getpwnam(username); struct passwd* p = getpwnam(username);
if (!p) if (!p)
@ -82,6 +88,7 @@ int main(int argc, char** argv) {
return 0; return 0;
} }
usleep(sleep_ms);
fprintf(stderr, "Wrong password.\n"); fprintf(stderr, "Wrong password.\n");
tries++; tries++;
} }

View file

@ -1 +1,2 @@
username=sw1tchbl4d3 username=sw1tchbl4d3
wrong_pw_sleep=1000