Skip to content
RCE Write-up Beginner

How to get a Reverse Shell from any Wordpress ?

An attacker who already has WordPress admin credentials can edit a theme's 404 template to insert a PHP reverse shell, then trigger it by visiting the theme's 404 page. This gives a remote shell on the server.

Mr Jokar Follow

Published on systemweakness.com

We are pentesting a wordpress site & eventually got admin credentials. After logging in, we get an admin dashboard from where we can edit themes or plugins.

Mr Jokar, on systemweakness.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the WordPress admin theme editor allows editing PHP template files, so anyone with admin access can run arbitrary PHP code on the server.

Impact

An attacker with admin credentials could gain a remote shell on the web server, but this requires already having admin access.

What the attacker needed

WordPress admin credentials; Theme editor enabled; Ability to edit theme files

The fix

The theme editor should be disabled or restricted so that admin users cannot edit PHP files directly, or file editing should be disallowed in production.

How it was found

  1. Log in to the WordPress admin dashboard.
  2. Go to Appearance > Editor > 404 Template.
  3. Replace the PHP code in the box with a PHP reverse shell and set the IP and port.
  4. Click Update File to save the changes.
  5. Start a netcat listener on the attacker machine.
  6. Visit the theme's 404.php page to trigger the shell.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A reverse shell is a way to make the victim server connect back to the attacker's computer, giving the attacker a command prompt on that server. The article assumes the attacker already has WordPress admin login, which normally lets you edit theme files. By replacing the 404 error page's code with a malicious script, the attacker gets a shell when that page is loaded.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Mr Jokar

View all

4 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.