One day, your website began showing unusual signs: organic traffic dropped suddenly, customers reported being redirected to unfamiliar gambling websites, or a few unfamiliar administrator accounts appeared in the admin settings page. If you are facing these issues, it is clear that your website has been infected with malware. Quickly finding a way handle wordpress hacked is critically important for protecting customer data, maintaining brand reputation, and avoiding being blacklisted by Google.
Recently, the technical team at DPS.MEDIA successfully helped restore a corporate website system heavily infected with malware (storage path on the server at `/home/yourdomain.com/public_html/`). Technical analysis from the Wordfence CLI log file shows that this website contains 16,854 files, with a total scanned size of 281.2 MiB. Wordfence took 851 seconds (approximately 14 minutes) to scan and detected exactly 3 suspicious files (files suspected of containing malicious code). This article will share the details of this real case study, provide the specific names of the malicious plugins, the hacker's fake admin accounts, and an A-to-Z cleanup process so you can check your own system.
Step 1: Scan for Malware Using Wordfence CLI
Wordfence CLI is an extremely powerful malware scanning tool that runs on your server's command line (VPS/Server), processing much faster than regular plugins. First, you need to connect your free Wordfence license key using the command:
wordfence configure
Then, scan the folder containing the website's source code and export the results to a fixed log file for easy analysis:
wordfence malware-scan --output-path=/home/yourdomain.com/public_html/wordfence-scan-log.log /home/yourdomain.com/public_html/
Extremely important note about the number of skipped files (Skipped Files)
During the scan, the system reports up to 7,903 files skipped. The reason is that Wordfence CLI, by default, only scans source code files (such as PHP). However, hackers today are very sophisticated; they often hide webshells or insert PHP code into static files (such as files with the `.jpg`, `.png`, `.css`, or `.js` extensions).
Therefore, to ensure a thorough cleanup, you must perform a full deep scan by adding the flag --include-all-files:
wordfence malware-scan --include-all-files --output-path=/home/yourdomain.com/public_html/wordfence-scan-full-\\$(date +%Y%m%d-%H%M%S).log /home/yourdomain.com/public_html/
In addition, if the log reports timeout (the system hit 1 timeout), check the timed-out file right away. Files with unusually large sizes or that take too long to process are usually files containing millions of lines of obfuscated code from hackers.

