linux Enumeration For Privilege esclation
In this article I will share with you some techniques for enumerate linux system.
Table of contents :
- System and User Enumeration
- Files Enumeration
- Network Enumeration
- Password Enumeration
- Automation Tools
System and User Enumeration
System and user enumeration involves gathering information about the operating system, users, groups, and privileges to identify potential weaknesses for privilege escalation.
uname: Theunamecommand, when used with the-aoption, displays detailed information about the Linux kernel:
| |
cat /etc/os-release: This command displays information about the target system’s distribution and version:
| |
cat /proc/version: This command displays more detailed information about the Linux kernel, including the compiler used to build it:
| |
Current User and Group:
| |
Logged-in Users:
| |
System Users:
| |
Sudo Permissions:
| |
Environment Variables:
| |
Processes Owned by Other Users:
| |
Hidden Users (Check for unusual configurations):
| |
Files with SUID/SGID Bit:
| |
Files Enumeration
File enumeration involves searching for sensitive files, misconfigurations, or improper permissions that can be exploited to escalate privileges or gain unauthorized access.
Search for World-Writable Files:
| |
Search for World-Writable Directories:
| |
Search for Files Owned by Root:
| |
Search for Files with SUID Bit:
| |
Search for Files with SGID Bit:
| |
Search for Configuration Files Containing Credentials:
| |
Identify Writable Files in System Directories:
| |
Look for Backup Files:
| |
Search for SSH Keys:
| |
Search for Sensitive Application Configuration Files;
Apache:
| |
MySQL:
| |
Find Recent Files Modified or Created:
| |
Find Hidden Files:
| |
Identify Files Owned by Current User:
| |
Check for Backup/Temp Files in Home Directories:
| |
Network Enumeration
Network enumeration involves discovering network configurations, active connections, and accessible services to identify potential attack vectors for privilege escalation or lateral movement.
Show Network Interfaces:
| |
Routing Table:
| |
View Active Network Connections:
| |
DNS Configuration:
| |
ARP Table:
| |
Ping to Test Connectivity:
| |
Traceroute to Map Network Path:
| |
Identify Listening Ports:
| |
Scan Open Ports on Target:
| |
Password Enumeration
Password hunting involves searching for stored credentials, configuration files, or weakly protected secrets that can be used to gain unauthorized access or escalate privileges.
- Some applications and services store sensitive information, including credentials, in configuration files.
Common Locations:
| |
Look in directories like /etc/, /var/, /opt/, and /home/. Examples of Files to Check:
| |
- Check History Files Users often type sensitive commands that get stored in shell history files.
| |
Look for commands like ssh, sudo, mysql, or any with plaintext passwords.
- Search for Files Containing the Word “Password” Look for plaintext credentials in files.
| |
Include variations like “passwd,” “pass,” or “pwd.”
- Search for SSH Keys SSH private keys can be used to log into other systems.
| |
Check default paths like ~/.ssh/.
- Look for Database Credentials Applications often store database credentials in config files.
| |
Files to check: wp-config.php (WordPress) .env (Laravel or modern apps) settings.py (Django)
- Dump Memory for Passwords Sometimes passwords can be found in running memory.
| |
Alternatively, check running processes:
| |
- Check for Backup Files Old backups may contain sensitive data.
| |
- Identify Open Connections for Exposed Credentials Applications exposing credentials via environment variables or arguments can be a goldmine.
| |
Check processes:
| |
- Look for Git or Repository Secrets Repositories often accidentally include credentials.
| |
- Dump Browser Credentials Browsers often save login information.
Firefox:
| |
Chrome: Credentials are stored in `~/.config/google-chrome/Default/Login Data (encrypted).
- Enumerate Credentials in Docker or Kubernetes
Docker:
| |
Kubernetes:
| |
- Extract Passwords from Files Using Tools Tools like strings, binwalk, or exiftool can help extract data from binary files.
| |
- Enumerate Web Credentials Search web server files for hardcoded credentials:
| |
- Advanced: Check for Password Reuse If you find a password or hash, try it across other accounts/services.
| |
Automation tools
Automation tools help streamline the process of enumeration, vulnerability discovery, and privilege escalation by automating repetitive tasks and identifying potential weaknesses efficiently. In my opinion, mastering the process manually is preferable.
- LinPEAS
LinPEAS (Linux Privilege Escalation Awesome Script) is a powerful script designed to enumerate a Linux system for privilege escalation vectors and misconfigurations.
• Download Source: LinPEAS GitHub Repository LinPeas
- Linux Exploit Suggester
This tool identifies potential privilege escalation vulnerabilities based on the system’s kernel version and configuration.
• Download Source: Linux Exploit Suggester GitHub Repository Linux Exploit Suggester
- LinEnum
LinEnum is a lightweight script that performs comprehensive enumeration of a Linux system, including user details, file permissions, and potential privilege escalation paths.
• Download Source: LinEnum GitHub Repository LinEnum
- Pspy
Pspy is a process monitoring tool that allows you to watch processes executed on a Linux system without needing elevated privileges.
• Download Source: pspy GitHub Repository Pspy
Conclusion In this article, I’ve shared key aspects of enumeration to help us master privilege escalation, from system and user insights to files, networks, and passwords. While tools can assist, I believe manual expertise is crucial. Thanks for reading, and happy learning!
