GoAdmio

scan

Scan PHP files modified in the last 24 hours for common web-shell function calls, and — if a stored key exists — for the root password appearing in code

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


Overview

/go/scan looks for two different things across every hosted account's recently changed PHP files, and emails and WhatsApps the administrator (not the hosting customer) when it finds something new:

  1. Possible web shells — any .php file modified in the last 24 hours that contains one of a short list of function names commonly (but not exclusively) used by malicious scripts.
  2. An exposed root password — the same recently modified files, checked against the server's own root password, if a key for it is saved at /var/go/etc/go.key.

[!WARNING] The root-password check calls openssl base64 -d -aes-128-cbc -d -pbkdf2 -nosalt -md md5 -in /var/go/etc/go.key -pass pass:"$MAC". openssl base64 is OpenSSL's plain Base64 encode/decode tool — it does not accept -aes-128-cbc, -pbkdf2, -md, or -pass at all (those belong to openssl enc, a different subcommand). This looks like it should have been openssl enc -d -aes-128-cbc -a -pbkdf2 -nosalt -md md5 .... As written, this call is very likely to fail and leave RemotePassword empty. An empty value then becomes an empty search pattern (grep -ioE "()"), and an empty pattern in grep matches every line of every file it's given — so this is likely to send a false "ROOT Password Scanner" alert, containing arbitrary lines from whatever PHP files were recently touched, on every run where go.key exists and any PHP file anywhere was modified in the last 24 hours. Verify this before trusting this part of the command's output.

[!NOTE] The PHP-shell check looks for base64_decode, proc_open, shell_exec, exec(, system(, and passthru — all of them ordinary PHP functions used by plenty of legitimate code (encoding, image handling, build tooling, and so on), not something unique to malware. This is a plain, case-insensitive text search, not the "AI-powered... behavioral pattern" analysis the alert email describes itself as. Treat every match as something to look at, not as confirmed malicious code.

The call is appended to /var/log/go/scan.log.


Quick start

# Run it once, by hand
/go/scan

It's meant to run on a schedule (daily, from cron), since it only looks at the last 24 hours of changes each time.


Syntax

/go/scan

The command takes no arguments.


Options

None.


Output

/home/example.com/www/wp-content/uploads/x.php:eval(gzinflate(base64_decode($s)));
There are no new PHP shell files.

Examples

# Run it manually
/go/scan
# Schedule it daily
/go/cron
# Clear the "already alerted" record for the shell scanner, to force re-alerting
sudo rm -rf /usr/local/goadmio/db/shell/*

Troubleshooting

Symptom Likely cause Fix
You receive a "ROOT Password Scanner" alert that doesn't actually contain the root password The decryption call is very likely broken (see the warning above), turning the search into an always-matches-everything pattern. Treat these alerts as unreliable until the openssl command is corrected.
A flagged file turns out to be legitimate code The scanner matches on common PHP function names with no behavioral analysis, despite what the alert email says. Review the file yourself before taking action; false positives are expected.
The same web shell keeps getting flagged every day Its line content changed (so it hashes differently), or its modification time keeps refreshing. Expected; each distinct line is only alerted on once (see Details).
A web shell that was never cleaned up stops showing up in new alerts Its file hasn't been modified in over 24 hours, so it's outside this command's scan window entirely — not because it's been resolved. Don't rely on this command alone for ongoing detection of unchanged files; also run a full scanner such as clamav or antivirus.
The root-password check never runs at all /var/go/etc/go.key doesn't exist on this server. Expected if that key was never generated here.
The root-password check used to work and now always fails (or always "finds" something) The server has more than one network interface with a MAC address — for example, after installing Docker (which adds its own bridge interface) — so the MAC-derived passphrase no longer matches what was used when the secret was first encrypted. Confirm with ifconfig | grep -c ether how many interfaces report a MAC address; this check assumes exactly one.
ifconfig: command not found net-tools isn't installed; some modern distributions ship only ip by default. Install net-tools, or treat the root-password check as non-functional on this server.

Details

PHP shell scanner

  1. Finds every .php file under /home/*/www modified in the last 1440 minutes (24 hours).
  2. Greps each one, case-insensitively, for: base64_decode, proc_open, shell_exec, exec(, exec (, system(, system (, passthru.
  3. Keeps at most 25 matching lines, and removes every ( character from the result before anything else happens to it.
  4. For each matching line, hashes the full file-path-plus-match text with MD5. If a marker file for that hash doesn't already exist under /usr/local/goadmio/db/shell/, creates one and adds the line to this run's alert.
  5. If anything new was found, emails and WhatsApps the administrator a templated security alert containing the new lines; a file whose matching line was already alerted on before is not alerted on again.

Because step 1 only looks at files modified in the last day, a file that was planted earlier and hasn't been touched since will not be examined by a later run — this command catches new or recently changed files, not everything on disk.

Root password scanner

Runs only if /var/go/etc/go.key exists:

  1. Derives a passphrase from the MAC address(es) reported by ifconfig, Base64-encoded.
  2. Attempts to decrypt go.key with that passphrase (see the warning above about the likely-broken openssl invocation) to recover the stored root password.
  3. Searches the same set of recently modified PHP files for that exact string.
  4. If anything matches, redacts the password with asterisks in the output and sends an alert — with no deduplication, so a persistent match (true or false) re-alerts on every run.

Known issues


See also

Command Description
clamav Open-source antivirus engine for malware, viruses, trojans, and threats
antivirus Built-in GoAdmio antivirus
uploader Report file uploads or fingerprint a known file
cron Set up main cron jobs in GoAdmio
root Change the GoAdmio root password
fail2ban Install and configure Fail2ban to ban brute-force sources against SSH, FTP, SMTP, and Dovecot