WordPress - Abuse Theme Configuration on templates (WIP)

This works for version twenty-twenty-one or less of the base WordPress template. We can add malicious code to a page theme configuration, and this will allow us to get a reverse shell when activating the theme.

  • From the administrator dashboard go to Appearance>Edit File Editor. On the Select Theme to edit slider, select version twenty-twenty-one or the one we are going to abuse. Go to the 404 Template tab and we will see a code like this:

<?php
/**
 * The template for displaying 404 pages (not found)
 *
 * @link https://codex.wordpress.org/Creating_an_Error_404_Page
 *
 * @package WordPress
 * @subpackage Twenty_Twenty_One
 * @since Twenty Twenty-One 1.0
 */

// HERE GOES THE SCRIPT FOR REVERSE SHELL!!!!

get_header();
?>
...

  • Put the content of this script in the space shown above

Remember to specify the host machine IP and port on lines 6 and 7


  • Click on the Update File button, go to Appearance>Themes, and activate the theme that has been modified. Then create a netcat listener in our machine


  • Visit the site and search for a URL that does not exist. If we check our listener, we should have gained the Reverse Shell


Last updated