Exam PT0-002 All QuestionsBrowse all questions from this exam
Question 185

A penetration tester is able to use a command injection vulnerability in a web application to get a reverse shell on a system After running a few commands, the tester runs the following:

python -c 'import pty; pty.spawn("/bin/bash")'

Which of the following actions Is the penetration tester performing?

    Correct Answer: B

    The command 'python -c 'import pty; pty.spawn("/bin/bash")'' is used to spawn a pseudo-terminal (PTY) and execute the /bin/bash shell within it. This enhances the basic reverse shell by providing a more interactive and functional environment, which allows the penetration tester to execute commands as if they were directly logged into the system. This process is known as upgrading the shell. It is not related to privilege escalation, writing a script for persistence, or building a bind shell.

Discussion
RRabbitOption: B

B. Upgrading the shell. The command the penetration tester is running is used to upgrade the shell from a basic shell to a more advanced shell with better capabilities, such as running multiple commands and using command line arguments. This is known as upgrading the shell. Privilege escalation is the process of obtaining higher privileges on a system, while writing a script for persistence is writing code that will automatically run whenever the system is started or rebooted. Building a bind shell is creating a shell that can be accessed remotely over a network.

nickwen007Option: B

This command is used to spawn a pseudo-terminal (known as a PTY) and execute the /bin/bash shell within it. This provides a more interactive environment than a standard terminal session and allows for more complex tasks to be executed. When this command is run, the bash prompt will appear and the user will have access to all of the features of this shell. It is commonly used in penetration testing, allowing the tester to gain access to a system and explore it freely.

[Removed]

B 100% correct

cy_analystOption: B

The code python -c 'import pty; pty.spawn("/bin/bash")' is a Python command that is being run in the command shell of the compromised system. The command is executing a Python script in-line (using the -c flag) that does two things: Imports the pty module: This module provides functionality for spawning a new pseudo-terminal (pty) on the current terminal session. This allows the tester to interact with the shell in a more efficient and interactive way. Spawns a new shell with elevated privileges: The pty.spawn("/bin/bash") method spawns a new bash shell (/bin/bash) with elevated privileges. This is because the current shell that the tester has access to may not have all the necessary permissions to perform certain actions, such as accessing sensitive files or executing certain system commands. By spawning a new shell with elevated privileges, the tester is able to bypass these restrictions and perform a wider range of actions.

[Removed]

Please share your answer about the Questions Q- 20 Q- 18 Q-163

Etc_Shadow28000Option: B

B. Upgrading the shell Explanation: • The command python -c 'import pty; pty.spawn("/bin/bash")' is used to spawn an interactive TTY shell. When a reverse shell is obtained, it often operates in a non-interactive mode, which can limit the ability to use certain commands and interact with the system effectively. By running this Python command, the penetration tester is upgrading the reverse shell to a more fully functional, interactive shell.

[Removed]Option: B

B is correct