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