Offensive Security Prep Pack for eJPT, OSCP, PNPT, OSWE, and OSEP Practice Questions: Linux Privilege Escalation Domain
Test your Offensive Security Prep Pack for eJPT, OSCP, PNPT, OSWE, and OSEP knowledge with 10 practice questions from the Linux Privilege Escalation domain. Includes detailed explanations and answers.
OSPP Practice Questions
Master the Linux Privilege Escalation domain with 10 exam-style scenarios and detailed explanations.
Test your knowledge in the Linux Privilege Escalation domain with these 10 practice questions. Each question is designed to help you prepare for the OSPP certification exam with explanations that reinforce the technique—not just the final choice.
Question 1
Sudo + Command Injection
You have a shell as user analyst on a hardened Ubuntu 22.04 server.
sudo -l returns:
Matching Defaults entries for analyst on sec-srv:
env_reset, secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
User analyst may run the following commands on sec-srv:
(root) NOPASSWD: /usr/bin/python3 /opt/tools/logrotate.py
The contents of /opt/tools/logrotate.py are:
#!/usr/bin/python3
import os
import sys
LOG_DIR = "/var/log/app/"
if len(sys.argv) != 2:
print("Usage: logrotate.py <logfile>")
sys.exit(1)
logfile = sys.argv[1]
cmd = "tar -czf /var/backups/" + logfile + ".tar.gz " + LOG_DIR + logfile
os.system(cmd)
You confirm that analyst can write to /var/log/app/ but not to
/var/backups/. Which of the following is the most reliable way to escalate to root?
Show Answer & Explanation
Correct Answer: B
The script concatenates untrusted input into a shell command and executes it with os.system().
Because the script is executed as root via sudo, shell metacharacters in logfile allow root-level command execution.
Reliable trigger pattern
sudo /usr/bin/python3 /opt/tools/logrotate.py 'test.log; /bin/bash -p'
Why the other options are weaker
- A:
tar -czfcreates archives; it does not overwrite arbitrary files like/etc/sudoersas a direct effect. - C:
secure_pathexcludes/var/log/app, so PATH hijacking is not reliable. - D: Archiving a sensitive file is data access, not deterministic privilege escalation to a root shell.
Question 2
Writable Script in Sudo Chain
On a hardened Ubuntu 22.04 server, you gain a shell as user report. While enumerating, you find:
report@filesrv:~$ sudo -l
Matching Defaults entries for report on filesrv:
env_reset, mail_badpass,
secure_path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
User report may run the following commands on filesrv:
(root) NOPASSWD: /usr/bin/find /mnt/reports -type f -name '*.csv' -exec /usr/local/bin/process_report.sh {} \;
You inspect /usr/local/bin/process_report.sh:
#!/bin/bash
/usr/bin/python3 /opt/reporting/process.py "$1"
Permissions:
-rwxr-xr-x 1 root root 102 Jan 5 11:21 /usr/local/bin/process_report.sh
-rwxrwxr-x 1 root report 4096 Jan 5 11:20 /opt/reporting/process.py
Which is the MOST straightforward way to escalate to a root shell using this configuration?
Show Answer & Explanation
Correct Answer: A
The sudo rule executes a root-owned wrapper script which calls /opt/reporting/process.py.
That Python script is group-writable by report, which means you can modify code that will run as root.
Question 3
Cron + Group-Writable Root ScriptYou find the following cron entry in /etc/crontab:
*/5 * * * * root /usr/local/bin/cleanup.sh
Inspecting the script:
$ ls -l /usr/local/bin/cleanup.sh
-rwxrwxr-x 1 root dev 512 Mar 1 2024 /usr/local/bin/cleanup.sh
$ cat /usr/local/bin/cleanup.sh
#!/bin/bash
LOG_DIR=/var/log/myapp
TMP_DIR=/tmp/myapp
rm -rf "$TMP_DIR"/*
find "$LOG_DIR" -type f -mtime +7 -delete
What is the most reliable way to escalate to root using this misconfiguration?
Show Answer & Explanation
Correct Answer: A
The cron job runs as root and executes a script that is group-writable by the dev group.
If you can edit the script contents, you can add a command that executes with root privileges at the next cron run.
Question 4
SUID Script + PATH Hijack ClaimYou find an unusual SUID entry:
/usr/local/bin/backup
Script contents:
#!/bin/bash
# Simple backup script
tar -czf /var/backups/home.tar.gz /home 2>/dev/null
echo "Backup completed"
Permissions:
-rwsr-xr-x 1 root root 1048 Jan 5 09:13 /usr/local/bin/backup
Your PATH:
/home/appuser/.local/bin:/home/appuser/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Which approach is the MOST reliable way to escalate privileges to root using this misconfiguration?
Show Answer & Explanation
Correct Answer: A (with an important caveat)
Many training scenarios assume PATH is honored and the SUID wrapper is exploitable via PATH hijacking.
In real systems, the kernel ignores SUID on scripts on most modern Linux distributions (for safety), and behavior can vary.
For an exam-style question set, option A is the intended vector: the script calls tar without an absolute path, and your PATH places a writable directory first.
Question 5
Sudo find -exec tar + Option InjectionYou have:
User www-data may run the following commands on web01:
(root) NOPASSWD: /usr/bin/find /var/backups -type f -mtime -1 -exec /bin/tar -czf /var/backups/daily.tar.gz {} +
You cannot modify /usr/bin/find or /bin/tar, and /var/backups is writable by www-data.
Which is the most reliable way to escalate to root?
Show Answer & Explanation
Correct Answer: C (and A is incomplete)
This is tar option-injection via filenames. You typically need both --checkpoint=1 and
--checkpoint-action=exec=... as separate arguments (filenames), which is why option C is the accurate description.
Question 6
Sudo find (Argument Escape Risk)Sudoers shows:
User www-data may run the following commands on web01:
(root) NOPASSWD: /usr/bin/find /tmp -name *
Which is the most reliable way to escalate to a root shell using this configuration?
Show Answer & Explanation
Correct Answer: B (depends on sudoers argument restrictions)
In many labs, this is intended as a GTFOBins-style escape: if sudo allows additional arguments beyond the displayed pattern,
appending -exec yields root command execution. If sudoers is configured to strictly match arguments (or uses NOEXEC),
this would fail; but for a practice set, B is the canonical expected answer.
Question 7
Wildcard Injection with TarSudoers shows:
User webapp may run the following commands on app01:
(root) NOPASSWD: /usr/bin/tar -czf *
Current directory is writable (/var/www/app/uploads). Which is MOST reliable?
Show Answer & Explanation
Correct Answer: C
This is classic wildcard/argument injection: the shell expands * into filenames you control.
Filenames beginning with -- are interpreted by GNU tar as options.
Question 8
Python subprocess + PATH ResolutionSudoers shows:
User report may run the following commands on srv01:
(root) NOPASSWD: /usr/bin/python3 /opt/tools/manage.py *
Script:
#!/usr/bin/python3
import sys
import subprocess
if len(sys.argv) < 2:
print("Usage: manage.py <command>")
sys.exit(1)
cmd = sys.argv[1]
if cmd == 'backup':
subprocess.call(['tar', 'czf', '/backups/app.tar.gz', '/var/www/app'])
elif cmd == 'status':
subprocess.call(['systemctl', 'status', 'apache2'])
else:
print('Unknown command')
/opt/tools/manage.py is not writable. report can write to /home/report/bin, and PATH starts with that directory.
What is the most straightforward way to escalate?
Show Answer & Explanation
Correct Answer: A (with environment caveat)
Because subprocess is invoked with a list (no shell), command injection (C) does not apply.
The intended vector is PATH-based command resolution for tar. In hardened sudo configs, PATH may be reset via secure_path;
for this practice scenario, the provided PATH detail indicates the exam-intended answer is A.
Question 9
Cron + Wildcard Injection with TarRoot cron runs:
* * * * * root /usr/local/bin/backup.sh
Script:
#!/bin/bash
SRC_DIR="/home/dev/app"
DEST="/backups/app-$(date +%F).tar.gz"
cd "$SRC_DIR" || exit 1
tar -czf "$DEST" *
You control /home/dev/app. Which approach is MOST reliable?
Show Answer & Explanation
Correct Answer: B
The script runs as root and uses * in a user-controlled directory, enabling wildcard/argument injection.
Tar checkpoint options are the canonical execution primitive in this pattern.
Question 10
Writable /usr/local/bin + Root CronYou find:
/etc/crontab:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * root backup.sh
/usr/local/bin is writable by appuser:
drwxrwxrwx 2 root root 4096 Jan 10 08:59 /usr/local/bin/
backup.sh:
#!/bin/sh
tar -czf /var/backups/home.tar.gz /home/*
What is the most straightforward way to escalate to root on this host?
Show Answer & Explanation
Correct Answer: A
If a root cron job executes a script from a directory you can write to, the simplest path is to replace the script with your payload and wait for cron to execute it as root.
Ready to Accelerate Your Offensive Security Prep?
Join learners who use FlashGenius to practice domain-by-domain, identify weak areas quickly, and build exam-day confidence.
- • Domain-focused practice questions for OSPP
- • Exam-style explanations that teach the underlying technique
- • Performance tracking to identify weak areas
- • Mobile-friendly practice for quick sessions
- • Fast iteration: new questions added regularly
About Offensive Security Prep Pack for eJPT, OSCP, PNPT, OSWE, and OSEP Certifications
Offensive Security Prep Pack for eJPT, OSCP, PNPT, OSWE, and OSEP validates practical skills in Linux privilege escalation and related exploitation workflows. Use these practice questions to validate reasoning patterns, not just memorized commands.
Offensive Security Prep Pack: EJPT, OSCP, PNPT, OSWE & OSEP
Train for multiple offensive security certifications in one place. Get domain-based drills, mixed-mode practice tests, and realistic red-team scenarios that mirror how EJPT, OSCP, PNPT, OSWE & OSEP actually feel on exam day.
- 10+ focused domains covering networking, web, AD, privilege escalation & more
- Exam-style MCQs, methodology drills, and chained attack paths
- Mixed practice sets to simulate end-to-end engagements
- Detailed explanations to turn every miss into a lesson
Ideal if you're targeting 2–3 OffSec-style certifications and want one unified prep pack.
Try the Offensive Security Prep Pack