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?
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.
Nguyet
5 months agoMarla
5 months agoMila
5 months agoNida
5 months agoCatalina
5 months agoSerina
5 months agoVeda
5 months agoMargart
5 months agoCiara
6 months agoNickie
6 months agoShelton
6 months agoErnie
6 months agoSylvie
7 months agoRenato
5 months agoJeffrey
5 months agoCristal
5 months agoJackie
7 months agoJustine
7 months agoBrittni
7 months agoTheron
7 months agoAhmed
7 months agoWillie
7 months agoAlaine
6 months agoLorean
6 months agoOwen
6 months agoSage
6 months agoRosita
6 months agoAnisha
6 months agoShantay
6 months agoAmber
7 months agoAlesia
7 months agoBernardo
7 months ago