ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 359 - PT0-002 discussion

Report
Export

During an engagement, a penetration tester was able to upload to a server a PHP file with the following content:

<? php system ($_POST['cmd']) ?>

Which of the following commands should the penetration tester run to successfully achieve RCE?

A.
Option A
Answers
A.
Option A
B.
Option B
Answers
B.
Option B
C.
Option C
Answers
C.
Option C
D.
Option D
Answers
D.
Option D
Suggested answer: A

Explanation:

The PHP file uploaded by the penetration tester allows for Remote Code Execution (RCE) by executing the command supplied through the cmd POST parameter. To exploit this, the penetration tester needs to send a POST request to the PHP file with the command they want to execute.

Among the given options, Option A is the most suitable for achieving RCE:

It uses Python's requests library to send a POST request, which is appropriate because the PHP script expects data through the POST method.

The data parameter in the requests.post function is correctly formatted as a dictionary, which is the expected format for sending form data in POST requests. It includes the key cmd with the value id, which is a common command used to display the current user ID and group ID.

The only minor issue with Option A is that it prints the entire response object, which includes not just the response content but also metadata like status code and headers. To print just the response content (which would include the output of the id command), appending .text to the requests.post call would be more precise, but this is a small detail and does not affect the execution of the command.

The other options have various issues:

Option B is close but has a syntax error in the data argument. It uses parentheses () instead of curly braces {} for the dictionary, and also lacks the .text at the end to print the response content.

Options C and D use the requests.get method, which is not suitable in this scenario because the PHP script is expecting data through the POST method, not the GET method. Additionally, Option D has a syntax error similar to Option B.


asked 02/10/2024
Jose Rodrigues
38 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first