標籤:
catalog
1. 漏洞描述2. 漏洞觸發條件3. 漏洞影響範圍4. 漏洞程式碼分析5. 防禦方法6. 攻防思考
1. 漏洞描述
Dedecms測試人員中樞注入漏洞
Relevant Link
http://www.yunsec.net/a/security/bugs/script/2012/1220/12127.html
2. 漏洞觸發條件
因為是update注入,並且用了>ExecuteNoneQuery所以不能採用benchmark延時注入,但是可以通過一個"返回狀態差異"判斷來進行忙注,如果條件成功那麼mtypename=‘$name‘就會被update了
1. 首先開啟: http://127.0.0.1/dedecms5.5/member/mtypes.php2. 添加一個分類,記住ID(1),和原來的分類名稱(fenlei)3. 然後開啟: http://127.0.0.1/dedecms5.5/member/mtypes.php?dopost=save&mtypename[1‘ or @`‘` AND 1%3D1 and (select ‘r‘)%3D‘r‘ and ‘1‘%3D‘1]=4//將其中的1改成你的分類ID4. 結束之後開啟之後返回: http://127.0.0.1/dedecms5.5/member/mtypes.php //如果(select ‘r‘)=‘r‘的話 那麼分類名稱就被改成了4! 這樣我們就能來判斷是否滿足條件了,二值判斷注入
Relevant Link
http://www.wooyun.org/bugs/wooyun-2010-048880http://www.0x50sec.org/0day-exp/2012/12/id/1482/comment-page-1/#comment-57057
3. 漏洞影響範圍
4. 漏洞程式碼分析
/member/mtypes.php
elseif ($dopost == ‘save‘){ if(isset($mtypeidarr) && is_array($mtypeidarr)) { $delids = ‘0‘; $mtypeidarr = array_filter($mtypeidarr, ‘is_numeric‘); foreach($mtypeidarr as $delid) { $delids .= ‘,‘.$delid; unset($mtypename[$delid]); } $query = "delete from `#@__mtypes` where mtypeid in ($delids) and mid=‘$cfg_ml->M_ID‘;"; $dsql->ExecNoneQuery($query); } //通過$mtypename進行key注入 foreach ($mtypename as $id => $name) { $name = HtmlReplace($name); //未對索引值$id進行任何過濾就帶入查詢,導致注入 $query = "update `#@__mtypes` set mtypename=‘$name‘ where mtypeid=‘$id‘ and mid=‘$cfg_ml->M_ID‘"; $dsql->ExecuteNoneQuery($query); } ShowMsg(‘分類修改完成‘,‘mtypes.php‘);}
5. 防禦方法
/member/mtypes.php
elseif ($dopost == ‘save‘){ if(isset($mtypeidarr) && is_array($mtypeidarr)) { $delids = ‘0‘; $mtypeidarr = array_filter($mtypeidarr, ‘is_numeric‘); foreach($mtypeidarr as $delid) { $delids .= ‘,‘.$delid; unset($mtypename[$delid]); } $query = "delete from `#@__mtypes` where mtypeid in ($delids) and mid=‘$cfg_ml->M_ID‘;"; $dsql->ExecNoneQuery($query); } //通過$mtypename進行key注入 foreach ($mtypename as $id => $name) { $name = HtmlReplace($name); /* 對$id進行正常化處理 */ $id = intval($id); /* */ $query = "update `#@__mtypes` set mtypename=‘$name‘ where mtypeid=‘$id‘ and mid=‘$cfg_ml->M_ID‘"; die(var_dump($query)); $dsql->ExecuteNoneQuery($query); } ShowMsg(‘分類修改完成‘,‘mtypes.php‘);}
通過intval規範互處理,使得駭客注入的盲注語句失效,即不管任何時候,返回結果都是能成功修改為4,即盲注的二值條件不存在了
6. 攻防思考
Copyright (c) 2015 LittleHann All rights reserved
dedecms /member/mtypes.php SQL Injection Vul