OSCP Sudo PrivEsc: NOPASSWD + GTFOBins Cheatsheet (Fast Lab Workflow)

sudo nopasswd privilege escalation

NOPASSWD: It’s a Contract, Not a Shell

In the high-stakes environment of an OSCP lab, NOPASSWD isn’t a free pass—it’s a permission slip with fine print. If you skim the sudo -l output, you’re not just missing a root shell; you’re burning the only resource you can’t brute-force: your remaining exam minutes—and that’s exactly how rabbit holes quietly steal your OSCP window.

“Match constraints first, choose the outcome second. Avoid the traps of fixed paths, wrapper scripts, and restricted Defaults like secure_path or noexec.”

Read the Contract

Confirm RunAs, exact binary paths, and allowed arguments before executing.

Classify Fast

Identify the payload: Is it a shell escape, a root file-write, or a privileged read?

Timebox Ruthlessly

If the standard GTFOBins escape fails due to env_reset, pivot or adapt immediately—use the same timebox discipline you’d apply to Hydra.

Prove, Then Move

Capture your three screenshots, document the constraint bypass, and clear the box—ideally using a repeatable OSCP proof screenshot routine.

Built for time-boxed takedowns and report-ready documentation.

Fast Answer: If sudo -l shows NOPASSWD, treat it as a “no-prompt execution ticket”—but only after you confirm what runs, as whom, and with which constraints. The fastest lab workflow is: run sudo -l → isolate NOPASSWD entries → identify the exact binary + allowed arguments → map to a GTFOBins-style escape (or a safe alternative) → verify a clean root shell or file-write primitive → capture proof. Speed comes from matching constraints, not trying 15 tricks.
Safety / Disclaimer (authorized labs only): Use this content only on systems you own or have explicit written permission to test (OSCP/PNPT-style labs, training ranges, approved practice boxes). Don’t reuse these techniques on real-world systems without authorization.
Eligibility checklist: Answer “yes/no” fast before you touch anything.
  • Yes — You have explicit permission (lab/exam box, written scope).
  • Yes — You can run sudo -l and you captured the output.
  • Yes — You can explain the escalation in plain English (what ran, as who, why it worked).
  • No — You’re unsure about scope or rules. Stop and verify.

Next step: If you answered “yes” to the top three, proceed to Section 2 and treat sudoers like a contract.

1) Who this is for / not for

For: “I have sudo -l output and need a fast decision”

This is for OSCP/PNPT-style lab learners who don’t want a long lecture—they want a repeatable checklist that survives stress. If you’ve ever stared at a “NOPASSWD” line and still managed to waste 45 minutes (hi, it’s me), you’re in the right place.

  • Time-boxed lab takedowns where speed + clean evidence matter
  • People who want a constraint-first workflow instead of “open GTFOBins and vibe it”
  • Anyone building a personal playbook for repeatable wins

Not for: “I’m learning Linux from zero”

If you can’t yet parse sudo -l details—RunAs rules, defaults, exact command specs—start with the fundamentals. Otherwise, you’ll misread constraints and blame the tool (when it was the contract).

What you must already have

  • A foothold shell in-scope (if you want a compact baseline, keep an OSCP initial access checklist nearby)
  • Basic comfort with id, whoami, cat, ls -la, and reading config files
  • A habit of logging commands and grabbing proof screenshots

Quick anecdote: I used to “save evidence for later.” Later became “after I lose the shell,” which is a very educational experience the first time and a very dumb experience the second time.

2) Read sudo -l like a contract (not a hint)

Treat sudo -l like a legally binding document written by someone who doesn’t want you to have fun. Because… it is. In training ranges, NOPASSWD is often the doorway, but the locks are in the details.

The four fields that change everything

  • RunAs: does it run as (root), (ALL), or a specific user?
  • NOPASSWD: is it truly passwordless for this entry, or only for some commands?
  • Command specification: exact path, allowed arguments, wildcards, or wrappers
  • Defaults: things like secure_path, env_reset, noexec, setenv, and friends
