Offensive methodology

Privilege escalation

Going from a limited foothold to full control of the machine, on Linux and Windows alike. The rule is the same everywhere: enumerate methodically before acting. Practise on authorised lab machines.

CPTSOffensiveAuthorised lab / HTB

Common approach

  1. LocateWho am I, what rights, which machine, which network?
  2. EnumerateProcesses, services, tasks, rights, files, software.
  3. Spot a vectorA misconfiguration or excessive right that can be abused.
  4. Escalate then stabiliseGain the rights, keep a record, document.
Enumerate firstScripts like linPEAS and winPEAS automate the collection, but understand what they report: a vector is recognised by hand. Never run an unknown tool on a machine that is not yours.

Linux: classic vectors

VectorIdea
sudo rightssudo -l: a binary runnable as root that can be abused (see GTFOBins).
SUID binaryAn executable that runs with its owner's rights, often root.
Cron jobA root script run periodically and writable, or an unprotected path.
CredentialsCleartext passwords in configuration files, history, backups.
CapabilitiesOverly broad Linux capabilities on a binary (e.g. cap_setuid).
Group or kernelMembership of the docker, lxd, disk groups; outdated kernel or service.
id ; sudo -l                       # who am I, what can I run as root
find / -perm -4000 2>/dev/null     # SUID binaries
getcap -r / 2>/dev/null            # capabilities
cat /etc/crontab ; ls -la /etc/cron.*
grep -ri password /etc /var/www 2>/dev/null

Windows: classic vectors

VectorIdea
Token privilegesSeImpersonatePrivilege, SeBackupPrivilege, SeDebugPrivilege that can be abused.
Misconfigured servicesUnquoted service path, writable binary or folder, overly broad rights.
Scheduled tasksA task running a writable script or binary.
Stored credentialsUnattend files, PowerShell history, Credential Manager, shares.
Always keep in mindVulnerable software installed, writable AutoRun key, AlwaysInstallElevated policy.
whoami /priv ; whoami /groups
systeminfo                         # version and patches
Get-Service ; schtasks /query /fo LIST /v
Get-ChildItem -Recurse env:        # variables, sometimes secrets

Defensive side

  • Apply least privilege, patch quickly, remove unnecessary sudo rights and SUID bits.
  • Monitor process creation (4688, Sysmon 1) and privilege assignment (4672).
  • See Windows logs and Sysmon and the Linux essentials sheet.