How a scan works#
- The scanner asks the panel for all servers, 100 per page.
- It keeps the servers allowed by Scan mode.
- For each server it opens the folder
basePathplus the server UUID. - It collects the files that match Include patterns and do not match Exclude patterns.
- It skips empty files and files larger than Max file size.
- It reads each file as text and checks it line by line.
A finding is one line in one file that matches one check. A line that matches several checks gives several findings.
The checks#
All patterns are regular expressions. They ignore upper and lower case.
| Check | Severity | Looks for |
|---|---|---|
backdoors |
critical | eval or assert on base64_decode, gzinflate or str_rot13 output, create_function with base64_decode, preg_replace with the /e modifier, and the names of known web shells (c99shell, r57shell, b374k, wso.php, FilesMan) |
webshells |
critical | passthru( (not fpassthru), shell_exec(, a request variable called as a function, and php://input combined with eval, exec, system and similar functions or with request variables |
reverseshells |
critical | fsockopen with /bin/sh or /bin/bash, socket_create with socket_connect, nc -e /bin, bash -i to /dev/tcp, and Perl or Python scripts that combine sockets with a shell |
obfuscation |
high | Long base64_decode strings, gzinflate, str_rot13 or gzuncompress on base64_decode output, three hex escapes in a row, and a very long string followed by eval |
cryptominers |
critical | stratum+tcp://, xmrig, ethminer, cgminer, .mine( and mining with worker |
fileoperations |
high | file_put_contents or fwrite with base64_decode, move_uploaded_file to a .php file, copy from request variables, chmod to 0777 and unlink of /var/log |
database |
high | mysql_query, mysqli_query or SELECT ... FROM ... WHERE with request variables, UNION SELECT and DROP TABLE after a request variable, and INTO OUTFILE to a .php file |
network |
high | curl -o or wget -O to a .php file, file_get_contents of an http address, fsockopen with a host, and socket_connect |
containertools |
high | Tools that run containers or virtual machines on a game server: Harbor, Ptero-VM, proot, Alpine and other minirootfs downloads, unshare with root mapping or chroot, qemu with KVM, docker run or podman run with --privileged, setcap, capsh and LD_PRELOAD hooks |
These checks are PHP-heavy, but they run on every file type in Include patterns.
Keywords#
Keywords are plain names, also matched line by line and without regard to case. The severity is the group they are in.
| Group | Default keywords |
|---|---|
critical |
c99shell, r57shell, wso shell, WSO 2., PHPJackal, AnonymousFox, FilesMan, Cyber Shell, Harbor by RealTriassic, Ptero-VM, Alpine minirootfs |
high |
create_function, preg_replace.*\/e |
medium |
None |
low |
TODO: security vulnerability, FIXME: security hole, XXX: security |
Keyword findings have the category Suspicious Keyword.
File hashes#
When Hashes is on, the scanner computes the MD5 and SHA256 of each file and compares them with your lists. A match is a critical finding with the category Known Malware. The hash is taken over the file read as text, so it fits text files such as scripts and configs. No real malware hashes are included. The only default entry is the MD5 of an empty file, which never matches because empty files are skipped.
The plugin whitelist#
Some legitimate plugins use functions that look like a web shell. With Plugin whitelist on, a file whose path matches one of the listed paths gets a lighter check:
- The
webshellscheck is skipped. - For the other checks, a match only counts when the same line also contains
eval(,exec(,system(,passthru(,shell_exec(,assert(,base64_decodefollowed byeval, orpreg_replacewith/e.
Dynmap is whitelisted by default. See Settings.
Add your own checks#
Every section under malware that has enabled, severity and patterns is run, so you can add your own. Use one of the severities critical, high, medium or low.
malware:
mycheck:
enabled: true
severity: 'high'
patterns:
- 'some\s+regex'
The section name becomes the category of the finding.
What to do with a finding#
- Open the file on the node and read the line in the report.
- When the line is harmless, add the file to Exclude patterns, or the plugin to Plugin whitelist, so it does not come back.
- When the file is malware, remove it, find out how it got there and change the passwords of that server.
The scanner never changes anything by itself unless you turn on an action.