There are several sources that can provide us with credentials that we put in four categories. These include, but are not limited to:
Files
History
Memory
Key-Rings
Configs
Command-line History
In-memory Processing
SSH Keys
Logs
Browser stored credentials
Cache
Databases
Notes
Scripts
Source codes
Cronjobs
Differ from Windows Authentication, Linux depends mostly on File. Therefore, it is crucial to keep this concept in mind and search, find and filter the appropriate files according to our requirements.
Files
Some useful commands to enumerate files:
SSH Keys
SSH keys are used to authenticate users to remote servers. They are stored in the ~/.ssh/ directory. The following commands can be used to find SSH keys:
History
The command-line history can be a goldmine for finding credentials. The following commands can be used to find command-line history:
Memory and Cache
For this, we can use a powerful tool similar to the one on Windows call LaZagne:
Browsers
Browsers store the passwords saved by the user in an encrypted form locally on the system to be reused. For example, the Mozilla Firefox browser stores the credentials encrypted in a hidden folder for the respective user. These often include the associated field names, URLs, and other valuable information.
For encrypted passwords, Firefox Decrypt can be used, it requires python3.9 to run the latest version.
Alternatively, LaZagne can be used to extract the credentials from the browser if supported.
Passwd, Shadow and Opasswd
The /etc/passwd file contains the user account information, while the /etc/shadow file contains the password information. The PAM library (pam_unix.so) can prevent reusing old passwords. The file where old passwords are stored is the /etc/security/opasswd.