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.
List systemtimers (These are like cronjobs where they perform a task at a given interval.)
systemctl list-timers --all 2>/dev/null
Networking
Get network interface information
/sbin/ifconfig -a 2>/dev/null
Get network interface information
/sbin/ip a 2>/dev/null
Print the ARP table
arp -a 2>/dev/null
Print the ARP table
ip n 2>/dev/null
Get nameservers
grep "nameserver" /etc/resolv.conf 2>/dev/null
Get nameservers
systemd-resolve --status 2>/dev/null
Get default route
route 2>/dev/null | grep default
Get default route
ip r 2>/dev/null | grep default
Get listening TCP ports
netstat -ntpl 2>/dev/null
Get listening TCP Ports
ss -t -l -n 2>/dev/null
Get Listening UDP Ports
netstat -nupl 2>/dev/null
Get listening UDP Ports
ss -u -l -n 2>/dev/null
Services
Get all running processes (List list will be limited to what the current user can view)
ps aux 2>/dev/null
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.
ps aux 2>/dev/null | awk '{print $11}'|xargs -r ls -la 2>/dev/null |awk '!x[$0]++' 2>/dev/null
Prints inetd.conf for a manual check for useful information
cat /etc/inetd.conf 2>/dev/null
Get binaries and their permissions from inetd
awk '{print $7}' /etc/inetd.conf 2>/dev/null |xargs -r ls -la 2>/dev/null
Print xinetd.conf for manual inspection
cat /etc/xinetd.conf
Check if /etc/xinetd.d is in xinetd.conf
grep "/etc/xinetd.d" /etc/xinetd.conf 2>/dev/null
Get binaries and their permissions from xinetd
awk '{print $7}' /etc/xinetd.conf 2>/dev/null |xargs -r ls -la 2>/dev/null
Get init.d files' permissions
ls -la /etc/init.d 2>/dev/null
Check if there are any init.d files not owned by root
find /etc/init.d/ \! -uid 0 -type f 2>/dev/null |xargs -r ls -la 2>/dev/null
Get file permissions for rc.d/init.d
ls -la /etc/rc.d/init.d 2>/dev/null
Check if there are any init.d files not owned by root
find /etc/rc.d/init.d \\! -uid 0 -type f 2>/dev/null |xargs -r ls -la 2>/dev/null
Get file permissions for /usr/rc.d files
ls -la /usr/local/etc/rc.d 2>/dev/null
Check for rc.d files not owned by root
find /usr/local/etc/rc.d \! -uid 0 -type f 2>/dev/null |xargs -r ls -la 2>/dev/null
Check /etc/init permissions
ls -la /etc/init/ 2>/dev/null
Check for startup scripts not owned by root
find /etc/init \\! -uid 0 -type f 2>/dev/null |xargs -r ls -la 2>/dev/null
Get systemd config file permissions
ls -lthR /lib/systemd/ 2>/dev/null
Check for systemd files not owned by root
find /lib/systemd/ \\! -uid 0 -type f 2>/dev/null |xargs -r ls -la 2>/dev/null
ls -alhR /var/www/ 2>/dev/null; ls -alhR /srv/www/htdocs/ 2>/dev/null; ls -alhR /usr/local/www/apache2/data/ 2>/dev/null; ls -alhR /opt/lampp/htdocs/ 2>/dev/null
Interesting Files
Check to see if various useful tools are installed
which nc 2>/dev/null ; which netcat 2>/dev/null ; which wget 2>/dev/null ; which nmap 2>/dev/null ; which gcc 2>/dev/null; which curl 2>/dev/null
Lists permissions of some sensitive files that need to be manually checked
ls -la /etc/passwd 2>/dev/null ; ls -la /etc/group 2>/dev/null ; ls -la /etc/profile 2>/dev/null; ls -la /etc/shadow 2>/dev/null ; ls -la /etc/master.passwd 2>/dev/null
Find SUID files
find / -perm -4000 -type f 2>/dev/null
Find SUID files that are part of GTFO Bins (assumes the previous command is stored in a variable $allsuid)
find $allsuid -perm -4000 -type f -exec ls -la {} \\; 2>/dev/null | grep -w $binarylist 2>/dev/null
Check for SUID files that are world writeable
find $allsuid -perm -4002 -type f -exec ls -la {} 2>/dev/null \;
Check for world writeable SUID files owned by root
find $allsuid -uid 0 -perm -4002 -type f -exec ls -la {} 2>/dev/null \;
Find SGID files
find / -perm -2000 -type f 2>/dev/null
Check for SGID files that are part of GTFO Bins (assumes that the previous commad is store in a variable $allsgid)
find $allsgid -perm -2000 -type f -exec ls -la {} \\; 2>/dev/null | grep -w $binarylist 2>/dev/null
Check for world writeable SGID files
find $allsgid -perm -2002 -type f -exec ls -la {} 2>/dev/null \;
Check for world writeable SGID files owned by root
find $allsgid -uid 0 -perm -2002 -type f -exec ls -la {} 2>/dev/null \;
if [ "$userswithcaps" ] ; then
#matches the capabilities found associated with users with the current user
matchedcaps=`echo -e "$userswithcaps" | grep \`whoami\` | awk '{print $1}' 2>/dev/null`
if [ "$matchedcaps" ]; then
echo -e "\e[00;33m[+] Capabilities associated with the current user:\e[00m\n$matchedcaps"
echo -e "\n"
#matches the files with capapbilities with capabilities associated with the current user
matchedfiles=`echo -e "$matchedcaps" | while read -r cap ; do echo -e "$fileswithcaps" | grep "$cap" ; done 2>/dev/null`
if [ "$matchedfiles" ]; then
echo -e "\e[00;33m[+] Files with the same capabilities associated with the current user (You may want to try abusing those capabilties):\e[00m\n$matchedfiles"
echo -e "\n"
#lists the permissions of the files having the same capabilies associated with the current user
matchedfilesperms=`echo -e "$matchedfiles" | awk '{print $1}' | while read -r f; do ls -la $f ;done 2>/dev/null`
echo -e "\e[00;33m[+] Permissions of files with the same capabilities associated with the current user:\e[00m\n$matchedfilesperms"
echo -e "\n"
if [ "$matchedfilesperms" ]; then
#checks if any of the files with same capabilities associated with the current user is writable
writablematchedfiles=`echo -e "$matchedfiles" | awk '{print $1}' | while read -r f; do find $f -writable -exec ls -la {} + ;done 2>/dev/null`
if [ "$writablematchedfiles" ]; then
echo -e "\e[00;33m[+] User/Group writable files with the same capabilities associated with the current user:\e[00m\n$writablematchedfiles"
echo -e "\n"
fi
fi
fi
fi
fi