Takeaway: NOPASSWD isn’t “instant root”—it’s “you may run this exact thing without a prompt.”
  • Read RunAs first (who becomes powerful).
  • Read the exact command spec second (what is actually allowed).
  • Read Defaults third (what quietly blocks common escapes).

Apply in 60 seconds: Copy only the NOPASSWD command lines into a separate note labeled “candidates.”

sudo nopasswd privilege escalation

Curiosity gap: The “harmless” entry that’s usually not

Why do “safe” tools (editors, pagers, archivers) turn into escape hatches? Because many of them include a perfectly legitimate feature: “run a command,” “open a shell,” “load a plugin,” “write a file,” or “execute a hook.” In sudoers, legitimate features become leverage.

Quick triage: copy out only what matters

Under pressure, don’t keep the whole output in your head. Pull only the lines that look like:

  • NOPASSWD: entries
  • Anything that runs as (root) or a privileged user
  • Anything with wildcards, user-controlled file input, or wrapper scripts

Another small lived-experience note: the number of times I’ve been “sure” a binary was allowed, only to realize the allowed path was different… enough times that I now copy/paste the full path like it’s sacred text.

Show me the nerdy details

Sudoers parsing can include defaults that behave differently per host/user/command, and command specs can be exact-path locked. That’s why “sudo somebinary” might fail while “sudo /usr/bin/somebinary” works (or vice versa). When in doubt, re-check the exact line shown by sudo -l and test only what’s explicitly permitted.

Decision card: When a shell vs when a file-write
  • Go for a root shell when the allowed binary naturally spawns commands or interprets code.
  • Go for root file-write when arguments are restricted but you can write to privileged paths (cron/config/keys).
  • Go for privileged read when “almost-root” data unlocks a cleaner path (keys, tokens, configs).

Next step: Choose your win condition for this box: shell, write, or read—then match candidates to that.

3) Fast workflow: NOPASSWD → GTFOBins match in under 2 minutes

Here’s the compact loop you want to internalize. Not “memorize 200 escapes.” Just this loop.

Step 1: Is it a known “escape class” binary?

  • Editors / pagers: built-in command modes, subshells, external commands
  • Archivers / compressors: hooks, file write paths, extraction behaviors
  • Interpreters / runtimes: “run code” is literally the feature
  • File transfer / writers: can write arbitrary paths or overwrite configs
  • System helpers: plugin/module loading, service managers, task runners

Step 2: Confirm constraints before you celebrate

Ask three questions:

  • Is the binary path fixed (e.g., /usr/bin/...)?
  • Are arguments locked (specific flags/paths only)?
  • Is it a wrapper script (meaning the “real work” happens elsewhere)?

Step 3: Choose your escalation goal

If you can’t get a clean shell quickly, don’t panic. In labs, a root file write primitive is often faster, quieter, and easier to explain than a fragile shell escape.

Let’s be honest…

Most sudo privesc “fails” aren’t failures. They’re just misread sudoers constraints—the wrong binary path, restricted args, or a default you didn’t notice.

Anecdote: I once spent 30 minutes “debugging” a supposed escape, only to realize the entry allowed running the binary as a non-root service user. The command worked perfectly. My reading didn’t.

Mini timebox calculator: Stop brute-trying candidates.

Next step: Commit to a budget. When it’s gone, pivot to Section 5 instead of spiraling.

4) The GTFOBins shortlist OSCP learners actually use

GTFOBins is not a magic spell—it’s a menu. Your job is to order what the kitchen is actually allowed to cook. Instead of dumping a massive list, let’s keep this focused: the “classes” of binaries that show up often and convert quickly.

Tier A: “Usually instant” NOPASSWD hits

