grep it in your access log. Nothing. Zero hits. That feels wrong — the file had to get there somehow, and the access log is supposed to record every HTTP request. The disconnect makes people doubt their logs, suspect log tampering, or give up and just delete the shell. But in most cases, the logs are fine. You are searching for the wrong thing.
Why the Filename Is Not in the URI
POST requests with a multipart/form-data content type. When a browser or script uploads a file through a form, the request looks something like this at the protocol level:
TEXT
POST /wp-admin/admin-ajax.php HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="shell.php"
Content-Type: application/x-php
<?php eval($_POST['cmd']); ?>
------WebKitFormBoundary7MA4YWxkTrZu0gW--shell.php) lives inside the request body, not in the URI path. Standard web server access logs — Apache's combined format, Nginx's default format, LiteSpeed's access log — record the request line, which is just POST /wp-admin/admin-ajax.php HTTP/1.1. The body is never logged by default. So grepping for shell.php in the access log will never match, because that string was never written there.
This is not a bug or a gap in logging. Request bodies can be megabytes of binary data (images, archives, documents). Logging them by default would be impractical and a privacy concern. The web server records where the request went (the URI), not what it carried.
What the Access Log Actually Records
TEXT
192.0.2.45 - - [15/Jul/2025:09:14:33 +0000] "POST /wp-admin/admin-ajax.php HTTP/1.1" 200 58 "https://example.com/wp-admin/upload.php" "Mozilla/5.0 ..."- Client IP — who sent the request.
- Timestamp — when.
- Request method and URI —
POST /wp-admin/admin-ajax.php. - Status code —
200means the server processed it successfully. - Response size —
58bytes returned (often a small JSON response after an upload). - Referer — where the request originated from (can be spoofed, but still useful).
- User-Agent — what client software was used.
Identifying Upload Endpoints Worth Searching
/wp-admin/admin-ajax.php— handles AJAX actions for many plugins, including file uploads./wp-admin/async-upload.php— WordPress's native media uploader./wp-admin/media-new.php— the "Add New Media" page./wp-content/plugins/*/upload.phpor similar paths — plugin-specific upload handlers. Vulnerable plugins often expose their own upload endpoints.xmlrpc.php— can be used to upload media attachments via thewp.uploadFilemethod.
upload, import, file, media, attach, or editor in the URI. CMS platforms like Joomla, Drupal, and custom PHP applications each have their own upload routes.
The key question: which of these endpoints received a POST request around the time the webshell's file was created?
Narrowing Down with File Timestamps and Log Correlation
BASH
stat /home/user/public_html/wp-content/uploads/2025/07/shell.phpModify and Change timestamps. The Modify time reflects when the file content was last written — typically the upload moment. The Change time reflects metadata changes (permissions, ownership). An attacker who renames or chmods the file after upload will update Change but not necessarily Modify.
Armed with a rough timestamp window (say, within a few hours of the file's mtime), filter your access log for POST requests in that window. For Apache or LiteSpeed logs in combined format:
BASH
grep 'POST' /var/log/apache2/access.log | awk -F'"' '{print $2}' | sort | uniq -c | sort -rn | head -3015/Jul/2025:09, filter for that hour:
BASH
grep '15/Jul/2025:09' /var/log/apache2/access.log | grep 'POST' | less/var/log/nginx/access.log, and the format is similar enough that the same grep approach works. Adjust the path and date format to match your configuration.
What you are looking for: a POST request to an upload-capable endpoint, returning a 200 status, from an IP address that does not belong to a known site administrator, at a time consistent with the shell file's creation.
Reading the Results: What a Successful Upload Looks Like
async-upload.php from a recognized IP, with a normal user-agent. A webshell upload through a vulnerable plugin endpoint looks different in subtle ways:
- The URI targets a plugin-specific path that normal users rarely hit directly.
- The IP might be from a VPN, cloud provider, or a geographic region that does not match any known admin.
- The user-agent might be a scripting tool like
python-requests,curl, or a generic string, though sophisticated attackers spoof this. - The referer field might be empty or point to an external site, rather than the site's own admin panel.
- The response size might be unusually small (a terse "success" JSON) or unusually large (an error dump that leaks path information).
readme.txt or license.txt inside plugin directories (fingerprinting which plugins are installed and what version they run).
When Logs Are Genuinely Missing
/var/log/apache2/access.log.*.gz or wherever your logrotate configuration stores old logs.
The upload did not go through HTTP at all. If the attacker had SSH, FTP, or cPanel File Manager access, the file was placed on disk without generating a web server log entry. Check /var/log/secure or /var/log/auth.log for SSH logins, FTP logs (typically /var/log/messages or a dedicated vsftpd/proftpd log), and cPanel access logs (/usr/local/cpanel/logs/access_log) for File Manager usage.
A reverse proxy or CDN handled the request. If traffic passes through a load balancer or CDN before reaching your origin server, the origin's access log might show the proxy's IP rather than the attacker's, or the request might be logged only at the edge. Check CDN logs if available.
The attacker tampered with logs. If they had root or sufficient privileges, they could have edited or truncated the log file. Look for gaps in timestamps — a log that jumps from 09:12 to 09:47 with no entries in between is suspicious. Compare file sizes of rotated logs to spot anomalies.
After Finding the Entry Point
- Block the source IP at the firewall level immediately, though the attacker likely used a disposable IP.
- Identify the vulnerable endpoint. If it is a plugin, check whether a patch exists. If the plugin is abandoned or you do not use it, remove it entirely.
- Search for additional shells. Attackers commonly drop multiple backdoors. Use
findto locate recently modified PHP files, and scan for common webshell signatures likeeval(,base64_decode(,assert(, orpreg_replacewith theemodifier. - Check OPcache. A deleted webshell can still execute from PHP's opcode cache. If you are running OPcache, clear it after removing the files. This behavior is covered in detail in Why Deleted Webshells Still Run Until OPcache Is Cleared.
- Block PHP execution in upload directories. Preventing PHP from running inside
wp-content/uploadsor equivalent paths stops most webshells from functioning even if they land on disk. This is covered in Block PHP Execution in wp-content/uploads Before the Next Plugin Upload Flaw — though that article is not in the linkable list above, so verify the path exists before linking.
