Skip to content
leg3ndProjects & tools
01Home02Projects03Tools04Notes
GMT+8
O/ OSCP exploitation reference
Workspace controls Memory only · 0 steps
Visualize path ↗
Command values 0 filled

Temporary connection values clear on reload. Passwords, hashes and tickets remain placeholders. Check address-family syntax in the selected command.

Reference index ↗ Search all procedures & variants ↗
01Discovery02Enumeration03Initial access04Usable access05Local privilege06Active Directory07Internal access08Evidence & reporting

QUICK REFERENCE

Discovery›Services›Web mapping›Web exploitation›Credentials›Public exploits›Sessions & transfers›Linux escalation›Windows escalation›AD enumeration›AD identity attacks›Lateral movement›Pivoting & tunnels›Execution troubleshooting›Integration & evidence›
174 methods · 15 topicsFull reference on GitHub ↗Commands · scripts · next steps
Tools/OSCP/Local privilege/Linux escalation
← All linux escalation tasks

Hijack an unqualified helper through controlled PATH resolution

CommandsIf → thenExplanation & examples

Needs: A controlled directory precedes the real helper in the consumer's effective PATH; execution preserves useful privilege and a trigger exists

Shell commands

# Baseline
echo "$PATH" | tr ':' '\n'
echo "$PATH" | tr ':' '\n' | while IFS= read -r d; do
  [ -z "$d" ] && d=.
  [ -w "$d" ] && ls -ld "$d"
done
strings /PATH/TO/PRIVILEGED_BINARY | grep -E '(^|[^/])(cp|tar|service|sh|bash|cat)( |$)'

# If the privileged consumer resolves helper through a controllable PATH
printf '#!/bin/sh\n/usr/bin/id > /tmp/path-proof\n' > /WRITABLE/DIR/helper
chmod 700 /WRITABLE/DIR/helper
PATH=/WRITABLE/DIR:$PATH /PATH/TO/TRIGGER
cat /tmp/path-proof

Requires a relative command, the consumer's effective PATH, an earlier writable directory, trigger and retained privilege. Your interactive PATH alone is inconclusive.

Verify → Prove actual helper selection and effective identity through a controlled effect.

If it fails → secure_path, absolute paths, a changed working directory or privilege dropping can invalidate the route. More detail ↓

If → then

  • Root-owned cron, systemd or recurring process activity uses a controllable object → Control a script, binary or configuration consumed by a privileged job/service

    Needs: Effective object control, actual privileged consumer identity, correct path/environment and an available schedule/restart trigger

  • A nonstandard or dangerous privileged executable → Use a SUID or SGID program's exposed privileged primitive

    Needs: Effective SUID/SGID on the relevant mount; a program operation preserves and exposes useful privilege

  • A new Linux foothold or an identity/privilege change → Establish Linux state and choose an escalation candidate

    Needs: A working command channel and accurate effective identity, group, mount and process context

No useful finding → another task in this topic. Failed check → resolve the failure before ruling out the path.

Explanation & examples

Hijack an unqualified helper through controlled PATH resolution

USE WHEN
A privileged program/job invokes a helper without an absolute path
STARTING ACCESS
A verified Linux foothold with a known effective UID, groups and filesystem context
RESULT
Verified execution of the chosen helper under the consumer identity

Recognize the clue

Inspect a verified privileged helper/script for unqualified executable names and compare its actual PATH with writable directories.

printf '%s\n' "$PATH"
namei -l /PATH/TO/CANDIDATE_DIRECTORY
strings /PATH/TO/REVIEWED_BINARY
SYNTHETIC EXAMPLE OUTPUT
Helper invocation: backup_tool ARGUMENT
Consumer PATH: /CONTROLLED_DIRECTORY:/usr/bin:/bin

Means: An unqualified helper can resolve through the controlled earlier directory in the consumer's environment.

Confirm: Find the helper name in the privileged script or observed pspy command. Check that it is unqualified and identify the consumer's real PATH; a writable directory matters only if that consumer searches it first.

After validation
The consumer selects the controlled helper under the higher identity: use the verified resolution route.
Ruled out in this context
It invokes /usr/bin/backup_tool by absolute path or uses a protected PATH: reject this hijack.
Still inconclusive
A strings result alone does not prove an executed call or inherited PATH; inspect/observe the consumer.

Troubleshooting: secure_path, absolute paths, a changed working directory or privilege dropping can invalidate the route.

Additional prerequisite checks

printf '%s\n' "$PATH"
namei -l /PATH/TO/CANDIDATE_DIRECTORY

If the privileged consumer resolves helper through a controllable PATH:

Requires a relative command, the consumer's effective PATH, an earlier writable directory, trigger and retained privilege. Your interactive PATH alone is inconclusive.

Why it works

The caller's effective PATH determines helper lookup; changing the attacker's PATH has no effect when the privileged consumer sets its own environment or uses an absolute path.

Worked example · hypothetical

Observation: a privileged helper invokes a bare command name. Test: inspect the execution environment and create a controlled implementation in the earlier permitted directory. Illustrative output: the triggered program runs the controlled helper as root. Interpretation: resolution and privilege retention are confirmed.

New identity, privilege, host or route? Re-enumerate → All topic tasks →

Study guide ↗Full procedure ↗Cheatsheet ↗
HomeProjectsToolsNotes
Interactive toolsOSCP notes ↗Extended OSCP workspace ↗Attack-path visualizer ↗

© 2026 Armaan. Built with curiosity.

GitHub ↗GMT+8