These are binaries where “execute commands” is a normal feature. If sudoers allows them with flexible arguments, you often get a clean win. If sudoers locks arguments hard, they can drop into Tier B or Tier C.

  • Interpreters/runtimes and “run code” hosts
  • Tools explicitly designed to launch processes or run tasks
  • Utilities with built-in command execution modes

Tier B: “Works if you spot the right mode”

These tools aren’t “shell tools”… until they are. Many have escape sequences, command modes, or hooks that become powerful under sudo.

  • Pagers with command escape features
  • Editors that can run external commands
  • Archivers that can trigger helper programs or manipulate files

Tier C: “Quietly powerful” file-write primitives

If you can’t pop a shell, don’t get dramatic. File-write primitives are often the fastest path to durable access in labs (again: scope and rules first).

  • Anything that can overwrite files as root
  • Anything that can append to root-owned configs
  • Anything that can write into cron/service config directories

Curiosity gap: Why your favorite trick might not work here

Three common reasons:

  • Restricted args: you’re allowed /usr/bin/tool /safe/path and nothing else.
  • Wrapper scripts: sudo calls a script that sanitizes input or calls other binaries.
  • Defaults: environment cleanup, path controls, or exec restrictions change behavior (and if you’ve ever been bitten by shell state, you’ll recognize the vibe in bash/zsh history + environment leakage quirks).

Anecdote: I once “had” a classic pager escape—except the system defaulted to a build without the feature I expected. That wasn’t the machine being tricky. That was me assuming.

Takeaway: Don’t memorize tricks—memorize categories and constraints.
  • Tier A converts when arguments are flexible.
  • Tier B converts when you recognize “modes.”
  • Tier C converts when shells are blocked but writes are possible.

Apply in 60 seconds: Label each candidate as A/B/C before you try anything.

sudo nopasswd privilege escalation

5) When GTFOBins doesn’t pop: the fallback decision tree

When the obvious path fails, don’t widen the search into chaos. Narrow it into questions. This is the part that separates “I clicked around” from “I operated.”

If arguments are restricted

  • Look for wildcards that allow multiple targets.
  • Check whether you can influence an input file, config file, or path that the allowed command reads.
  • Ask if the allowed argument is a directory you can write into.

If it’s a wrapper script

Read it. Then ask:

  • Does it call other binaries with relative paths?
  • Does it trust environment variables or user-controlled input?
  • Does it write files somewhere you can influence?

If it’s “safe” but runs as root

“Safe” tools still have power when they run as root. Convert “safe” into:

  • Write: privileged config edits, service overrides, scheduled tasks (where allowed)
  • Read: secrets, keys, tokens, and configs that unlock a cleaner escalation path

Curiosity gap: The fastest “non-shell” win

Sometimes the fastest win is not a root shell—it’s a root-owned file write you can prove, explain, and (if needed) undo. In reporting terms, it’s also easier to document than a shaky interactive escape.

Anecdote: the first time I chose “root read” over “root shell,” I felt like I was settling. Then the read exposed a config secret that gave me a clean, explainable escalation in under 10 minutes. Pride is expensive. Evidence is cheaper.

Show me the nerdy details

Many “fails” come from treating command specs like suggestions. If sudoers allows a command with fixed args, your only leverage might be in files those args reference (inputs, configs, directories). Wrapper scripts often reveal the real attack surface: calls to other binaries, file permissions, or unsafe string handling. Reading the wrapper can be higher-yield than trying more one-liners.

6) Evidence-first lab workflow (report-ready, not vibes)

In OSCP/PNPT-style training, you’re not just solving the box—you’re building a story that will still make sense at 2 a.m. when you’re tired and your notes are ugly. Evidence-first means you don’t “remember what happened.” You can show what happened.

Minimal command log (what to capture)

  • sudo -l output (clean and complete)
  • The exact escalation command(s) you ran (copy/paste into notes—ideally inside a reusable Obsidian OSCP host template)
  • Proof of effective privileges (e.g., effective UID or privileged file access)
  • Any changes you made (what, where, and how to revert)
