Blogs & Stories

SpiderLabs Blog

Attracting more than a half-million annual readers, this is the security community's go-to destination for technical breakdowns of the latest threats, critical vulnerability disclosures and cutting-edge research.

[Honeypot Alert] PHP-CGI Vuln Targeted For Database Dumping

Thanks to my SpiderLabs Research colleague @claudijd for collaborating with this analysis.

In a previous blog post, we highlighted how the PHP-CGI vulnerability is actively being targeted by attackers. Attackers often have the same set of goals or outcomes for their attacks (botnet recruitment, exfiltration of user data, etc...) but the specific attack vectors are "hot swapable." They simply monitor for new vulnerabilities and then try to use the same attacks against the new vectors. In this blog post, we will highlight an interesting attack that leveraged the PHP-CGI vulnerability.

PHP-CGI Attack Payload

On Friday, our web-based honeypots picked up the following attack targeting the PHP-CGI vulnerability:

Screen shot 2012-06-18 at 9.21.34 AM
The php "-dauto_prepend_file" argument levarages the PHP-CGI vulnerablity and tells the php program to download the code on the remote site and execute it before any local code. In this case, the "versions.txt" file on the remote hacker site contains the following php code:

Screen shot 2012-06-18 at 9.25.19 AM
This code will take the POST parameter "d" payload and loop though it 100 characters at a time and convert it into the following php code:

Screen shot 2012-06-18 at 9.30.30 AM

The initial section of code can be decoded to the following:

Screen shot 2012-06-18 at 4.43.10 PM
This will essentially take the data sent within the POST parameter "p1", execute it and then format the data for the html response. This section of code is taken from larger webshell/backdoors that we have captured from our web honeypots.

Sypex Dumper

When this php code executes, the resulting output includes something similar to this:


Sypex Dumper is described as:

Sypex Dumper is a PHP-script, which can help you create a backup (dump) of a MySQL database, and also restore the database from the backup if needed.

It contains the cfg.php file we saw referenced in the output above and here are the default configuration contents:

Screen shot 2012-06-18 at 10.06.52 AM

As you can see, this is a configuration for the DB backup process. In this case, the attackers are of course initiating illegal backups or data dumps. During our web honeypot research, we have identified examples of other sites being compromised and even found SQL database dump files of successful exfiltration using similar tools.

We highly recommend that sites review their SQL database configuration to verify that default username/passwords and access permissions have been updated.