Post

Linux Privilege Escalation

Linux

Manual Checks

A list of useful commands to perform manual privilege escalation on Linux operating system.

System Information

OS info

1
(cat /proc/version || uname -a ) 2>/dev/null
1
cat /etc/os-release 2>/dev/null

Path

1
echo $PATH

Env info

1
(env || set) 2>/dev/null

CPU info

1
lscpu

System stats

1
(df -h || lsblk)

Kernel Exploit

1
cat /proc/version
1
uname -a
1
searchsploit "Linux Kernel"

Drives

Check what is mounted and unmounted

1
ls /dev 2>/dev/null | grep -i "sd"
1
cat /etc/fstab 2>/dev/null | grep -v "^#" | grep -Pv "\W*\#" 2>/dev/null

Check if credentials are in fstab

1
grep -E "(user|username|login|pass|password|pw|credentials)[=:]" /etc/fstab /etc/mtab 2>/dev/null

Processes

1
ps aux
1
ps -ef
1
top -n 1

Network

Hostname, hosts

1
cat /etc/hostname /etc/hosts /etc/resolv.conf

Interfaces

1
cat /etc/networks
1
(ifconfig || ip a)

Neighbours

1
(arp -e || arp -a)
1
(route || ip n)

IPtables rules

1
(timeout 1 iptables -L 2>/dev/null; cat /etc/iptables/* | grep -v "^#" | grep -Pv "\W*\#" 2>/dev/null)

Files used by network services

1
lsof -i

SUDO and SUID

Check commands you can execute with sudo

1
sudo -l

Find all SUID binaries

1
find / -perm -4000 2>/dev/null

Open Ports

1
(netstat -punta || ss --ntpu)
1
(netstat -punta || ss --ntpu) | grep "127.0"

Users

Info about me

1
id || (whoami && groups) 2>/dev/null

List all users

1
cat /etc/passwd | cut -d: -f1

List users with console

1
cat /etc/passwd | grep "sh$"

List superusers

1
awk -F: '($3 == "0") {print}' /etc/passwd

Currently logged users

1
w

Login history

1
last | tail

Last log of each user

1
lastlog

List all users and their groups

1
for i in $(cut -d":" -f1 /etc/passwd 2>/dev/null);do id $i;done 2>/dev/null | sort

Password Policy

1
grep "^PASS_MAX_DAYS\|^PASS_MIN_DAYS\|^PASS_WARN_AGE\|^ENCRYPT_METHOD" /etc/login.defs
This post is licensed under CC BY 4.0 by the author.