How to Find and Remove a Web Shell in WordPress
A web shell is a script that can give someone remote control of files or commands on your web server. If you find one that you did not authorize on your WordPress site, treat it as a possible compromise. Do not open the suspected file in a browser to see what it does.
Editorial correction: An earlier version of this page described uploading shells as a routine WordPress task. That advice was misleading. This guide now explains how site owners can investigate and remove an unauthorized web shell. For ordinary maintenance, use your hosting panel, SFTP or authorized SSH access.
What to do first if you suspect a web shell
Contact your host and record what you found: the file path, the time, any security alert and the symptoms visitors see. Ask the host to help restrict access if the site is serving harmful content. Preserve a copy of the files, database and available logs before cleanup. Keep this evidence private and outside the public website; an infected backup is evidence, not a clean recovery point.
If the dashboard is compromised or inaccessible, work through the hosting account instead. Avoid adding an unfamiliar file-manager plugin to the affected site. For a broader recovery checklist, see WordPress.org’s hacked-site guidance.
1. Investigate suspicious files without running them
Use your host’s file manager or SFTP to inspect file names and modification times. Review unexpected PHP files in uploads, unfamiliar plugins, must-use plugins, theme changes and files in the WordPress root. Check related sites in the same hosting account too.
A strange name, recent timestamp or encoded text is a lead, not proof. Legitimate plugins can generate files, and attackers can change timestamps or hide code inside otherwise normal files. Compare suspicious files with a trusted package for the same product version. Do not delete every PHP file in a folder or assume a file is safe because its name looks familiar.
2. Compare WordPress files with trusted originals
If your host provides WP-CLI, ask them to run a core integrity check from the correct WordPress installation directory:
wp core verify-checksums
This compares core files with WordPress.org’s checksums and runs before WordPress loads. A mismatch needs investigation; it does not identify the attacker or establish that every other file is safe. Use the installed version and locale when troubleshooting a mismatch. See the core checksum command documentation.
WordPress.org plugins can also be compared with their published checksums:
wp plugin verify-checksums --all
Premium and custom plugins may not have WordPress.org checksums. Obtain their clean packages from the original developer. Plugin checks do not validate your database, uploads or every theme file. On a compromised installation, have your host perform checks in an isolated environment; do not assume that every command is safe merely because it is diagnostic. See the plugin checksum command documentation.
3. Remove confirmed malicious code and restore clean files
After preserving evidence, have confirmed malicious files quarantined outside the web-accessible directories. Replace affected core, plugin or theme files with trusted copies, keeping track of legitimate customizations. Uploading a clean package over an infected directory can leave extra malicious files behind, so compare the complete file set.
Do not replace wp-config.php, delete wp-content or remove a database without knowing what they contain and how you will restore the site. If you use a backup, establish that it predates the compromise and investigate how the original intrusion happened before reopening the site.
4. Check for other ways the attacker could return
One removed shell does not prove cleanup is complete. Review administrator accounts, application passwords, scheduled tasks, must-use plugins, server configuration changes and suspicious database content. Ask your host to examine access logs and other installations under the account. Keep a record of what was checked and what remains uncertain.
If you cannot establish the scope of the compromise, stop making isolated edits and get help. You can describe the symptoms through my WordPress malware removal service. I confirm the scope and price before work starts.
5. Close the entry point and secure access
Patch or remove the vulnerable component identified during the investigation. Use supported software from trusted sources. From a clean device, revoke unauthorized access and change affected passwords. Coordinate database credential changes with the site’s configuration so you do not disconnect WordPress. Rotate WordPress security keys and salts to invalidate existing login sessions.
Review account permissions, enable available multifactor authentication and ask your host about restricting script execution in upload directories where appropriate for your site. A firewall can reduce exposure, but it does not remove an existing backdoor. The WordPress hardening handbook explains additional safeguards.
6. Verify recovery and keep monitoring
Check important pages, login, forms and any checkout or course access from a normal visitor session. Rescan the recovered files, confirm that the suspicious file does not reappear and monitor new alerts and unexpected account changes. If Google reported a security issue, review its report and request a review after the underlying problem is resolved.
Save a clean recovery backup and document the repair. Ongoing WordPress maintenance can help keep updates, backups and monitoring organized, but no maintenance plan can guarantee that a site will never be compromised.
Common questions about WordPress web shells
Is a web shell the same as SSH?
No. SSH is an authenticated remote-access service supplied by your host. A web shell is code running through the website. Uploading a shell is not a required step for ordinary WordPress administration.
Can a scanner prove my site is clean?
A scanner can find known patterns and suspicious changes, but a clean scan is not proof that every backdoor is gone. Combine scanning with file comparisons, account review and investigation of the entry point.
Why does this page still have an upload-shell URL?
The address is retained so existing links reach the corrected guide. The previous instructions have been replaced with guidance for protecting and recovering a WordPress site.
