Table of Contents


Checklist

  • System Enumeration
    • - “The 7 W’s” commands
      • - whoami - See the name of the current user
      • - hostname - See the name of the current host
      • - pwd - Look what directory you’re in
      • - id - look which groups the current user is a part of
      • - history - Look through the terminal history to see if there aren’t any low hanging fruits. Also look through .bash_history, .bashrc and .bash_profile
      • - sudo -l - Look for any useful sudo rights. Compare them with GTFObins and if nothing is there - try LD_PRELOAD privesc
      • - cat /etc/sudoers - Look for any relative paths - this could be a way for privesc
    • - Check common folders
      • - Look for hidden files: ls -la
      • - ~ for a the home directory
      • - /home/Desktop
      • - /home - and other users’ home folders if he have the access to do so
      • - /root
      • - /tmp and /var/tmp
      • - /var/www/html for Apache webserver
      • - /opt
    • - System information
      • - cat /etc/os-release and cat /etc/lsb-release
    • - /etc/passwd, /etc/shadow and /etc/security/opasswd
      • - Check if you can view them and enumerate information inside
      • - grep "*sh$" /etc/passwd - to check for users with an actual shell
    • - Check for SSH keys
      • - grep -rnw "PRIVATE KEY" /* 2>/dev/null | grep ":1" - Look for private keys
      • - grep -rnw "ssh-rsa" /home/* 2>/dev/null | grep ":1" - Look for private keys
    • - Check existing shells
      • - cat /etc/shells
    • - Folder and file enumeration
      • - Look for writable folders and files
        • - Folders - find / -path /proc -prune -o -type d -perm -o+w 2>/dev/null
        • - Files - find / -path /proc -prune -o -type f -perm -o+w 2>/dev/null
      • - Look for hidden folders and files
        • - Folders - find / -type d -name ".*" -ls 2>/dev/null
        • - Files - find / -type f -name ".*" -exec ls -l {} \; 2>/dev/null
      • - Look for folders with special privileges
        • - find / -user root -perm -4000 -exec ls -ldb {} \; 2>/dev/null - Check for SUID
        • - find / -user root -perm -6000 -exec ls -ldb {} \; 2>/dev/null - Check for SETGID
    • - Enumerate users and groups
      • - ps au - See logged in users
      • - cat /etc/group - Check all groups
    • - Check environmental variables
      • - echo $PATH
      • - env
      • - Check for any relative file paths (like home and not /home)
      • - Check if you can write to $PATH - PATH=.:${PATH}, export PATH and then echo $PATH
    • - Check processes and services for know exploits
      • - ps aux, ps aux | grep root, ps aux | grep tmux
      • - sudo -V - Check sudo version
        • - CVE-2021-3156 - 1.8.31 - Ubuntu 20.04, Debian 10 1.8.27, Fedora 33 1.9.2
        • - CVE-2019-14287 - From X to 1.8.28
        • Check for any other exploits on OSINT
      • - find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -type f -exec getcap {} \; - Check for any extensive capabilities rights
      • - screen -v - Check for screen version to exploit it (if it’s on a host)
      • - If the binary has a suid or sguid - check it for “Shared Object Hijacking” with ls -la.
  • Kernel
    • - uname -a, cat /etc/lsb-release and cat /proc/version
    • - Dirty Pipe - From 5.8 to 5.17
    • - Dirty Cow - From 2.6.22 to 4.8.3, 4.7.9, 4.4.26
    • - CVE-2021-22555 - From 2.6 to 5.11
    • - CVE-2022-25636 - From 5.4 to 5.6.10
    • - CVE-2023-32233 - From X to 6.3.1
    • - Check if polkit is on the host (pkexec) and check if it’s vulnerable to CVE-2021-4034 or any other known exploits
    • - Check for other possible exploits in OSINT
  • Drives & Mounts
    • - lsblk - Check for unmounted file systems/drives
    • - lpstat - Check for printers connected
    • - cat /etc/fstabor cat /etc/fstab | grep -v "#" | column -t (for prettier output) - View unmounted file systems
    • - df -h - View mounted file systems
    • - mount -t nfs - Check for locally mounted NFS shared
  • Network & Shares
    • - ss -tun - Check locally open ports
    • - ifconfig /all - Check for other networks
    • - arp -a - Look for any other commonly connecting hosts on the network
    • - route - Looking what other networks are accessible through which interface
    • - showmount -e - Check for a accessible NFS mounts
    • - cat /etc/resolv.conf - To see any internal DNS server and look for AD connection
    • - cat /etc/hosts - Check for any manual IP to host maps
    • - Look for browsers to enumerate credentials hashed inside of them
    • - Check for a possible Active Directory integration
  • Automation
    • - LinEnum - Scripted local Linux enumeration & privilege escalation checks (Smaller)
    • - LinPEAS - Scripted local Linux enumeration & privilege escalation checks for Linux/Unix*/MacOS (Bigger, more robust than LinEnum)
    • - LaZagne - Use LaZagne for looking for passwords
    • - GTFObins - Check for potentially exploitable binaries on the system - for i in $(curl -s https://gtfobins.github.io/ | html2text | cut -d" " -f1 | sed '/^[[:space:]]*$/d');do if grep -q "$i" installed_pkgs.list;then echo "Check GTFO for: $i";fi;done
  • CRON Jobs
    • - cat /etc/crontab - Look for system wide cron jobs
    • - ls -la /etc/cron.*/ - List all cron files
    • - Use PSPY to view running processes live for any cron jobs
  • Virtualization
    • - Look if you’re not in a lxd or lxc group (Alpine)
    • - Look if you’re not in the docket group
    • - Look for Kubernets ports
  • Deep search
    • - find /home/* -type f -name "*.txt" -o ! -name "*.*" - Look for simple notes that might’ve been missed
    • - Check if logrotate is susceptible for logrotten exploit (3.8.6, 3.11.0, 3.15.0, 3.18.0)
    • - find / -type f \( -name *_hist -o -name *_history \) -exec ls -l {} \; 2>/dev/null - Check for history files
    • - for i in $(find / -name *.cnf 2>/dev/null | grep -v "doc\|lib");do echo -e "\nFile: " $i; grep "user\|password\|pass" $i 2>/dev/null | grep -v "\#";done - Look for interesting config files
    • - find / -type f \( -name *.conf -o -name *.config \) -exec ls -l {} \; 2>/dev/null and for l in $(echo ".conf .config .cnf");do echo -e "\nFile extension: " $l; find / -name *$l 2>/dev/null | grep -v "lib\|fonts\|share\|core" ;done - Check for config files
    • - for l in $(echo ".sql .db .*db .db*");do echo -e "\nDB File extension: " $l; find / -name *$l 2>/dev/null | grep -v "doc\|lib\|headers\|share\|man";done - Look for database files
    • - find / -type f -name "*.sh" 2>/dev/null | grep -v "src\|snap\|share" and for l in $(echo ".py .pyc .pl .go .jar .c .sh");do echo -e "\nFile extension: " $l; find / -name *$l 2>/dev/null | grep -v "doc\|lib\|headers\|share";done - Check for scripts
    • - for i in $(ls /var/log/* 2>/dev/null);do GREP=$(grep "accepted\|session opened\|session closed\|failure\|failed\|ssh\|password changed\|new user\|delete user\|sudo\|COMMAND\=\|logs" $i 2>/dev/null); if [[ $GREP ]];then echo -e "\n#### Log file: " $i; grep "accepted\|session opened\|session closed\|failure\|failed\|ssh\|password changed\|new user\|delete user\|sudo\|COMMAND\=\|logs" $i 2>/dev/null;fi;done - Look for interesting log files
  • Last chance
    • Search through OSINT information
    • Search through your notes, HTB sections and cheatsheets
    • Rest and repeat the whole process, you must have missed something

References

Checklist - Linux Privilege Escalation
Linux Privilege Escalation
Linux - Privilege Escalation - Internal All The Things