With administrative access to WordPress, we can modify the PHP source code to execute system commands. To perform this attack, log in to WordPress with the administrator credentials, which should redirect us to the admin panel. Click on Appearance
on the side panel and select Theme Editor
. This page will allow us to edit the PHP source code directly. We should select an inactive theme in order to avoid corrupting the main theme.
We can see that the active theme is Transportex
so an unused theme such as Twenty Seventeen
should be chosen instead.
Choose a theme and click on Select
. Next, choose a non-critical file such as 404.php
to modify and add a web shell.
We modified the source code of the 404.php
page and added a new function called system()
.
The modified URL should look like this 404.php?cmd=id
.