๐Linux Local Enumeration
Enumerating System Information
After gaining initial access to a target system, it is always important to learn more about the system like, what OS is running as well as the OS version. This information is very useful as it gives us an idea of what we can do and what type of exploits we can run.
What are we looking for?
Hostname
Distribution & distribution release version
Kernel version & architecture
CPU information
Disk information & mounted drives
Installed packages/software
MSFconsole Commands:
sessions -u 1โ upgrades the shell to Meterpreter shell.
Meterpreter Command:
sysinfoโ Display system information for the compromised machine.
Linux Commands:
/bin/bash -iโ Start an interactive bash shell.hostnameโ Display the name of the host (computer) on which the command is executed.cat /etc/issueโ Show the operating system and version information.cat /etc/*releaseโ Display distribution-specific release information.uname -aโ Show detailed system information.uname -rโ Display the kernel release information.envโ Display environment variables.lscpuโ Display information about the CPU architecture.free -hโ Show memory usage in human-readable format.df -hโ Display disk space usage for all mounted filesystems.df -ht ext4โ Show disk space usage only for ext4 filesystems.lsblk | grep sdโ List block devices (drives) and filter for those containing "sd".dpkg -lโ List installed packages on a Debian-based system.
Enumerating Users & Groups
After gaining initial access to a target system, it is always important to learn more about the system like, what user account you have access to and other user accounts on the system.
What are we looking for?
Current user & privileges
Other users on the system
Groups
Meterpreter Command:
getuidโ Retrieve the current user's ID and privilege level.
Linux Commands:
whoamiโ Display the name of the currently logged-in user.sudo -lโ List available commands that the current user can run with sudo privileges.groups <user>โ Show group memberships of a specific user.cat /etc/passwd | grep -v /nologinโ Display user accounts excluding those with "/nologin" shell.wโ Display currently logged-in users with detailed information.whoโ Display currently logged-in users.lastโ Show listing of last logged-in users and logouts.lastlogโ Display information about last logged-in users.
Enumerating Network Information
What are we looking for?
Current IP address & network adapter
Internal networks
TCP/UDP services running and their respective ports
Other hosts on the network
Meterpreter Commands:
ifconfigโ Display network interface configuration.netstatโ Show network statistics and active connections.routeโ Display the routing table.arpโ Show the ARP (Address Resolution Protocol) cache.
Linux Commands:
ifconfigโ Display network interface configuration.ip a sโ Show IP address information for all interfaces.cat /etc/networksโ Display network configuration information.cat /etc/hostnameโ Show the hostname of the system.cat /etc/hostsโ Display the hosts file, mapping hostnames to IP addresses.cat /etc/resolv.confโ Show DNS resolver configuration.arp -aโ Display the ARP cache of the system.
Enumerating Processes & Cron Jobs
After gaining initial access to a target system, it is always important to learn more about the system like, what processes, services and scheduled tasks are currently running.
What are we looking for?
Running services
Cron Jobs
Meterpreter Command:
psโ List running processes on the target system.
Linux Commands:
psโ Display running processes.ps auxโ List all running processes with detailed information.topโ Display dynamic real-time information about system processes.crontab -lโ List the cron jobs for the current user.ls -al /etc/cron*โ List cron-related files and directories in the/etc/directory.cat /etc/cron*โ Display the content of cron-related files in the/etc/directory.
Automating Linux Local Enumeration
In addition to performing local enumeration manually, we can also automate the process with the help of a few scripts and MSF modules.
While local enumeration techniques/commands are important to know, as a penetration tester, you will need to be time efficient. As a result, you will need to learn how to utilize various automated enumeration scripts.
In addition to automating the process of enumerating information like system information, users & groups etc, these automated enumeration scripts will also provide you with additional information regarding the target system like; privilege escalation vulnerabilities, locally stored passwords etc.
Linux Local Enum Scripts
LinEnum- LinEnum is a simple bash script that automates common Linux local enumeration checks in addition to identifying privilege escalation vulnerabilities.
MSFconsole Post-exploitation Modules for Linux:
/post/linux/gather/enum_configsโ Gather configuration information on a Linux system./post/linux/gather/enum_networkโ Enumerate network-related information on the target Linux system./post/linux/gather/enum_systemโ Enumerate general system information on a Linux system./post/linux/gather/checkvmโ Check if the target Linux system is a virtual machine.
Getting LinEnum Script on Target System:
Visit the GitHub repository of LinEnum Script and copy the script from the RAW tab.
Paste the copied script on the attacking machine.
Use a Meterpreter shell to upload the script to the victim's temporary folder using the
"upload <file_path>"command.Give executable permissions to the script using
"chmod +x <script_name>".Run the script using the command
"./linenum".
Hacker's Mantra:In a world of zeros and ones, hackers are the ones who see the bigger picture.
Last updated
Was this helpful?