Linux PrivEsc

METHODOLOGY:

  1. Run "uname -a" to check kernel version.

  2. Run "sudo -l" command. (If nothing found, move ahead)

  3. Check /etc/passwd for usernames.

  4. If /etc/passwd has W access then use openssl to create new root user.

  5. Check if /etc/shadow has RW access. (Crack the hash)

  6. Check for backup files at /home/user, /root, /tmp, /var/backups

  7. Enumerate user's home directory (check for interesting files, intel, ssh keys)

  8. Check web root dir. cd /etc/apache2. grep -Ri DocumentRoot .

  9. Check grep -R '$bigtree\["config"\]["db"\]' . (. for current dir)

  10. Alternative for above find . -iname '*config*'

  11. Enumerate the /var/www/ directory to find config files and other info.

  12. Check already found credentials for database running on machine.

  13. Check if root login is allowed with SSH (grep PermitRootLogin /etc/ssh/sshd_config)

  14. If you find nothing after this, then follow these steps:

FILE PERMISSIONS /etc/shadow

#READ ACCESS
#Extract the hash and save it in hash.txt file in Kali machine
#Check the hash type using https://hashcat.net/wiki/doku.php?id=example_hashes
#Crack it using JOHN or HASHCAT
john --format=sha512crypt --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
hashcat -m 1800 hash.txt /usr/share/wordlists/rockyou.txt
#Switch to that user using "su username" followed by password you cracked

#WRITE ACCESS
#Create a password hash
mkpasswd -m sha-512 newpass
#Replace the user's hash with the one we generated

FILE PERMISSIONS /etc/passwd

SUDO PRIVESC

SUID/SGID FILES

CRON JOBS

PASSWORDS AND KEYS

BACKUP FILES

MYSQL UDF

NFS

SSH PORT FORWARDING

MYSQL UDF

Last updated

Was this helpful?