LinEnum
Understanding LinEnum
LinEnum is a Privilege Escalation Checker. Here I will try to breakdown and understand the commands used specifically for information gathering. I am not trying to analyze the script but what it is getting, how it is getting it, and why it is getting it. This script is pretty well commented so much of the work is done for us.
Main Functions
header debug_info system_info user_info environmental_info job_info networking_info services_info software_configs interesting_files docker_checks lxc_container_checks footer
Information Gathering Commands
List of binaries from GTFO Bins
binarylist='aria2c\|arp\|ash\|awk\|base64\|bash\|busybox\|cat\|chmod\|chown\|cp\|csh\|curl\|cut\|dash\|date\|dd\|diff\|dmsetup\|docker\|ed\|emacs\|env\|expand\|expect\|file\|find\|flock\|fmt\|fold\|ftp\|gawk\|gdb\|gimp\|git\|grep\|head\|ht\|iftop\|ionice\|ip$\|irb\|jjs\|jq\|jrunscript\|ksh\|ld.so\|ldconfig\|less\|logsave\|lua\|make\|man\|mawk\|more\|mv\|mysql\|nano\|nawk\|nc\|netcat\|nice\|nl\|nmap\|node\|od\|openssl\|perl\|pg\|php\|pic\|pico\|python\|readelf\|rlwrap\|rpm\|rpmquery\|rsync\|ruby\|run-parts\|rvim\|scp\|script\|sed\|setarch\|sftp\|sh\|shuf\|socat\|sort\|sqlite3\|ssh$\|start-stop-daemon\|stdbuf\|strace\|systemctl\|tail\|tar\|taskset\|tclsh\|tee\|telnet\|tftp\|time\|timeout\|ul\|unexpand\|uniq\|unshare\|vi\|vim\|watch\|wget\|wish\|xargs\|xxd\|zip\|zsh'System Info
Get kernel info
uname -a 2>/dev/nullGet kernel info
cat /proc/version 2>/dev/nullGet OS info ```cat /etc/*-release 2>/dev/null
Get hostname
```bash
hostname 2>/dev/nullUser Info
User ID and groups
Get the last time users logged in
Get users currently logged in
for i in $(cut -d":" -f1 /etc/passwd 2>/dev/null);do id $i;done 2>/dev/null Get all IDs and groups Get adm users (Admin Users)
Check for hashes in passwd
/etc/passwd contents
Attempt to read master.passwd
Attempt to read /etc/shadow
Get all accounts with UID 0
Get sudoers
Get sudo permissions without password
Get sudo permissions with password
Checks if any of the binaries in GTFO Bins can be ran as sudo
Get users who have successfully used sudo
Check if root directory is readable
Get home directory permissions
Get a list of files writeable but not owned by the current user
Get a list of files owned by the current user
List hidden files
Find world writable files within /home directories
List contents of the current user's home directory
Finds various important ssh files
Check if root can log in via ssh
Environmental
Get Environment Variables
Check if SELinux is enabled
Get $PATH
Get a list of shells that are available
Get the UMASK value
Get the UMASK from /etc/login.defs
Get Password Policy info
Jobs
Get cron jobs
Check permissions on cron jobs
Get system-wide cron jobs
Get user cron jobs
Get anacron jobs
Get user anacron jobs
Check if any user in /etc/passwd has cronjobs
List systemtimers (These are like cronjobs where they perform a task at a given interval.)
Networking
Get network interface information
Get network interface information
Print the ARP table
Print the ARP table
Get nameservers
Get nameservers
Get default route
Get default route
Get listening TCP ports
Get listening TCP Ports
Get Listening UDP Ports
Get listening UDP Ports
Services
Get all running processes (List list will be limited to what the current user can view)
Get the process binary path as well as the permissions The awk '!x\[$0\]++' Is a bit confusing but what this is doing is creating a hash table where the current line is the key and the value is incremented by one each time it is referenced. If it is the first time the line is referenced, it gets printed and the count gets incremented by 1; otherwise the line gets ignored.
Prints inetd.conf for a manual check for useful information
Get binaries and their permissions from inetd
Print xinetd.conf for manual inspection
Check if /etc/xinetd.d is in xinetd.conf
Get binaries and their permissions from xinetd
Get init.d files' permissions
Check if there are any init.d files not owned by root
Get file permissions for rc.d/init.d
Check if there are any init.d files not owned by root
Get file permissions for /usr/rc.d files
Check for rc.d files not owned by root
Check /etc/init permissions
Check for startup scripts not owned by root
Get systemd config file permissions
Check for systemd files not owned by root
Software
Get Sudo Version
Get MySQL version
Check root:root password for mysql
Get Postgres version
Checks connection with several users to different databases
Get apache and httpd versions
Get the user running apache
Check to see what apace and httpd modules are installed
Find .htpasswd files and print them out
Check the contents of default http directories
Interesting Files
Check to see if various useful tools are installed
Check to see if compilers are installed
Lists permissions of some sensitive files that need to be manually checked
Find SUID files
Find SUID files that are part of GTFO Bins (assumes the previous command is stored in a variable $allsuid)
Check for SUID files that are world writeable
Check for world writeable SUID files owned by root
Find SGID files
Check for SGID files that are part of GTFO Bins (assumes that the previous commad is store in a variable $allsgid)
Check for world writeable SGID files
Check for world writeable SGID files owned by root
List all files with POSIX capabilities
Search for capability of users
User Capabilities
Search for readable private keys
Search for AWS keys
Search for git creds
List all world writeable files excluding those in /proc and /sys
List any .plan files
List any .plan files (BSD)
Find and print any .rhost files
Find and print any .rhost files (BSD)
TODO
Print /etc/exports
Print /etc/fstab
Look for creds in /etc/fstab
Looking for creds in /etc/fstab round 2
Search conf files for a given keyword stored in $keyword
Search php files for a given keyword stored in $keyword
Search log files for a given keyword stored in $keyword
Search ini files for a given keyword stored in $keyword
Get all conf files from /etc/
Get all current user history files
Attempt to get root's history
Find and print all .bash_history files that are readable
Find any .bak files
Check if there is any readable mail
Check if root has mail that can be read by the current user
Docker
Check if current environment is a docker instance
Check if docker is installed and if there are any instances
Check if the current user is in the docker group
Find Dockerfile files
Find docker-compose.yml files
LXC Container
Check if current environment is a LXC container
Check if current user is in the lxd group
TODO
Go through and explain why these each check can be helpful. (Some are obvious.)
Last updated
Was this helpful?