Environment enumeration is the foundation of successful Linux privilege escalation. After gaining initial access to a Linux host, systematic enumeration helps identify potential attack vectors, misconfigurations, and valuable information that can lead to privilege escalation.
"Enumeration is the key to privilege escalation. Understanding what pieces of information to look for and being able to perform enumeration manually is crucial for success."
π Initial Situational Awareness
Fundamental Orientation Commands
Before diving deep into enumeration, establish basic situational awareness:
# Current user contextwhoami# What user are we running as?id# What groups does our user belong to?# System identification hostname# Server name and naming conventionsuname-a# Kernel and system information# Network positionifconfig# Network interfaces and subnetsipa# Alternative network interface command# Privilege checksudo-l# Can we run anything with sudo without password?
Why This Matters:
Documentation: Screenshots provide evidence of successful RCE
System Identification: Clearly identify the affected system
Quick Wins: sudo -l can sometimes provide immediate escalation paths
π Operating System Enumeration
System Version Detection
Check OS Distribution and Version:
Example Output:
Analysis Points:
Distribution Type: Ubuntu, CentOS, Debian, SUSE, etc.
Version Currency: Is the system maintained or end-of-life?
LTS Status: Long Term Support versions typically more secure
Release Lifecycle: Check if version has known vulnerabilities
Alternative OS Detection Methods
βοΈ System Environment Analysis
PATH Variable Examination
Check Current PATH:
Typical Output:
Security Implications:
PATH Hijacking: Writable directories in PATH can be exploited
Custom Paths: Non-standard paths may contain vulnerable binaries
Order Matters: Earlier directories take precedence
Environment Variables
Enumerate All Environment Variables:
Look for Sensitive Information:
Common Sensitive Variables:
Database passwords
API keys
Service credentials
Custom application secrets
π§ Kernel and Hardware Information
Kernel Version Analysis
Get Kernel Information:
Example Output:
Key Information:
Kernel Version: 5.4.0-122-generic
Build Date: Wed Jun 22 15:00:31 UTC 2022
Architecture: x86_64
Distribution: Ubuntu
CPU and Hardware Details
CPU Information:
Memory Information:
Hardware Details:
π Available Shells and Interpreters
Login Shell Enumeration
Available Shells:
Example Output:
Security Considerations:
Shell Vulnerabilities: Older bash versions vulnerable to Shellshock
Restricted Shells: rbash may limit command execution
Session Management: tmux/screen available for persistence
Interpreter Versions: Check for vulnerable versions
Shell Version Checking:
π‘οΈ Security Controls Detection
Identify Active Security Mechanisms
Common Security Tools to Check:
Why This Matters:
Attack Vector Selection: Avoid triggering active defenses
Environment enumeration provides the foundation for all subsequent privilege escalation attempts. Thorough initial reconnaissance significantly increases the likelihood of successful privilege escalation and helps identify the most efficient attack paths.
# Additional OS information sources
cat /etc/issue
cat /etc/redhat-release # Red Hat/CentOS systems
cat /etc/debian_version # Debian-based systems
lsb_release -a # LSB information (if available)
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 0 0 0 ens192
10.129.0.0 0.0.0.0 255.255.0.0 U 0 0 0 ens192
arp -a
ip neigh show
cat /etc/resolv.conf
netstat -tulpn
ss -tulpn
lsof -i
cat /etc/passwd
cat /etc/passwd | cut -f1 -d:
grep "sh$" /etc/passwd
# Check for users with login shells
grep -E "/bin/(bash|sh|zsh|csh|tcsh|fish)$" /etc/passwd
# Look for service accounts
grep -E "daemon|www-data|nginx|apache|mysql|postgres" /etc/passwd
# Find recently created users (high UID numbers)
awk -F: '$3 >= 1000 {print $1":"$3}' /etc/passwd
cat /etc/group
# sudo group members
getent group sudo
# admin group members
getent group admin
# wheel group (on some systems)
getent group wheel
# docker group (container access)
getent group docker
groups
id
ls -la /home
# Configuration files
find /home -name ".*rc" -type f 2>/dev/null
find /home -name "*.conf" -type f 2>/dev/null
# History files
find /home -name "*history*" -type f 2>/dev/null
# SSH keys
find /home -name "id_*" -type f 2>/dev/null
find /home -name "authorized_keys" -type f 2>/dev/null
# Scripts and automation
find /home -name "*.sh" -type f 2>/dev/null
find /home -name "*.py" -type f 2>/dev/null
# Check readable bash history
ls -la /home/*/.bash_history
# Look for notes and documentation
find /home -name "*note*" -type f 2>/dev/null
find /home -name "*password*" -type f 2>/dev/null
find /home -name "*cred*" -type f 2>/dev/null
find / -type f -name ".*" -exec ls -l {} \; 2>/dev/null | head -20
find / -type d -name ".*" -ls 2>/dev/null
find /home -type f -name ".*" -exec ls -l {} \; 2>/dev/null