WEBSITE RECOVERY
PHP Webshell Removal: Recover the Website and Close Access
A PHP webshell is an unauthorised server-side script that can give an attacker continuing access to a web server. Removal must cover the access route, other persistence and potentially exposed secrets; deleting the discovered file alone does not establish that the server is trustworthy.

Understand the finding without running the suspect file
MITRE describes webshells as a form of persistent access through a web server. A suspect script may provide capabilities far beyond changing the page that first alerted the owner. Do not browse to the script or execute it to see what it does. Have an authorised investigator examine a preserved copy in an appropriate isolated environment.
Treat scanner results, unusual filenames and obfuscated content as investigation leads rather than verdicts in isolation. Legitimate applications can use generated or encoded code, while a malicious file can have an ordinary name. File timestamps can also be misleading. Compare the finding with trusted source material and correlate it with available request and system activity.
| Finding | Question for the investigator |
|---|---|
| Unexpected PHP file in public content | Who or what wrote it, and can requests reach an execution handler? |
| Unapproved change to an existing script | What code path loads it and what other components were changed? |
| Repeated suspicious file creation | Is a remaining process, account or scheduled task restoring persistence? |
| Web-process activity outside expected behaviour | Does the incident extend beyond the application directory? |
Contain access while preserving useful evidence
Restrict the affected application and ask the host to preserve relevant access, authentication and system evidence before it is overwritten. Retain the suspicious files and a snapshot privately with a clear record of collection. Do not leave a renamed backdoor inside a public directory on the assumption that it can no longer execute.
Record the affected hosting identity, directories, applications and connected services. A shared account can expose more than the one site on which the webshell was found. If privileged host access may have been obtained, involve the infrastructure provider or incident-response specialist rather than treating the work as ordinary website maintenance.
Containment should stop harmful access, not simply hide a visible error. A firewall rule aimed at one known URL may reduce immediate exposure while leaving a second backdoor or stolen credential usable. Document what the containment covers and what remains uncertain.
Investigate initial access and the reach of the incident
Review the application's upload handling, known affected components, deployment process and administrative access. Correlate file changes with the request and account timeline. The presence of a webshell does not itself identify the original vulnerability; it may be a consequence of stolen credentials, an application flaw or a wider host compromise.
Microsoft's published webshell investigations show why the scope can extend beyond a single file into other accounts and systems. For your environment, investigate the permissions actually available to the affected process and credentials it could access. Do not assume full server compromise without evidence, but do not assume the application directory was an effective boundary either.
- Inventory other applications and directories writable by the same identity.
- Review scheduled jobs, startup configuration and application loaders for unauthorised persistence.
- Check exposed configuration and integration secrets and identify the owners who can revoke them.
- Inspect relevant outbound connections and unusual process behaviour where the hosting telemetry supports it.
- Record missing logs or visibility limits as investigation gaps, not as proof that no activity occurred.
Choose an eradication or rebuild approach deliberately
- Identify trustworthy application releases, custom source and essential business data before making destructive changes.
- Replace compromised executable components from verified sources and review configuration and stored content separately.
- Remove identified persistence and close the initial access route, or keep the unknown cause as an explicit unresolved risk.
- Rebuild the affected account or host on clean infrastructure when integrity cannot be established at that layer. Copy only reviewed necessary data into the replacement.
- Rotate relevant exposed credentials, revoke sessions and update integration configuration in an environment that can protect the new values.
Do not transplant an entire old document root into a fresh server and call that a clean rebuild. Equally, avoid deleting business data indiscriminately in the hope that less content means less risk. The migration needs an inventory, review decisions and functional acceptance.
Reduce execution opportunities in upload and content paths
Where file uploads are relevant, OWASP recommends layered validation and constrained storage rather than trusting a filename or browser-supplied content type. Review permitted formats, content checks, generated storage names, size limits and the permissions required by the business feature. Keep uploaded content away from execution paths where the architecture allows.
Have the hosting administrator test the effective configuration for the actual web server and PHP handler. Copying an Apache rule into a directory served by a different stack may do nothing. Confirm that legitimate media still works and disallowed executable content cannot run. Do not relax permissions broadly to repair a broken upload feature after cleanup.
These controls reduce exposure but do not replace runtime and application updates. Nor do they prove that a previously compromised server is clean. Record which specific route they address and verify them as part of the restored system's acceptance checks.
Verify recovery and document the remaining boundary
Test the public business journeys, expected script behaviour, account access and baseline file inventory. Review any newly created files or unexpected activity after controlled use and scheduled work. Establish a monitoring owner and escalation route, with suitable retention for the evidence the host can actually provide.
Hypothetical example: a company finds a PHP backdoor in an upload directory. Investigation links the file to an unsafe upload feature and shows that the web process could read an integration secret. Recovery replaces the affected feature, prevents code execution in that content path, revokes the exposed secret and validates the replacement application. The final report distinguishes those confirmed findings from historical activity that cannot be reconstructed from missing logs.
CyberXperts can help scope PHP webshell removal and website recovery around the evidence available. Initial enquiries should describe the platform and finding without attaching live backdoor code, credentials or a public download of the affected database.
Frequently asked questions
Is deleting the webshell enough?
No. Another backdoor, stolen credential or unresolved vulnerability may remain. Preserve evidence, investigate the access route and affected permissions, remove persistence and establish a trusted application or host baseline. Document what was assessed and what remains uncertain.
Should I open a suspicious PHP file in my browser?
Do not execute or request it to test its capabilities. Use a preserved copy and an appropriate isolated analysis process handled by an authorised investigator. Interacting with the live script may trigger behaviour, change evidence or expose the investigator’s environment.
Can an image upload directory contain a backdoor?
An attacker may place unexpected executable content in a writable directory, especially if upload or server controls are weak. The directory name does not make its contents safe. Inspect files and verify the effective execution policy for the actual hosting stack.
Does a webshell mean the attacker controlled the whole server?
Not automatically. The scope depends on the process permissions, exposed credentials and subsequent activity. Investigate those boundaries with available host evidence. A webshell is serious, but both underestimating and exaggerating access without evidence can lead to poor recovery decisions.
When should the server be rebuilt?
Consider a clean infrastructure rebuild when host integrity cannot be established, privileged access is suspected or persistence cannot be bounded. Preserve evidence and plan selective data migration first. Rebuilding does not remove the need to close the access route and replace exposed credentials.
Sources and further reading
Official documentation and advisories supporting the technical points above. The recovery workflows and examples are editorial guidance for adapting to your own systems.
- MITRE ATT&CK: Web Shell, T1505.003 — accessed 22 October 2026
- Microsoft Security: Investigating web shell attacks — accessed 22 October 2026
- OWASP: File Upload Cheat Sheet — accessed 22 October 2026
Get practical support for your next step.
Tell CyberXperts what happened, which systems are affected and what you have already checked. Do not include passwords or sensitive incident evidence in the initial form.
Discuss your website security