Takeaway: The best privesc is the one you can explain in three screenshots.
  • One shot: sudo -l showing the entry.
  • One shot: the exact command you executed.
  • One shot: proof of elevated capability.

Apply in 60 seconds: Screenshot sudo -l immediately—before you “try one quick thing.” If you want to keep your proof clean and consistent, pair it with a ShareX screenshot naming pattern.

Keep it exam-safe

  • Prefer minimal, reversible actions.
  • Avoid destructive changes unless the lab objective requires it.
  • Keep your steps tight: fewer moving parts means fewer surprises (a small OSCP VM lockdown checklist helps prevent self-inflicted chaos).

Anecdote: I used to chase “perfect” proofs. Now I chase “clear” proofs. Perfect proofs are how you end up with 17 tabs open and no screenshot of the one line that mattered.

7) Common mistakes (the OSCP time-sinks)

Mistake 1: Treating NOPASSWD as “guaranteed root”

NOPASSWD just means no password prompt. It says nothing about whether you can control args, invoke an escape mode, or reach root at all.

Mistake 2: Skipping RunAs + Defaults

If you don’t check who the command runs as and what defaults apply, you’ll do the right technique on the wrong conditions. That’s not bad luck—it’s mis-scoping.

Mistake 3: Forcing a shell when a file-write is easier

Shells feel satisfying. File-write primitives are often more reliable and easier to document. Choose the win that fits the contract.

Mistake 4: Not validating the exact binary path

/usr/bin/tool is not the same as tool in your PATH. Sudoers often pins the path for a reason. Respect it.

Mistake 5: Over-trying instead of pivoting

Give each candidate a strict budget. When the budget is gone, pivot. The box doesn’t reward persistence; it rewards correct reading and smart branching.

Anecdote: I once spent “just five more minutes” on a stubborn entry—four times in a row. That’s 20 minutes I could’ve used to read the wrapper script that literally explained the right path.

8) Don’t do this: two ways people burn their whole privesc window

Don’t “spray” GTFOBins techniques blindly

Clicking through GTFOBins like it’s a slot machine is a classic time sink. It feels productive because you’re doing things. But the fastest operators do fewer things, more deliberately.

  • Match technique to constraints.
  • Stop after a small number of attempts.
  • Switch strategy based on what the contract allows.

Don’t ignore “almost-root” wins

A privileged read of configs, keys, tokens, or service settings can unlock a cleaner path than forcing an interactive escape. In real engagements, this is often the safer story too: least privilege impact, maximum clarity.

Here’s what no one tells you…

You don’t need the fanciest privesc. You need the privesc you can repeat when your hands are shaky and the clock is loud—and that starts with stable basics like a reliable TTY upgrade checklist when your shell is brittle.

Short Story: The night I stopped “trying harder” (120–180 words) …

I remember a lab box where sudo -l showed a single NOPASSWD entry that looked like a gift. I did what I used to do: I tried every clever trick I’d ever bookmarked. Ten minutes passed. Then twenty. The entry kept “working,” but never the way I wanted. That’s when I finally did the boring thing: I re-read the line like it was the only sentence on the page.

The arguments were locked. The path was fixed. The tool read a file from a directory I could write to. So I stopped chasing a shell and shifted my goal to a file-write primitive I could prove. It wasn’t flashy. It was clean. Three screenshots later, I had a defensible escalation narrative—and my brain felt quiet for the first time that night.

Infographic: NOPASSWD → Proof (fast operator loop)
1) Capture

Run sudo -l and screenshot it before “one quick attempt.”

2) Contract check

RunAs + exact path + allowed args + defaults.

3) Classify

Tier A shell / Tier B mode / Tier C write-read.

4) Timebox

Small attempt budget per candidate, then pivot (the same mindset as fast enumeration routines for any VM—tight loops, not vibes).

5) Verify

Prove effective privilege: UID or privileged file access.

