From 8957cbc53f721786e4b4db674597f79e838186d0 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 4 Nov 2019 17:27:13 -0500 Subject: Hash client passwords with crypt --- bounce.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'bounce.c') diff --git a/bounce.c b/bounce.c index 537f539..889ed5b 100644 --- a/bounce.c +++ b/bounce.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,16 @@ #define SIGINFO SIGUSR2 #endif +static void hashPass(void) { + char *pass = getpass("Password: "); + byte rand[12]; + ssize_t len = getrandom(rand, sizeof(rand), 0); + if (len < 0) err(EX_OSERR, "getrandom"); + char salt[3 + BASE64_SIZE(sizeof(rand))] = "$6$"; + base64(&salt[3], rand, sizeof(rand)); + printf("%s\n", crypt(pass, salt)); +} + static FILE *saveFile; static void saveExit(void) { @@ -190,7 +201,7 @@ int main(int argc, char *argv[]) { const char *away = "pounced :3"; const char *quit = "connection reset by purr"; - const char *Opts = "!A:C:H:K:NP:Q:U:W:a:f:h:j:n:p:r:s:u:vw:"; + const char *Opts = "!A:C:H:K:NP:Q:U:W:a:f:h:j:n:p:r:s:u:vw:x"; const struct option LongOpts[] = { { "insecure", no_argument, NULL, '!' }, { "away", required_argument, NULL, 'A' }, @@ -244,6 +255,7 @@ int main(int argc, char *argv[]) { break; case 'u': user = optarg; break; case 'v': verbose = true; break; case 'w': pass = optarg; + break; case 'x': hashPass(); return EX_OK; break; default: return EX_USAGE; } } -- cgit 1.4.1