Skip to content

Information gathering (linux)

Automated Enumeration Tools


  • LinPeas: https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS
  • LinEnum: https://github.com/rebootuser/LinEnum
  • LES (Linux Exploit Suggester): https://github.com/mzet-/linux-exploit-suggester
  • Linux Smart Enumeration: https://github.com/diego-treitos/linux-smart-enumeration
  • Linux Priv Checker: https://github.com/linted/linuxprivchecker
  • unix_privesc_check: https://pentestmonkey.net/tools/audit/unix-privesc-check

Host


hostname

System Information


os info Let's starting gaining some knowledge of the OS running

cat /etc/issue
cat /etc/*-release
kernel version
uname -a
arch
arch
cat /proc/version
uname -mrs
rpm -q kernel
dmesg | grep Linux
ls /boot | grep vmlinuz
path If you have written permissions on any folder inside the PATH variable you may be able to hijacking some libraries or binaries:
echo $PATH
env info Interesting information, passwords or API keys in the environment variables?
(env || set) 2>/dev/null
list mounted drives
cat /proc/mounts
mount
df -aTh
findmnt
kernel exploits Check the kernel version and if there is some exploit that can be used to escalate privileges
cat /proc/version
uname -a
searchsploit "Linux Kernel"

Useful software


enumerate useful binaries

which nmap aws nc ncat netcat nc.traditional wget curl ping gcc g++ make gdb base64 socat python python2 python3 python2.7 python2.6 python3.6 python3.7 python3.9 python3.10 perl php ruby xterm doas sudo fetch docker lxc ctr runc rkt kubectl 2>/dev/null
Also, check if any compiler is installed. This is useful if you need to use some kernel exploit as it's recommended to compile it in the machine where you are going to use it (or in one similar)
(dpkg --list 2>/dev/null | grep "compiler" | grep -v "decompiler\|lib" 2>/dev/null || yum list installed 'gcc*' 2>/dev/null | grep gcc 2>/dev/null; which gcc g++ 2>/dev/null || locate -r "/gcc[0-9\.-]\+$" 2>/dev/null | grep -v "/doc/")

vulnerable software installed Check for the version of the installed packages and services. Maybe there is some old Nagios version (for example) that could be exploited for escalating privileges… It is recommended to check manually the version of the more suspicious installed software.

dpkg -l #Debian
rpm -qa #Centos
If you have SSH access to the machine you could also use openVAS to check for outdated and vulnerable software installed inside the machine.

Note that these commands will show a lot of information that will mostly be useless, therefore it's recommended some application like OpenVAS or similar that will check if any installed software version is vulnerable to known exploits

User


user information

id
whoami
users
all users
cat /etc/passwd
user groups
groups
user history
history
cat /home/<user>/.bash_history
cat ~/.bash_history | less
cat ~/.mysql_history | less
cat ~/.nano_history | less
cat ~/.*history | less
find file by name
find . -name flag.txt
find file owned by user
find <directory-location> -user <username> -name <file-name> 2>/dev/null
find file owned by a group
find <directory-location> -group <group-name> -name <file-name>  2>/dev/null
**find file owned by a group (executable)
find <directory-location> -executable -group <group-name>  2>/dev/null

Cron


scheduled task

cat /etc/crontab
crontab -l
cat /etc/cron.deny
cat /etc/cron.hourly
cat /etc/cron.monthly
cat /etc/cron.weekly
cat /etc/cron*
file permissions
ls -la /etc/cron*
log
grep "CRON" /var/log/cron.log

Processes


list process Take a look to what processes are being executed and check if any process has more privileges than it should (maybe a tomcat being executed by root?)

ps aux
ps -A
ps axjf

Services


service

sudo systemctl start apache2
sudo systemctl status apache2
sudo systemctl restart apache2
sudo systemctl stop apache2
sudo systemctl enable apache2 # autostart on boot time
systemctl list-unit-files # list all services

service settings, there is any wrong allocation?

cat /etc/syslog.conf
cat /etc/chttp.conf
cat /etc/lighttpd.conf
cat /etc/cups/cupsd.conf
cat /etc/inetd.conf
cat /etc/apache2/apache2.conf
cat /etc/my.conf
cat /etc/httpd/conf/httpd.conf
cat /opt/lampp/etc/httpd.conf
ls -aRl /etc/ | awk ‘$1 ~ /^.*r.*/

Installed Applications

application (debina)

dpkg -l

Readable/Writable Files and Directories

find / -writable -type d 2>/dev/null
- -d directories

Network


TCP/IP configuration

ip a
ifconfig -a
routing tables
/sbin/route
/sbin/routel
active network connections
ss -anp
netstat -antup
netstat -antpx
netstat -tulpn
firewall
grep -Hs iptables /etc/*

Disks

enumeration all disks

mount
cat /etc/fstab
/bin/lsblk

Device Drivers and Kernel Modules

enumerate the loaded kernel modules

lsmod
use modinfo to find out more about the specific module
/sbin/modinfo libata

Binaries That AutoElevate

find / -perm -u=s -type f 2>/dev/null