Step 2: Read the log file and precisely identify the malware name
Because Wordfence only reports the number of suspicious files in the final summary, you need to filter the file paths of these 3 files using a filter command grep:
grep -i "suspicious\|malicious\|match" /home/yourdomain.com/public_html/wordfence-scan-log.log
Or you can export the scan results directly to CSV format for easier visual analysis:
wordfence malware-scan --output-format=csv --output-path=/home/yourdomain.com/public_html/wordfence-scan-results.csv /home/yourdomain.com/public_html/
Based on the actual log, we detected 3 specific malicious files, including:
- wp-content-filter/wp-content-filter.php: The fake plugin contains malicious code that creates an admin account and prints an "OK" confirmation line. This is a classic admin-creating backdoor, usually triggered remotely by hackers through a hidden HTTP parameter.
- wordpress-cache-optimizer/wordpress-cache-optimizer.php: A fake plugin disguised as a caching tool. This file contains code that automatically inserts a hidden administrator account with hardcoded login credentials.
- wp-fixplugin.php: Located in the directory
wp-content/mu-plugins/(Must-Use Plugins, automatically loaded without appearing in the regular plugin list). This file automatically inserts a malicious script tag in the form<script src="...">into the tag<head>of the website to redirect users to betting sites. The subtle part is that this file uses the functionis_user_logged_in()to hide this malicious script from logged-in admins to avoid being detected by administrators when browsing their own website.
Once you know exactly what they are, use the following command to completely delete these malicious folders and files:
rm -rf /home/yourdomain.com/public_html/wp-content/plugins/wp-content-filter
rm -rf /home/yourdomain.com/public_html/wp-content/plugins/wordpress-cache-optimizer
rm /home/yourdomain.com/public_html/wp-content/mu-plugins/wp-fixplugin.php
Step 3: Review and Delete Fake Admin Accounts
List all accounts with the highest privileges on the website using WP-CLI:
wp user list --role=administrator --allow-root --path=/home/yourdomain.com/public_html
Cross-checking against the source code and account creation times, we detected 2 fake administrator accounts created by the hacker:
- wphiddenbot (ID 4): Created at 2026-07-21 03:54:55, display name "Cache Worker", email
wphiddenbot@gmail.com. This is an account created by a fake pluginwordpress-cache-optimizer.php. - wpenginebot (ID 3): Created at 2026-07-20 21:41:33 (about 6 hours before wphiddenbot). This is precisely the account created by the backdoor
wp-content-filter.phpcreated. The creation time coincides with the moment the malware was deployed to the server.
Delete these 2 fake accounts and reassign their posts to the real admin account (ID 1):
wp user delete 3 --reassign=1 --allow-root --path=/home/yourdomain.com/public_html
wp user delete 4 --reassign=1 --allow-root --path=/home/yourdomain.com/public_html
Step 4: Clean Up Malicious Configurations Deeply Hidden in the Database
Malicious code does not only reside in files but also stores harmful configurations in the database (table wp_options). In many cases, administrators delete PHP files but do not clean up the database, so the website continues to be hacked again.
To search for these malicious options in the database, use WP-CLI to run the following check commands (note: change the actual domain path to yourdomain.com):
wp option list --search="*fixplugin*" --allow-root --path=/home/yourdomain.com/public_html
wp option list --search="*cache_optimizer*" --allow-root --path=/home/yourdomain.com/public_html
wp option list --search="*content_filter*" --allow-root --path=/home/yourdomain.com/public_html
The terminal output will help you immediately identify any abnormal configurations:
+-------------------------+--------------------------------------------------+
| option_name | option_value |
+-------------------------+--------------------------------------------------+
| wp_fixplugin_script_url | https://mamglaqwek.com/googletagmanager.js?v=2.0 |
| wp_fixplugin_script_ver | 1785515873 |
+-------------------------+--------------------------------------------------+
+-------------+--------------+
| option_name | option_value |
+-------------+--------------+
+-------------+--------------+
| option_name | option_value |
+-------------+--------------+
+-------------+--------------+
| option_name | option_value |
+-------------+--------------+
Specifically, mu-plugin wp-fixplugin.php call function get_option() from the configuration constants. During actual testing, we found two malicious options added to the table wp_options:
- wp_fixplugin_script_url: Save the malicious script link value
https://mamglaqwek.com/googletagmanager.js?v=2.0. This link impersonates Google Tag Manager to blend in with your legitimate tracking code (for exampleGTM-WPTSRZZJ). - wp_fixplugin_script_ver: Save timestamp
1785511188(or other timestamp variants such as1785515873).
These two options have option_id very large (up to 100,136), indicating they were recently injected during the attack chain on 20-21/07. Proceed to delete these options entirely using WP-CLI:
wp option delete wp_fixplugin_script_url --allow-root --path=/home/yourdomain.com/public_html
wp option delete wp_fixplugin_script_ver --allow-root --path=/home/yourdomain.com/public_html
Trace and Search Deeper:
Hackers often have backup mechanisms, inserting malicious links mamglaqwek.com in many other places, such as post content, widgets or themes. You need to scan the entire system to search for traces of this domain:
# Quét tìm trong toàn bộ file của wp-content
grep -rl "mamglaqwek.com" /home/yourdomain.com/public_html/ 2>/dev/null
# Quét tìm trong toàn bộ các bảng dữ liệu database
wp db search "mamglaqwek.com" --allow-root --path=/home/yourdomain.com/public_html
Step 5: Check Configuration Files and Patch Critical Vulnerabilities
Read the file carefully .htaccess and wp-config.php:
cat /home/yourdomain.com/public_html/.htaccess
cat /home/yourdomain.com/public_html/wp-config.php | grep -v "^\s*//" | grep -v "^\s*\$"
Carefully check whether there are any unusual redirect rules in the `.htaccess` file. At the same time, during a review of the `wp-config.php` file, we identified 2 serious security vulnerabilities that require immediate action:
1. Security keys (Salts keys) have not been set up
The keys used to encrypt login cookies are still set to WordPress's default values:
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
...
Get a new set of random keys from WordPress.org by running the command:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
Or automatically rotate the Salts keys using WP-CLI (this will force all logged-in accounts, including hackers, to log out immediately):
wp config shuffle-salts --allow-root --path=/home/yourdomain.com/public_html
2. Database Password Leaked or Too Weak
If your database connection password was exposed in logs or is too simple, change it immediately in the MySQL console:
# Truy cập MySQL Console
mysql -u root -p
# Thay đổi mật khẩu cho user kết nối database
ALTER USER 'yourdomain_wp_user'@'localhost' IDENTIFIED BY 'mat_khau_moi_sieu_manh';
FLUSH PRIVILEGES;
EXIT;
Then, update this new password in the line DB_PASSWORD in the file wp-config.php.
Step 6: Replace the entire Core source code with a clean copy
To make sure no system files have been quietly altered by hackers, overwrite the core with a clean copy from WordPress's official source (skip the wp-content folder):
cd /tmp
wget https://downloads.wordpress.org/release/wordpress-7.0.2-no-content.zip
unzip wordpress-7.0.2-no-content.zip
# Sao lưu wp-admin và wp-includes cũ để dự phòng
cp -r /home/yourdomain.com/public_html/wp-admin /home/yourdomain.com/wp-admin-backup-\\$(date +%Y%m%d)
cp -r /home/yourdomain.com/public_html/wp-includes /home/yourdomain.com/wp-includes-backup-\\$(date +%Y%m%d)
# Sử dụng rsync ghi đè core sạch
rsync -av --exclude='wp-content' /tmp/wordpress/ /home/yourdomain.com/public_html/
Step 7: Reset the password of the genuine Admin account
Change the passwords for all actual admin accounts in the system (such as the account admindps and other admins) via WP-CLI:
wp user update admindps --user_pass="MatKhauMoiSieuCapBaoMat@2026" --allow-root --path=/home/yourdomain.com/public_html
Step 8: Block PHP File Execution in the Uploads Folder
This is a mandatory security hardening action. Hackers frequently exploit upload vulnerabilities to upload webshells disguised with extensions such as `.png.php` or similar into the uploads folder. Create a file .htaccess located in the folder wp-content/uploads/ with content that blocks PHP execution:
<Files *.php>
deny from all
</Files>
Step 9: Scan the System One More Time to Confirm It Is Clean
Rerun the comprehensive scan to make sure no remaining threats are left behind:
wordfence malware-scan --include-all-files --output-path=/home/yourdomain.com/public_html/wordfence-scan-final.log /home/yourdomain.com/public_html/
When the results come back completely clean, turn off maintenance mode:
wp maintenance-mode deactivate --allow-root --path=/home/yourdomain.com/public_html
Step 10: File Permissions and Continuous Monitoring
Set the directory permissions to 755, the file is 644, and file wp-config.php is 400 or 600 to prevent unauthorized changes to the configuration file.
Website Security Optimization with DPS.MEDIA Professional Services
Removing malware only addresses the symptoms. The core issue is that you must identify the original security vulnerability by analyzing the Web Server Access Log at the time the backdoor file was created, in order to close that gap and prevent hackers from returning next time.
You should review the official security standards through the official WordPress Hardening documentation to enhance the security of the system.
If you are struggling to clean up malicious code or want to strengthen comprehensive security for your website, contact DPS.MEDIA right away via Hotline/Zalo: 0961545445 or visit our office at number 56 Nguyen Dinh Chieu, Tan Dinh Ward, District 1, Ho Chi Minh City. We offer professional WordPress website design service SEO-compliant, with integrated multi-layer automatic security and daily secure backup mode, helping you operate your business with confidence and grow sustainably.
Ý kiến bạn đọc (9)
Đăng nhập để bình luận
Đăng nhập nhanh 1-chạm bằng Google để chia sẻ ý kiến của bạn về bài viết.
Bằng cách đăng nhập, bạn đồng ý với điều khoản và chính sách cộng đồng.
A case of 16,854 files where only 3 were flagged as suspicious sounds like a small number, but that doesn't mean the system is clean, right? Especially with 7,903 files skipped, should I scan them again using a different method?
That's right. The number of files detected should not be taken to mean that all the malicious code is only in those 3 files. Skipped Files need to be checked for the cause; if important folders or files were not scanned, they must be addressed first and then rescanned.
We have encountered cases where the logs showed only a few files, but hackers had also installed a fake admin and injected configuration into the database. Cleaning up files alone is not enough; you must also check users, the database, cron jobs, and the source code.
I'd like to ask: if wp-fixplugin.php is found in mu-plugin, should it be deleted immediately, or should it be backed up and analyzed first? The website is running sales, so I'm quite hesitant to accidentally delete a system file.
Don't delete anything just because the name looks unfamiliar. Make a forensic backup first, check the content and file modification times, compare against a clean source, and only then remove it. Unfamiliar mu-plugins deserve special attention because they can be loaded automatically.
Exactly. I once only deleted the files without looking for persistence, so a few days later they reappeared on their own. Then I had to check the database, fake admin accounts, and other auto-run mechanisms before it was fully cleaned up.
Blocking PHP execution in uploads is a very practical step. If you clean everything up but still let hackers upload and execute a shell, all the earlier effort is wasted.
Replacing the entire WordPress Core is worth doing if you're not sure which files have been modified. But third-party plugins and themes still need to be checked separately; replacing the core doesn't solve all malware problems.
Many people probably skip the Salts keys section, thinking it's just a minor configuration. If you suspect the website has been compromised, resetting the salts along with the admin password is something you should do promptly to invalidate old login sessions.
Chưa có bình luận nào. Hãy là người đầu tiên chia sẻ cảm nghĩ!
Đăng nhập / Tạo tài khoản
Đăng nhập với Google để gửi bình luận và tương tác cùng cộng đồng.
Tiếp tục là đồng ý với điều khoản sử dụng và chính sách bảo mật của DPS Media.