From 9fa1190f7d2211695e5f146868f7d6721a30a1d3 Mon Sep 17 00:00:00 2001 From: sw1tchbl4d3 Date: Tue, 13 Jul 2021 23:42:11 +0200 Subject: [PATCH] Add sleep between wrong password attempts This is required for #1 --- rdo.c | 11 +++++++++-- rdo_sample.conf | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rdo.c b/rdo.c index f1196a1..00c39e0 100644 --- a/rdo.c +++ b/rdo.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,10 @@ void runprog(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) errx(1, "Please specify a program to run"); @@ -54,9 +59,10 @@ int main(int argc, char** argv) { runprog(argc, argv); return 0; } - - char username[64]; + 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); if (!p) @@ -82,6 +88,7 @@ int main(int argc, char** argv) { return 0; } + usleep(sleep_ms); fprintf(stderr, "Wrong password.\n"); tries++; } diff --git a/rdo_sample.conf b/rdo_sample.conf index 8ba8716..3c00c78 100644 --- a/rdo_sample.conf +++ b/rdo_sample.conf @@ -1 +1,2 @@ username=sw1tchbl4d3 +wrong_pw_sleep=1000