GoAdmio

uploader

List recent POST requests (size, time, visitor IP, and request) from the access log, or trace which request uploaded a given file by matching its size and modification time

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

Attackers often get into a website by uploading a file, such as a PHP shell, with a POST request. /go/uploader helps you find out who did it. It has two modes:

Mode You give it It shows
List Nothing, hour, or a number of seconds Every POST request in the access log during that time
Trace a file The path of one file The POST requests that could have uploaded that file

In trace mode, it looks for requests from the last 7 days to the file's domain whose size is close to the file's size, and that happened within 30 seconds of the time the file was last changed. The request gives you the visitor's IP address, which you can then block.


Quick start

# POST requests of the last 24 hours
/go/uploader

# Who uploaded this file?
/go/uploader /home/example.com/www/uploads/suspicious.php

Syntax

/go/uploader [hour | seconds]
/go/uploader <file>

The command writes the call and a timestamp to /var/log/go/uploader.log. Run it as root.


Arguments

You type Mode Time window
Nothing List Last 24 hours
hour List Last hour
A whole number, such as 3600 List Last that many seconds. 604800 is 7 days.
One argument that is an existing file Trace Last 7 days, matched to the file
Anything else List Last 24 hours

[!WARNING] A misspelled file path is not reported as an error. It is not an existing file, so it is treated as "anything else" and lists all POST requests of the last 24 hours.

Trace mode works only when you give exactly one argument. It assumes the file is under /home/<domain>/, because it takes the domain from the path.


Output

Every request is one row:

Column Meaning
1 The size of the request in bytes
2 The value in field 7 of the access log line
3 The time, as a Unix timestamp (list mode only)
4 The visitor's IP address. When the log has a forwarded address, that is used. Otherwise the connecting address.
5 The host name, joined directly to the request, with no space between them
1534  200  1732190000  203.0.113.7  example.comPOST /upload.php HTTP/1.1

The values above are only an illustration.

Rows are sorted by size, smallest first. To read a timestamp, run date -d @1732190000.

Trace mode

Trace mode first prints:

Then it prints the matching rows, with columns 1, 2, 4, and 5 only. Column 5 is cut at its first word, so it shows the host name and method but not the URL. The command always ends with exit status 1.


Examples

# All POST requests of the last 24 hours
/go/uploader
# The last hour
/go/uploader hour
# The last 7 days
/go/uploader 604800
# Trace a file (run it from the file's folder, not from /)
cd /home/example.com/www/uploads
/go/uploader suspicious.php
# Turn a timestamp into a date
date -d @1732190000

Troubleshooting

Symptom Likely cause Fix
Trace mode prints nothing under the file size line The file was changed more than 7 days ago, the upload was not a POST, the log was rotated, or no request matches in size and time. Check an older log by hand, or use list mode with a number of seconds.
Trace mode shows many rows Several requests of a similar size happened at the same time. Compare the rows with the file's content and the site's pages.
Trace mode shows no URL Column 5 is cut at its first word. Search the access log for the IP address.
A long list appears when you meant to trace a file The path was misspelled, so list mode ran. Check the path.
Trace mode shows the wrong domain, or nothing The file is not under /home/<domain>/. Use a path inside the site's folder.
It is slow Trace mode searches the current folder, the whole log is read, and two external web requests are made on every run. Run it from a small folder.
host and POST are joined, such as example.comPOST The script prints them with no space. Read it as host and method.
Rows from another domain appear in trace mode Domains are matched anywhere in the line, so example.com also matches my-example.com. Check the host name in column 5.

Details

List mode

  1. Records the call in /var/log/go/uploader.log.
  2. Finds the access log with GoAdmio's LOG helper.
  3. Works out the start time: now minus the number of seconds (hour is 3600, and the default is 86400).
  4. Reads the access log and keeps lines that are POST requests newer than that time.
  5. Prints size, field 7, time, IP address, and host plus request, sorted by size.

Trace mode

  1. Prints the path of any file named 88888888888.jpg found below the current folder.
  2. Gets the file's full path, and takes the domain from it.
  3. Reads the file's size and its last modification time.
  4. Runs uploader 604800 for the last 7 days, keeps the lines that contain the domain, and saves them in /usr/local/goadmio/tmp/uploader.log. That file is overwritten each time.
  5. Keeps the requests that are inside both limits below.
Check Limit
Request size From the file size minus 1,000 bytes up to the file size plus 10,000 bytes. The extra space covers the request headers.
Request time Within 30 seconds before or after the file's last modification time
  1. Prints the dashed lines, the file size, and the matches.
flowchart TD
    A["uploader [argument]"] --> B{"One argument that is an existing file?"}
    B -- "Yes" --> C["Get domain, size, and modification time"]
    C --> D["List POST requests of the last 7 days for the domain"]
    D --> E["Keep requests close in size and time"]
    E --> F["Print matches, exit 1"]
    B -- "No" --> G["Work out the time window"]
    G --> H["List POST requests in that window, sorted by size"]

Settings that are read but not used

The command reads /etc/posttop for a request limit (250 by default, as in posttop), and the server's public IPv4 and IPv6 addresses. None of them is used by this command.


See also

Command Description
posttop Report IPs sending the most POST requests and block POST floods
scan Scan newly modified PHP files for shells and the root password
block Block an IP address in the server firewall and in Cloudflare
waf Block IPs via Cloudflare WAF
clamav Install or update ClamAV, or scan hosted domains for malware
httptop Watch the most frequent recent HTTP requests from the access log
iptop Report the busiest IPs by request count and block floods and bot networks
uploadmaxfilesize Read or set PHP upload_max_filesize across all php.ini files
postmaxsize Read or set PHP post_max_size across all php.ini files