From 8f4c0f2a8ef86942c4c147f82c5eeb2bd4107f9a Mon Sep 17 00:00:00 2001 From: sin Date: Tue, 22 Apr 2014 16:35:24 +0100 Subject: [PATCH] Add random replies for failed password attempts in su(1) --- su.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/su.c b/su.c index 2b5f0bf..9beb7d0 100644 --- a/su.c +++ b/su.c @@ -8,11 +8,13 @@ #include #include #include +#include #include "config.h" #include "util.h" extern char **environ; +static const char *randreply(void); static char *msetenv(const char *, const char *); static void dologin(struct passwd *); @@ -53,6 +55,8 @@ main(int argc, char *argv[]) else usage(); + srand(time(NULL)); + errno = 0; spw = getspnam(usr); if (errno) @@ -63,7 +67,7 @@ main(int argc, char *argv[]) switch (spw->sp_pwdp[0]) { case '!': case '*': - eprintf("Denied\n"); + eprintf("Denied.\n"); case '$': break; default: @@ -83,7 +87,7 @@ main(int argc, char *argv[]) eprintf("crypt:"); if (strcmp(cryptpass, spw->sp_pwdp) != 0) - eprintf("Denied\n"); + eprintf(randreply()); } errno = 0; @@ -122,6 +126,26 @@ main(int argc, char *argv[]) return (errno == ENOENT) ? 127 : 126; } +static const char * +randreply(void) +{ + static const char *replies[] = { + "Time flies like an arrow, fruit flies like a banana.\n", + "Denied.\n", + "You type like a dairy farmer.\n", + "CChheecckk yyoouurr dduupplleexx sswwiittcchh..\n", + "I met a girl with 12 nipples, it sounds weird dozen tit?\n", + "Here I am, brain the size of a planet and they ask me to keep hashing rubbish.\n", + "Clones are people two.\n", + "Your mom is an interesting su response.\n", + "no.\n", + "Your mom forgot to null-terminate???B?33??Abort (core dumped)\n", + "A fool-proof method for sculpting an elephant: first, get a huge block of marble; then you chip away everything that doesn't look like an elephant.\n", + "Bloating .data for fun and profit.\n", + }; + return replies[rand() % LEN(replies)]; +} + static char * msetenv(const char *name, const char *value) {