Gathering Information of the System
To escalate privileges on a Linux system, it’s crucial to gather as much information about the environment as possible. This helps identify potential weaknesses or misconfigurations that can be exploited. Below are some key commands that can be used for enumeration, along with a few additional ones to broaden the assessment.
Linux Privilege Escalation: Environment Enumeration
Check OS Information:
cat /etc/os-releaseContains details about the operating system version, distribution, and other useful information.
Inspect the PATH Variable:
echo $PATHReveals directories in the system's PATH, which could expose writable or insecure paths.
List Environment Variables:
envLists all environment variables. Sensitive information like credentials might be exposed.
Check Kernel Version:
uname -aDisplays kernel version, system architecture, and other details. Certain versions may have known vulnerabilities.
List Available Shells:
cat /etc/shellsShows available login shells. Vulnerable or misconfigured shells can provide opportunities for escalation.
View Routing Table:
route # or netstat -rnDisplays the routing table, helping identify available network interfaces.
Check ARP Table:
arp -aShows the ARP table, revealing other hosts the target machine communicates with.
List SUID and SGID Files:
find / -perm /4000 2>/dev/nullFinds SUID binaries, which run with the file owner's privileges (often root).
Check for Running Processes:
ps auxLists all running processes. Look for processes running as root or with elevated privileges.
Check for Installed Packages:
dpkg -l # For Debian-based systems rpm -qa # For Red Hat-based systemsLists installed packages. Some might have known vulnerabilities or misconfigurations.
Check Crontab Entries:
crontab -l cat /etc/crontabLists scheduled cron jobs. Misconfigured cron jobs running as root can be exploited.
Check Active Network Connections:
netstat -tulnDisplays active network connections and listening ports, which can help identify services running as root.
View Mounted File Systems:
mountLists mounted file systems. Uncommon or insecure mounts can offer opportunities for privilege escalation.
Check Writable Directories for Other Users:
find / -writable -type d 2>/dev/nullIdentifies world-writable directories that could be leveraged to inject malicious files.
Inspect sudo Privileges:
sudo -lLists what commands the current user is allowed to run with sudo, revealing potential escalation paths.
Last updated
Was this helpful?