WordPress Penetration Testing using WPScan & Metasploit

In our previous article we had discussed “WordPress Penetration Testing Lab Setup in Ubuntu” and today you will learn WordPress penetration testing using WPScan and Metasploit

Attacker: Kali Linux

Target: WordPress 

WPScan is a black box vulnerability scanner for WordPress written in PHP mainly focus on different types of vulnerability in WordPress, WordPress themes, and plugins. Well, WPScan tool is already installed by default in Kali Linux, SamuraiWTF, Pentoo, BlackArch, and BackBox Linux. WPScanuses the database of all the available plugins and themes (approximately 18000 plugins and 2600 themes) during testing against the target to find outdated versions and vulnerabilities.

Things WPScan can do for you are:

  • Detect a version of currently installed WordPress.
  • Can detect sensitive files like readme, robots.txt, database replacing files, etc.
  • Detect enabled features on currently installed WordPress.
  • Enumerate theme version and name.
  • Detect installed plugins and can tell you if it is outdated or not.
  • Enumerate user names also.

Let’s start

Go to your Kali Linux terminal and type following to download wpscan from git hub.

Now simply type in terminal to run the script:

Using default Option we will go to penetrate our WordPress website:

Scanning WordPress version of the target website

Wpscan is a great tool to scan WordPress websites. Now we will try to do some basic scan, we will use enumerate tools to find information about themes, plugins, usernames etc.

Now type the following command to scan WordPress and its server:

Instead of type the name of a website you want to scan. 

Here it found server: Apache/2.4.7, PHP /5.5.9 WordPress version 4.8.1, using this information an attacker can check for its exploit in Google. Moreover, it also found that the upload directory has directory listing enable which means anyone can browse the directory /wp-content/uploads to view the uploaded files and contents.

Enumerating WordPress Theme

A theme controls the general look and feel of the website including things like page layout, widget locations, and default font and color choices. WordPress.com has a wide range of themes for its user and each theme has an about page that includes features and instructions.

To scan the installed theme of WordPress website type following command:

Enumerating WordPress vulnerable Theme

To scan the installed vulnerable theme of WordPress website type following command:

From scanning result, we didn’t find any vulnerable theme which means there is no vulnerable theme which can be exploited.

Enumerating WordPress Plugins

Plugins are a small piece of code of a program which can be added to a WordPress website to extend its functionality.

To find installed plugins on our target’s WordPress website, type in terminal:

Finally, after a few seconds, you will get the result of the installed plug-in. You can see that in my scan result askismet v3.3.3, pixabay-images v2.14, wptouch v3.4.3 such types of the installed plug-in are detected. As well as it also describes the last update and the latest version of that plug-in.

Enumerating WordPress vulnerable Plugins

Now type the following command to scan vulnerable plug-in of any WordPress website:

After a few seconds, you will get the result of the installed vulnerable plug-in of the website. From the given image you can observe that the red color indicates vulnerable plug-ins as well as a link of exploits CVE.

Exploit vulnerable plug-in using Metasploit

This module exploits an arbitrary PHP code upload in the WordPress Reflex Gallery version 3.1.3. The vulnerability allows for arbitrary file upload and remote code execution.

Open the terminal load Metasploit framework and execute the following command:

Awesome!! From the given image you can observe the meterpreter session of victim’s web server.

Enumerating WordPress Usernames

In order to enumerate usernames of WordPress website execute the following command:

After some time it will dump the table of usernames. In this scan I had found three users with their Id as given below:

Enumerate ALL with a single command

Whatever we have scanned above can be easily enumerated at once by executing given below command:

–e: at: enumerate all themes of targeted website

–e: ap: enumerate all plugins of targeted website

–e: u: enumerate all usernames of targeted website

Brute force attack using Wpscan

With help of username which we had enumerated above, we can create a wordlist of password for user admin and can try brute force login attack using given below command.

It will start matching the valid combination of username and password for login and then dump the result, from the given image you can see it found login credential of the targeted website as admin: password.

Generate PHP backdoor in WordPress

You can use above credential for login into admin panel where we can upload any theme, taking advantage of admin right we will try to upload the malicious script to achieve reverse connection from victim’s system.

Once you are inside admin panel click on Appearance from the dashboard and then select option editor.

Now select template 404.php given on the right side of the frame; after that, you will found some php code in the middle frame for 404 temperate. Erase the entire php code so that you can add malicious php code for generating backdoor inside website as a new theme.

Now use msfvenom to generate malicious PHP script and type following command.

From the screenshot you can read the generated PHP script, at this instant we need to copy the text from *<?php……….die();  further, we will paste it inside WordPress template as a new theme.

Now past above copied PHP text *<?php……….die();   here as new theme under selected  404.php template.

On the other hand Load Metasploit framework and start multi/handler

When you will execute your uploaded theme 404.php in the browser you will receive reverse connection at multi/handler and get a meterpreter session of victim’s system.

Here form screenshot you can see through meterpreter we have access victim’s shell.

In this way using WPSCAN and METASPLOIT admin can check the strength and weakness of WordPress website.

Author: Akshay Bharadwaj is a passionate Hacker, Information Security Enthusiast and Researcher | Sketch Artist |Technical writer. Contact Here

5 Comments WordPress Penetration Testing using WPScan & Metasploit

Leave a Reply

Your email address will not be published. Required fields are marked *