Enumeration is key to privilege escalation. Several helper scripts exist to assist with enum, but its important to know what pieces of information to look for to be able to perform enumeration manually. When you gain initial shell access, it's important to check several key details:
- OS Version
- Knowing distribution will give you an idea of available tools, and if the version itself is exploitable
- Kernel version
- Similar to above. Public pocs for kernel version. These are dangerous. Know what they do before trying in a prod system
- Running services
- Knowing what svcs are running is important, especially those run as root. Misconfig/vulnerable services running as root can be easy win for privesc. Flaws are discovered in many common svcs (Nagios, Exim, Smba, ProFTPd, etc)
- Public PoCs exist for many of them.
ps aux | grep root
Installed packages and versions
- Out of date or vulnerable packages can be easily leveraged for privesc
- EX:
screen, common terminal multiplexer (think tmux)- Allows starting a session and open many windows of virtual terminals instead of multiple terminal sessions
- Screen version 4.05.00 suffers from privesc vuln
- EX:
Logged-in users
- Knowing other users logged in and what they are doing can give greater insight into possible local lateral movement and privesc paths
User home directories
- Other /home/ accessible? Other user home pages may contain SSH keys that can be used for lateral movement and gain access to other config files containing credentials. Not uncommon
- May even find a file with creds to gain entry into AD
.bash_historymay be readable and contain interesting info- If you find an SSH key for your current user this can be preferable than a revshell
- SSH Keys can also be leveraged to access other machines on the network as well
- At minimum check ARP cache to see what other hosts are being accessed and cross-reference these against usable SSH keys.
Sudo privileges
- If user can run commands as another user or root that's a potential path for privesc.
- sudoer entries often include NOPASSWD (no prompt)
- Not all commands runnable as root lead to privesc however.
- Not uncommon to be able to simply run
sudo suand enter a root shell.
Configuration files
- Wealth of info. Search through all files that end in extensions like .conf and .config for usernames/pass/secrets
- Readable shadow file - Self explanatory. Gather pw hashes and brute them.
- Password hashes in /etc/passwd - Occasionally hashes will be directly viewable in etc/passwd. Read above.
Cron jobs
- Scheduled tasks
- Often setup to perform maintenance + backup tasks
- In conjunction with other misconfigurations like relative paths or weak perimssions, often a privesc path
Unmounted file systems and additional drives
- If discover + mount an additional drive or unmounted file system, its possible to find sensitive files, passwords, or backups that can be leveraged for privesc.
lsblk
SETUID and SETGID permissions
- Binaries are set with permissions to allow a user to run a command as root, without granting root-level access to a user. Many bins contain functionality that can be exploited to get a root shell
Writeable directories
- Important to discover which directories are writeable if we want to download tools to a system. May discover a writeable directory where cron job places files, which provides an idea of how often the cron job runs and could be used to elevate privileges if the script that runs the cron job runs is also writeable.
find / -path /proc -prune -o -type d -perm -o+w 2>/dev/null
Writeable files
- Any scripts/configs world-writeable?
- While altering configuration files can be extremely destructive there can be instances where a minor modification can open up further access.
- Any scripts that are run as root using cron jobs can be modified slightly to append a command.