Faragiri

Learn Privilege escalation Ethical hacking

The sudo entry, the setuid list and the scheduled job, their Windows equivalents, and why a fully patched machine is escalated on a configuration from three years ago.

5Sections
4Min read
4Depth

Recommended Before This

0 / 2

Almost every escalation is a misconfiguration rather than an exploit, and three commands find most of them. sudo -l prints what the current account is permitted to run as somebody else. find / -perm -4000 -type f 2>/dev/null lists every program that runs as its owner. And crontab -l; ls -la /etc/cron.d/ shows scheduled work, some of which runs as root against a file the current account can write.

Dermot's engagement at a manufacturer in Warrington went from an unprivileged shell to full control in eleven minutes on the second of those three.

What each of the three finds

sudo -l is first because it is free and frequently decisive. An entry permitting one command as root is a foothold if that command can be made to do something else: an editor that can open a shell, an interpreter, or a program with a flag that runs another. The catalogue of which programs do that is public and searchable, which is why the entry rather than the program is the finding.

One machine

The rungs between a shell and the estate

Each rung is reached by a different class of mistake, and only the first is ever about a missing patch.

  1. 05The directoryOne administrative account, and every rung below it stops matteringthe estate
  2. 04A second machineThe same credential works elsewhere, which is what turns one machine into a findingreuse
  3. 03Root or SYSTEM on that machineA sudo entry, a setuid binary, a writable scheduled job, an unquoted service patha configuration
  4. 02Another user on the same machineA history file, a connection string, a script with a password in ita readable credential
  5. 01An unprivileged shellA web account or a service account, with no access to anything interestingwhere you start

The rungs are what an attacker holds, not how hard each step was. The step from the fourth to the fifth is usually the easiest one on the ladder, which is the argument for the controls that make reuse impossible.

Interactive Practice Lab

Edit and run this snippet directly in your browser (zero setup)

Regex
/\b(Role|Task|Constraint|Format):\s*([^\n]+)/gi
# sample: Role: Senior Python Reviewer
Task: Audit CSV parser edge cases
Constraint: Max 3 bullet points, zero fluff
Format: Markdown checklist

HTTP/TLS Request Lifecycle & Latency Waterfall Lab

Inspect every hop from DNS to Brotli stream and replay packet flow live.

The setuid list is second. Most entries on it are expected and one is not, and the one that is not is usually a program somebody installed and made setuid to fix a permissions problem in the fastest available way.

Scheduled work is third and it is the subtlest: a job running as root that executes a script in a directory the current account can write to is an escalation with a delay on it, and it looks like normal operation the entire time.

The Windows equivalents

The same three questions have different commands. whoami /priv prints the privileges held by the current token, and a handful of them are escalation on their own regardless of group membership. whoami /groups prints what was actually in the token at logon rather than what a directory says today.

Cross-platform equivalents

The same three escalation questions on Linux and Windows

Different commands ask the same underlying configuration questions, and patching closes none of them.

Linux checkUnix host
Windows equivalentToken and service host
Delegated privilegessudo -l permitted commandswhoami /priv token privileges
Assigned access contextSetuid binaries running as ownerwhoami /groups logon token membership
Writable execution pathsRoot cron jobs calling writable scriptsUnquoted service paths with spaces
Why patching misses itFile permissions and sudo rules stay intactService and token configuration stays intact

whoami /groups reflects what was in the token at logon rather than what the directory says today.

An unquoted service path is the classic third, where a service configured with spaces in its path and no quotes lets a file earlier in the path be executed instead, and wmic service get name,pathname or its PowerShell equivalent lists them. All three are configuration rather than vulnerability, which is why patching does not close them.

Credentials lying about

The other half of escalation is not privilege at all, it is a credential found in a readable place. History files, configuration files with a connection string, a script with a password in it, and files in a user's home directory that were readable by everybody all count.

Readable secrets

How stray credentials turn one host into the estate

Four ordinary file locations yield passwords that rarely stay confined to a single machine.

  1. Shell history files
  2. Config connection strings
  3. Scripts with passwords
  4. Readable home files
Credential reuseOne discovered secret tested elsewhere
  1. Another local user
  2. A second machine
  3. Whole-estate access

Report discovered passwords as a credential reuse risk rather than a single misconfigured file.

grep -rin 'password' /etc /opt /srv 2>/dev/null is crude and works far more often than it should. A credential found this way is frequently reused elsewhere, which is how a single machine becomes the whole estate, and the finding is worth writing up as reuse rather than as one file.

linPEAS, the catalogue, and reading the output

linPEAS and its Windows counterpart are free and run every check on this page and several hundred more, colouring the output by how interesting each result is. They replaced running the checks by hand and forgetting three of them, and the caution is that they are noisy: they touch a great many files and any monitoring worth having will see them.

Automation and lookup

How automated scripts, catalogues, and cleanup fit together

Enumeration scripts find candidates fast, lookup catalogues explain how binaries abuse rights, and notes ensure cleanup.

  • linPEAS and WinPEAS
  • GTFOBins and Windows list
  • Placement and removal log
  • linPEAS and WinPEASRun hundreds of checks without forgetting steps, though heavy file reads trigger monitoring
  • GTFOBins and Windows listLook up a permitted binary in seconds to see if it yields a shell, read, or write
  • Placement and removal logRecord where uploaded scripts live so every artefact is cleaned up after testing

Looking up one command from a sudo entry in GTFOBins often settles the finding in thirty seconds.

GTFOBins and its Windows equivalent are free catalogues of which ordinary programs can be turned into a shell, a file read or a file write, and they replaced knowing that by experience. Looking up the one command in a sudo entry is thirty seconds and settles the whole finding.

The honest note is that running an automated script on a client's machine writes files, and where it goes and how it is removed belongs in the notes.

Looking for an exploit first

The stall is looking for a kernel exploit. It is what the training material is about, it works in a lab, and on a maintained machine it usually does not: the kernel is patched, the exploit is unreliable, and running an unreliable kernel exploit against a production system is a decision with a real chance of an outage.

First move

Chasing a kernel exploit versus checking configuration

Maintained production hosts are usually patched against kernel bugs, yet carry old permission shortcuts.

Which path do you test first on a maintained host?
  • Kernel exploit first
    Unreliable and risks an outageLab staple that rarely helps in production
    • Patched kernels block public exploits
    • Failed attempts can crash the machine
  • Configuration checks first
    Reliable access, simple fixMatches Warrington's fully patched host
    • Non-standard setuid or sudo rules work even when patched
    • Remediation is often a single chmod change

Warrington went from unprivileged shell to full control in eleven minutes on a patched box via one three-year-old setuid utility.

Warrington's machine was fully patched. The setuid list had one entry that was not standard, a small utility somebody had made setuid three years earlier so that an operator could restart a service, and it took an argument that it passed to a shell. Eleven minutes, no exploit, and no version anywhere was out of date. The remediation was one chmod, which is the shape of most findings in this phase and the reason they are worth more than the exciting ones.

How the foothold this starts from was obtained is turning a weakness into access. What that access is worth once it is full control, and how it gets written down, is the deliverable, and writing it for the people who must fix it. And the model underneath every one of these three checks is who may read, write and run what.

Alongside this

Above this