ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 400 - PT0-002 discussion

Report
Export

After obtaining a reverse shell connection, a penetration tester runs the following command: www-data@server!2:sudo -1

User www-data may run the following commands on serverl2: (root) NOPASSWD: /usr/bin/vi

Which of the following is the fastest way to escalate privileges on this server?

A.
Editing the file /etc/passwd to add a new user with uid 0
Answers
A.
Editing the file /etc/passwd to add a new user with uid 0
B.
Creating a Bash script, saving it on the /tmp folder, and then running it
Answers
B.
Creating a Bash script, saving it on the /tmp folder, and then running it
C.
Executing the command sudo vi -c ' Jbash'
Answers
C.
Executing the command sudo vi -c ' Jbash'
D.
Editing the file/etc/sudoers to allow any command
Answers
D.
Editing the file/etc/sudoers to allow any command
Suggested answer: C

Explanation:

When the penetration tester has NOPASSWD privileges to run vi as root, the quickest way to escalate privileges is to leverage vi to execute a shell. The command sudo vi -c ':!bash' opens vi as the root user and immediately spawns a shell within vi. This method is fast and effective because vi (or vim) has the capability to run shell commands.

Executing sudo vi -c ':!bash' will open vi and then immediately run the :!bash command, which spawns a Bash shell with root privileges.

GTFOBins - vi

Example from penetration testing reports where vi is used to escalate privileges: Writeup.

asked 02/10/2024
Jay Fletcher
49 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first