LinEnum
What Is LinEnum?
LinEnum is a simple bash script that performs common commands related to privilege escalation, saving time and allowing more effort to be put toward getting root. It is important to understand what commands LinEnum executes, so that you are able to manually enumerate privesc vulnerabilities in a situation where you're unable to use LinEnum or other like scripts. In this room, we will explain what LinEnum is showing, and what commands can be used to replicate it.
Where to Get LinEnum
You can download a local copy of LinEnum from https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh
It's worth keeping this somewhere you'll remember, because LinEnum is an invaluable tool.
Getting LinEnum onto the Target
There are two ways to get LinEnum on the target machine. The first way is to go to the directory that holds your local copy of LinEnum and start a Python web server with python3 -m http.server 8000 [1]. Then, using wget on the target machine and your local IP, grab the file from your local machine [2]. Finally, make the file executable with chmod +x FILENAME.sh.
Other Methods
If you're unable to transport the file and have sufficient permissions, copy the raw LinEnum code from your local machine [1] and paste it into a new file on the target using Vi or Nano [2]. Save the file with the .sh extension, then make it executable with chmod +x FILENAME.sh. You now have your own executable copy of the LinEnum script on the target machine.
Running LinEnum
LinEnum runs like any bash script. Go to the directory where LinEnum is and run ./LinEnum.sh.
Understanding LinEnum Output
The LinEnum output is broken down into different sections. These are the main ones to focus on:
- Kernel: Kernel information is shown here. There is most likely a kernel exploit available for this machine.
- Can we read/write sensitive files: The world-writable files are shown. These are files that any authenticated user can read and write to. Looking at their permissions shows where misconfiguration lets users who shouldn't be able to write to sensitive files.
- SUID Files: The output for SUID files is shown here. There are a few interesting items worth looking into as a way to escalate privileges. SUID (Set owner User ID up on execution) is a special type of file permission given to a file. It allows the file to run with the permissions of whoever the owner is. If this is root, it runs with root permissions. It can allow us to escalate privileges.
- Crontab Contents: The scheduled cron jobs are shown. Cron is used to schedule commands at a specific time. These scheduled commands or tasks are known as "cron jobs". Related to this is the crontab command, which creates a crontab file containing commands and instructions for the cron daemon to execute. There is certainly enough information to warrant attempting to exploit cronjobs here.
There's also a lot of other useful information contained in this scan. Let's have a read.
Cron tabs location: cat /etc/crontab