PHP Malware Analysis
Rough cut analysis of PHP source code that I got via
running a WordPress honey pot.
This illustrates what I think the bottom feeders who hack WordPress sites do,
once they have illegitimate access to a new WordPress instance or host.
It's not scientific in any way. I'm only decoding the pieces of malware
that arrive at one honey pot, and I'm only decoding those pieces that
seem interesting because of method of download, obfuscation or unique
content. Oddities are over-represented because of that.
Broad malware categories
This collection of PHP malware, all found in the wild,
fits into a number of categories:
- Email spamming tools
- Access verification
- Reconnaisance, which has subcategories
- Web shells
- Backdoors
- SOCKS servers
- HTTP redirectors
- File Managers
- Password guessers
Some combinations occur: web shells, particularly WSO, often get used
as a backdoor (Php action, RC action). Access verification is a
form of reconnaisance.
Recon sometimes just looks at what CMS/frameworks are present,
but other times collects information about user ID, type and version
of OS, file system hints, useful only for potential lateral moves.
GetDomains recon seems like something of both, though.
Broad meta-malware categories
It seems to me that there are "cross cutting" aspects
of this kind of collection and analysis.
- Password guessing campaigns
- Methods of download, commonality with other malware
- Common "dropper" code usage
- Common phone-home code
- Common back-connect shell code (usually Perl)
- Methods of encoding/encryption (e.g. FOPO)
- Geolocation of attacking IP
- Campaign(s) associated with a specific malware
- subsequent access(es) of downloaded code
- previous access(es) of downloaded code
- common password lists used for guessing
Code that checks compromised website files for fragments of PHP that
indicate those files are probably malware.
Renames, deletes or repairs suspect files,
which probably renders most of them inoperative.
Injects code into WSO web shells that adds a special
cookie check as access control.
A PHP manager that downloads, runs, then deletes, a Python
program that downloads a list of domain names,
enumerates users of WordPress blogs on those domain names,
and tries to guess working passwords.
Guesses passwords using xmlrpc.php calls, not through
the WordPress login page.
574 instances of an email spamming tool downloaded to
7 different types of web shell, followed by 559 attempts
to send a test email through the spamming tool URLs.
I propose a hypothetical design for this distributed system.
2019-11-01, captured a similar campaign
The most backdoored download I've ever seen. A WSO 2.1 web shell, with
two phone-homes It also downloads the LeafMail mailing tool, and a WSO 2.6
web shell.
An instance of b374k Web Shell, which gets some code from EXIF
data of a googleusercontent.com JPEG image.
Descendant of b374k web shell, probably v2.2
A FOPO-encoded WSO webshell that I hand-decoded because
I didn't believe it was really FOPO-encoded.
Arrived in the same campaign that delivered the K4X SHELL.
Medium-capability web shell downloaded along with login_wall fake plugin.
May be related to c99 web shell.
Another autokey-encoded instance of the ring.php web shell.
The obfuscation has changed, and this wasn't part of a login_wall
download.
gsptg.php seems to try to convince web crawlers, spiders, search engines and bots
to come back often.
Ordinary humans probably continue to see the compromised WordPress site,
but it also sends users either referred by .kr domains,
or using Korean language in their browsers off to new URLs.
Downloaded via ring.php
A batch of malware received between 2017-11-23 and 2018-05-03
sharing a common method of encryption.
The encryption appears to be from WSO 4.x series of web shells,
but it has a much shorter key (8 vs 44 bytes).
At least 52 different downloads, including 4 instances of mumblehard
It's refreshing to see someone using non-trivial encryption.
Mumblehard botnet: a server that relays TCP/IP connections,
and a persistent payload, executed by cron, that can
download code from a command and control server, then
start it running.
Downloaded via WSO 4.x, my honey pot caught an evolved mumblehard.
Examination of the 44 Mumblehard instances I caught,
to see how the code and methods progress as time goes by.
A password-protected, plugin-extendable back door.
2019-05-09, I got a download of v3-01 of this backdoor.
It has a lot of fun stuff in it.
A Quttera blog entry
gives a non-specific description of these backdoors.
An object oriented dropper, descended from the procedurally-coded
code-in-cookie back door's
dropper.
An attack on a real WSO would leave behind an Extendable back door v2.0-1.
Campaign that would have installed v1-01 extendable backdoors.
The attackers tried to verify working WSO web shell targets before the installation.
Caught a second campaign on 2019-07-07
A backdoor that someone has tried to access over 1 million time
on my web site alone. Pretty stupid in and of itself, but apparently
an underground market for this backdoor exists.
A collection of malware masquerading as a plugin,
that's under active development.
A trojaned version of a real, but horribly out-of-date,
plugin named "Exec-PHP".
b374k has a link to download this moderately capable
web shell from pastebin.
A fake-ish theme, complete with a WSO web shell that
phones home, and an earlier version of webroot.php.
Another compromised WordPress theme, containing a seemingly
random complement of malware.
A relative of webrot.php, or sometimes known as "webrootv3".
More back shells than you can shake a stick at.
A moderately capable backdoor: saves and executes files,
as well as immediate PHP eval.
Uses native PHP RC4
encryption for password and data transfered.
A small, highly obfuscated immediate-eval backdoor.
The first layer of obfuscation just might be polymorphic,
redone every so often, or for every install.
Creates a .htaccess file that redirects users to yourstockexpert.su,
googlebot, bingbot and Baiduspider get a 404.
Undoes any file name changes that an invocation of the Vigilante Malware Cleaner
might make, too. That just seems weird, since ".suspected" file name
complaints are around, but not overwhelming. Maybe inter-spamgang warfare?
A WSO 2.5 web shell heavily modified by adding code from various
other hacking tools.
3.993 second WSO (Web Shell by oRb, a.k.a. "FilesMan")
installation, only eight HTTP requests, including a cold WordPress login.
Novel, yet oddly obfuscated WSO 2.5, installed via apikey.php.
apikey.php would have been installed via a plugin update with a malicious plugin,
so this isn't as circular as it could have been,
were apikey.php installed via WSO instance.
Another WSO 2.5, edited a little, called 2.6 and packaged up in a
dropper that probably doesn't work.
Arrived about an hour after the Chinafans defacement attempt.
Preceding the WSO 2.5 webshell installation,
someone from the same Chinese IP address tried to install
a defacement.
All of the passwords my honey pots have ever seen used to login to WSO instances.
What getting hit by a web exploit tool looks like.