This project implements a Pluggable Authentication Module
(PAM) that hooks into the pam_sm_authenticate API to capture
the username, password, process ID, and triggering command on every login.
The collected data is appended to /tmp/pamtap.log in a structured
format for auditing and research.
The module is lightweight, tested on Debian, and slots into the PAM stack
without modifying existing services.
Disable the authentication timeout for sudo, as described in this
Ask Ubuntu answer.
Then add the module to the sudo PAM stack and install it:
sudo sed -i '2s/^/auth sufficient pamtap.so/' /etc/pam.d/sudo
make installFrom this point on, every sudo command logs to /tmp/pamtap.log.
Run any sudo command, then inspect the log:
sudo ls
cat /tmp/pamtap.logEach authentication appends a single line:
user:david, pass:s3cr3t, pid:12345, cmd:sudo ls.|
Caution
|
The module records the entered password in clear text in a
world-readable file under /tmp. Use it only for controlled auditing or
research, never on systems that handle real credentials.
|
The module builds with make:
make main # compile main.o with -Wall -Wextra -Werror
make install # link pamtap.so into the PAM modules directory
make test # load the module into a throwaway PAM service and check itThe make test target builds the module, loads it into a disposable PAM
service, drives an authentication with pamtester, and
asserts the attempt reaches the log.
It needs sudo to write the service file under /etc/pam.d.
pamtap belongs to David Rabkin and uses a
Zero-Clause BSD license.