6) Document

Three screenshots + command log = report-ready (pair with Kali lab logging habits that survive stress).

FAQ

What does NOPASSWD in sudoers actually mean?

It means the specified sudo command can be run without entering a password. It does not mean you can run any command, and it does not guarantee root. Always read who it runs as (RunAs) and what’s permitted (exact path and arguments).

If sudo -l shows a command, does it always run as root?

Not always. Some entries run as a specific non-root user or allow multiple RunAs targets. Check the line for the RunAs context (often shown as (root) or another user) and confirm by verifying effective privileges after execution.

How do I tell if sudo restrictions are blocking “standard” escapes?

First, re-check whether arguments are restricted and whether the allowed entry is a wrapper script. Then look for sudo defaults that constrain environment or execution. In practice, the fastest indicator is: the usual escape relies on flexibility you don’t have (args, environment, or interactive features).

What if the allowed command requires specific arguments?

Treat that as the true puzzle. Your leverage often shifts from “launch a shell” to “influence the allowed inputs.” Ask what files, directories, or configs those arguments reference, and whether you can write to or control them within scope.

Is using GTFOBins allowed in OSCP/PNPT-style labs and exams?

In most training contexts, GTFOBins is used as a reference for understanding binary behaviors, but rules differ by platform and assessment. The safe approach: follow the written rules for your environment, keep actions minimal, and document what you did clearly. When in doubt, prefer explaining the mechanism over copying aggressive one-liners.

What’s faster: going for a root shell or writing a root-owned file?

It depends on constraints. If the allowed binary naturally runs commands and arguments are flexible, a shell can be fastest. If arguments are locked or interactive behavior is unreliable, a file-write primitive can be faster, cleaner, and easier to prove with screenshots.

Why does sudo behave differently than running the same binary normally?

Because sudo changes execution context: user identity, environment variables, and sometimes path behavior. That’s why “works normally” and “works under sudo” can diverge. Always validate under the exact sudo invocation shown in sudo -l.

What should I screenshot for a sudo-based privesc finding in a report?

Capture: (1) the sudo -l line showing the NOPASSWD entry, (2) the exact command you ran, and (3) proof of elevated capability (effective UID or privileged file access). If you changed anything, include a short note describing what and how to revert it.

sudo nopasswd privilege escalation

10) Next step: one concrete action

Build your personal “sudo NOPASSWD shortlist”

This is the highest-leverage habit you can build: a one-page note you can glance at under stress. Keep it small and sharp (if you want it to slot into your workflow, drop it into an Obsidian OSCP enumeration template so it shows up at the right moment).

  • (a) Your top candidate binary categories (Tier A/B/C)
  • (b) What constraint usually kills each one (restricted args, wrapper, missing mode)
  • (c) Your preferred proof shots (three screenshots, consistent order)
Takeaway: Your goal is not “more tricks”—it’s “fewer decisions.”
  • Classify candidates quickly.
  • Timebox attempts ruthlessly.
  • Document like you’ll forget everything tomorrow (because you will).

Apply in 60 seconds: On your next box, force yourself to label every NOPASSWD entry A/B/C before any attempt.

Anecdote: the first time you do this, it feels slow. The third time, it’s the fastest thing you do all day.

Conclusion

Let’s close the loop from the hook: that “easy NOPASSWD” line is only easy when you stop treating it like a hint and start treating it like a contract. The win is not a clever one-liner—it’s a calm workflow: capture, parse, classify, timebox, verify, document. If you do that, you’ll stop donating your best minutes to dead ends—especially when you anchor it inside a broader privilege escalation patterns playbook for OSCP.

Your next 15-minute move: pick one recent lab box (or spin up a practice VM), run sudo -l, and force the loop—candidate list → A/B/C → timebox → proof screenshots. Then write a three-sentence explanation of why it worked. If you can explain it cleanly, you can repeat it cleanly.

Last reviewed: 2026-01-23