www.51xiaofeng.com
phpwind 7.5 0day漏洞运用
phpwind 7.5 Multiple Include Vulnerabilities
壹.api/class_base.php本地包含漏洞
1.描敘
api/class_base.php文件裏callback函數裏$mode變量沒有過濾導致任意包含本地文件,從而可以執行任意PHP命令.
2. 具體分析
api/class_base.php文件裏:
function callback($mode, $method, $params) {
if (!isset($this->classdb[$mode])) {
if (!file_exists(R_P.’api/class_’ . $mode . ‘.php’)) {
return new ErrorMsg(API_MODE_NOT_EXISTS, “Class($mode) Not Exists”);
}
require_once(R_P.’api/class_’ . $mode . ‘.php’); //這裏
$this->classdb[$mode] = new $mode($this);
}
if (!method_exists($this->classdb[$mode], $method)) {
return new ErrorMsg(API_METHOD_NOT_EXISTS, “Method($method of $mode) Not Exists”);
}
!is_array($params) &&$params = array();
return @call_user_func_array(array(&$this->classdb[$mode], $method), $params);
}
我們繼續跟壹下具體變量傳遞的過程. 上面的函數在run()裏有調用:
function run($request) {
$request = $this->strips($request);
if (isset($request['type']) &&$request['type'] == ‘uc’) {
$this->type = ‘uc’;
$this->apikey = $GLOBALS['uc_key'];//註意這個變量也是該漏洞的關鍵
} else {
$this->type = ‘app’;
$this->apikey = $GLOBALS['db_siteownerid'];
$this->siteappkey = $GLOBALS['db_siteappkey'];
}
/***
if ($this->type == ‘app’ &&!$GLOBALS['o_appifopen']) {
return new ErrorMsg(API_CLOSED, ‘App Closed’);
}
***/
ksort($request);
reset($request);
$arg = ”;
foreach ($request as $key => $value) {
if ($value &&$key != ‘sig’) {
$arg .= “$key=$value&”;
}
}
if (md5($arg . $this->apikey) != $request['sig']) { //註意這個判斷,需要繞過它.上面的代碼可以看的出來$this->apikey = $GLOBALS['uc_key'],和$request['sig']我們
//都可以操控,那麽很轻易繞過它
return new ErrorMsg(API_SIGN_ERROR, ‘Error Sign’);
}
$mode = $request['mode']; //取$mode 沒有過濾直接進入下面的callback()
$method = $request['method'];
$params = isset($request['params']) ? unserialize($request['params']) : array();
if (isset($params['appthreads'])) {
if (PHP_VERSION <5.2) {
require_once(R_P.’api/class_json.php’);
$json = new Services_JSON(true);
$params['appthreads'] = $json->decode(@gzuncompress($params['appthreads']));
} else {
$params['appthreads'] = json_decode(@gzuncompress($params['appthreads']),true);
}
}
if ($params &&isset($request['charset'])) {
$params = pwConvert($params, $this->charset, $request['charset']);
}
return $this->callback($mode, $method, $params); //調用callback ()
}
我們繼續看看run()函數的調用:
在pw_api.php文件裏:
$api = new api_client();
$response = $api->run($_POST + $_GET);//直接run了$_POST , $_GET提交的變量.
上面的分析是逆行分析了整個漏洞變量提交的過程,其實我們這個漏洞還包含壹次編碼與解碼的問:require_once(R_P.’api/class_’ . $mode . ‘.php’);這個需要繞過魔術引號才可以
包含轻易文件.我們註意看run()的第壹句
$request = $this->strips($request);
strips()的代碼:
function strips($param) {
if (is_array($param)) {
foreach ($param as $key => $value) {
$param[$key] = $this->strips($value);
}
} else {
$param = stripslashes($param); //變量直接使用了stripslashes,那麽我們可以直接繞過魔術引號了 ![]()
}
return $param;
}
3.POC/EXP
缺
4.FIX
由於漏洞信息的外泄,官方針對這個漏洞已經做出了修補:
http://www.phpwind.net/read-htm-tid-914851.html
具體代碼:
require_once Pcv(R_P.’api/class_’ . $mode . ‘.php’);
function Pcv($filename,$ifcheck=1){
$tmpname = strtolower($filename);
$tmparray = array(‘ http://’,”\0“); //過濾了http:// \0 意思是不讓遠程 不讓截斷
$ifcheck &&$tmparray[] = ‘..’; //過濾了.. 意思是不讓轉跳目錄
if (str_replace($tmparray,”,$tmpname)!=$tmpname) {
exit(‘Forbidden’);
}
return $filename;
}
從Pcv()可以看出來phpwind的補丁風格是很猥瑣的,單從這個pcv來看 還有很多的邏輯問題,比如http://這個過濾很搞笑,人家就不可以用ftp://? …
二.apps/share/index.php遠程包含漏洞
1.描敘
apps/share/index.php 裏$route和$basePath變量沒有初始化,導致遠程包含或者本地包含php文件,導致執行任意php代碼
2.具體分析
<?php
if ($route == “share”) {
require_once $basePath . ‘/action/m_share.php’;
} elseif ($route == “sharelink”) {
require_once $basePath . ‘/action/m_sharelink.php’;
}
?>
這個漏洞好象不太需要分析!!!! 我建議寫這個代碼的人應該扣除年終獎…
3.POC/EXP
缺
4.FIX
等待官方補丁,假如用不著的朋友直接把這個文件刪除好了.
三.apps/groups/index.php遠程包含漏洞
1.描敘
apps/groups/index.php 裏$route和$basePath變量沒有初始化,導致遠程包含或者本地包含php文件,導致執行任意php代碼
2.具體分析
<?php
if ($route == “groups”) {
require_once $basePath . ‘/action/m_groups.php’;
} elseif ($route == “group”) {
require_once $basePath . ‘/action/m_group.php’;
} elseif ($route == “galbum”) {
require_once $basePath . ‘/action/m_galbum.php’;
}
這個漏洞好象不太需要分析!!!! 我建議寫這個代碼的人應該扣除年終獎…
3.POC/EXP
缺
4.FIX
等待官方補丁,假如用不著的朋友直接把這個文件刪除好了.
最新消息 目前官方已經發布補丁http://www.phpwind.net/read-htm-tid-914851.html
| 打印文章 | 这篇文章由小枫于2010年06月26日 2:26 下午发表在心情短语。你可以订阅RSS 2.0 也可以发表评论或引用到你的网站。 |
大约3周前
One knows that our life is high priced, but different people require money for various things and not every person earns enough money. So to receive fast loans or just sba loan will be a correct way out.
大约2月前
I had got a desire to make my firm, but I didn’t have got enough amount of money to do it. Thank God my close mate said to take the loans. Thence I received the consolidation loans and made real my desire.
大约2月前
People deserve very good life time and personal loans or just short term loan can make it better. Just because people’s freedom bases on money state.
大约2月前
好网站,不错的网站
大约2月前
精彩不容错过!
大约2月前
juicy couture outletmbt shoescheap mbt shoes
大约2月前
来看看 不想错过
大约2月前
Various people in the world receive the loan in different banks, because it’s simple and comfortable.
大约2月前
好文章,不错的博客
大约2月前
路过 留个名字,呵呵 愿您开心快乐每一天,愿您健康幸福每一天!
大约2月前
向蓝天借一朵云彩用喜悦写上;祝您生活甜蜜!
向大地借一片绿叶用真诚写上;祝您幸福吉祥!
向银河借一棵星星用思念写上;祝您快乐平安!
向明月借一束银光用企盼写上;祝您美梦成真!
大约2月前
人 生 是 一 道 风 景
快 乐 是 一 种 心 境
静 静 地 来 您 空 间
悄 悄 地 留 下 笔 迹
淡 淡 的 一 句 祝 福
倾 注 了 无 限 真 诚
愿你开心快乐每一天!
大约2月前
呵呵,新的一周开始了,祝博主,新的一周里,开心快乐~
大约2月前
不错的网站。好文章