Credential Hunting for Linux Privilege Escalation
Credentials left on disk are one of the most reliable escalation paths. Passwords in config files, history files, and environment variables frequently belong to root or a higher-privileged user. No exploit required — find the credential, authenticate, done.
Prerequisites Check
Confirm your current user and what you can read:
A low-privilege user can still read world-readable files, files in their home directory, and files owned by their group. Check your group memberships — adm group gets log access, docker group gets socket access. See https://hackindex.io/platforms/linux/privilege-escalation/group-based-privilege-escalation.
Shell History Files
The first place to look. Users frequently run commands with passwords inline:
Check history files for all users if readable:
Look for patterns indicating credentials were passed on the command line:
Config Files
Application config files are the most consistent source of credentials in labs and real environments:
Environment Variables
Running processes and shell sessions may have credentials in environment variables:
.env files are common in web applications and contain plaintext credentials:
SSH Private Keys
A readable SSH private key for root or another user is an immediate escalation path:
Read the key and check for a passphrase — unencrypted keys (no Proc-Type: 4,ENCRYPTED line) are immediately usable:
Use against the target:
Check authorized_keys — it reveals which users can authenticate and from where:
Database Credentials
Database config files almost always contain credentials. Test them against local and remote services:
System and Application Logs
Logs capture credentials when they are passed incorrectly — failed su attempts with the password in the username field, application startup logs with connection strings, debug logs:
adm group membership gives full log access. See https://hackindex.io/platforms/linux/privilege-escalation/group-based-privilege-escalation.
Systemd Service Credentials
Systemd units frequently store credentials in Environment= lines or EnvironmentFile= paths:
Scripts and Backup Files
Backup files and scripts left in web roots or home directories often contain credentials from previous configurations:
Password Reuse
Once you find any credential, test it against everything:
Password reuse across services and users is extremely common in lab environments. A single MySQL password frequently also works for su, SSH, or sudo.
Automated Credential Search
LinPEAS covers most of these automatically. Run it first, then manually check anything it highlights:
For a focused manual search combining all common patterns:
See https://hackindex.io/platforms/linux/privilege-escalation/privilege-escalation-enumeration-tools for full enumeration tool coverage.
References
-
PEASS-ng Automated credential discovery across history, configs, and environment files.
-
grep(1) Manualman7.org/linux/man-pages/man1/grep.1.html (opens in new tab)
Pattern matching options for recursive credential searches.
Was this helpful?
Your feedback helps improve this page.