2010-01-10 │phpwind 7.5 0day漏洞利用 【转】
作者:逍遥乾坤 | 发表时间:2010-01-10 16:19:45 | 分类:网络随笔 | 阅读:48482
| 评论:5330
2010-01-10 15:10
phpwind 7.5 Multiple Include Vulnerabilities
author: 80vul
team:http://www.80vul.com
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.具体分析
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
已经在这个补丁的同时'修补'了
http://www.phpwind.net/read-htm-tid-914851.html
!function_exists('readover') && exit('Forbidden');
if ($route == "share") {
require_once $basePath . '/action/m_share.php';
} elseif ($route == "sharelink") {
require_once $basePath . '/action/m_sharelink.php';
}
?>
三.apps/groups/index.php远程包含漏洞
1.描叙
apps/groups/index.php 里$route和$basePath变量没有初始化,导致远程包含或者本地包含php文件,导致执行任意php代码
2.具体分析
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
!function_exists('readover') && exit('Forbidden');
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';
}
?>
phpwind 7.5 Multiple Include Vulnerabilities
author: 80vul
team:http://www.80vul.com
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.具体分析
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
已经在这个补丁的同时'修补'了
http://www.phpwind.net/read-htm-tid-914851.html
!function_exists('readover') && exit('Forbidden');
if ($route == "share") {
require_once $basePath . '/action/m_share.php';
} elseif ($route == "sharelink") {
require_once $basePath . '/action/m_sharelink.php';
}
?>
三.apps/groups/index.php远程包含漏洞
1.描叙
apps/groups/index.php 里$route和$basePath变量没有初始化,导致远程包含或者本地包含php文件,导致执行任意php代码
2.具体分析
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
!function_exists('readover') && exit('Forbidden');
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';
}
?>
Top Iran Sites
FUCK SHIA
www.fadak.org www.islamicfeqh.org
www.islam-pure.de www.aqrazavi.org
www.al-hewar.com www.wilayah.org www.khamenei.com
www.imam-khomeini.org www.bayynat.org www.lankarani.org www.najaf.org www.tabrizi.org www.makaremshirazi.org www.shahroudi.com
www.al-khoei.org www.imamsadeq.org www.nasrallah.net www.alhakeem.com www.yahosein.net www.iiny.org www.msapsg.org www.aldaleel.org www.shialink.org www.holyquran.net www.quran.org.uk www.qurannetwork.com www.mansak.com www.madressa.net www.duas.org www.emamali.net www.wabil.com
www.h-marafie.org www.sicm.org.uk www.moqawama.org
www.ahlul-bayt.org www.alhag.org www.alhussain.com
www.imam-hussein.org www.azadari.com
www.jamkaran.info www.playandlearn.org www.yaabbas.com www.zainab.org www.nidanet.org
www.islamic-studies.org www.alseraj.net www.yamahdi.org www.ejlasmahdi.com www.islam.org.nz www.almarkaz.net www.alhadi.org
www.saba-igc.org www.almizan.org
www.alhoda.ws www.yazahra.com www.hasanbooks.com www.geocities.com/islamicyellowpages www.jaffari.org
http://home.swipnet.se/islam
www.almahdi.co.uk www.ahlulbaitonline.com
http://66.221.74.102/ahlulbayt_link.html www.mesbahyazdi.org www.yamahdi.org
www.understanding-islam.com
www.searchersforthetruth.i12.com www.geocities.com/ahlulbayt14/index1.html www.winislam.com www.alkarbalaeia.net
www.ya-hussain.com www.shiamasjid.org www.sobh.org
http://www.cybercities.com/t/almasder
www.hamasat.8m.net
http://alnor.4t.com www.ghadir.org www.ghadeer.org/site/thekr/index.htm www.ghadeer.org/site/abasaleh/index.html www.ghadeer.org/main.html
www.iec-houston.org
http://www.motahari.net www.shahidchamran.com
http://bahonar.roshd.ir
http://sadr.hawzah.net www.14Masom.com www.geocities.com/ahlulbayt14/index1.html
http://www.sobh.org/Shohada/Shohada-Jahan-Islam/Shohada-Palestine/Shahid-Aldorah.htm www.sobh.org www.imamjawad.net
www.imamali.i12.com www.Montazar.net www.jameatulquran.com
http://www.imamreza.net www.yahosein.net www.etekaf.org www.imamsadrnews.org www.andisheqom.com www.islamicdatabank.com www.convertstoislam.com
http://rajaee.roshd.ir www.Shiasearch.net www.qomicis.com www.mobalegh.net
http://63.249.218.117
www.awqaf-ir.org www.qomnet.net www.aqlibrary.org www.basiji.net www.fotros.org www.icronet.org www.nahad.net www.nezam.org www.noorihamedani.com www.roshd.org www.abtahi.com www.aghabaha.com/index.htm
www.allame-jafari.com www.ardebili.com
http://esraco.com
http://esraco.com/html/beetwen_bio1.htm
www.gharavi-aliari.com www.masoumeh.com www.navabsafavi.com www.saafi.net
http://amini.hawzah.net
http://farsi.tabrizi.org www.ghadeer.org/site/Al-darss/index.html www.holydefence.com/home.htm www.irib.com/presidency/occasion/Sacred-Defence.htm
http://mehr.sharif.edu/~jelveh/defa www.cressnet.com/war/index-f.html www.farhangeisar.com www.ghadeer.org/site/qasas/index.htm www.ghadeer.org/site/thekr/index.htm www.sabokbalan.com www.fakkeh.org www.avini.com www.ghadeer.org/site/tarbeiat/Default.html www.islamhoo.com www.jameeh.com www.iranwomen.org www.owghat.com www.maarefquran.com www.chehreha.com www.hafezan.org www.beheshti.org www.shahbazi.org www.qaraati.com www.rafed.net/arc/index.html www.imamkazem.net www.imambaqer.net www.imamcenter.org www.canoon.org www.mirath.com www.payameshargh.com www.salehin.com www.iranpolitics.net
www.j-alzahra.org www.mahooz.com www.alshaer.net
www.ic-el.org www.danafajr.com
www.karbala-najaf.org www.ashura.com www.fabonline.com www.karbala.com www.islam4u.com www.annajat.com www.aalalrasool.com www.taghrib.org www.fadak.org www.islamicfeqh.org
www.islam-pure.de www.aqrazavi.org
www.al-hewar.com
al-imam.net www.shia.org www.balagh.net www.hajr.org
www.u-of-islam.org www.alkawthar.com
www.ahl-ul-bayt.org www.hadith.net www.emamreza.net www.rafed.net www.aqaed.com www.imamalinet.net
www.al-islam.org
www.al-shia.com www.hawzah.net www.iranjudiciary.org
www.mche.or.ir www.iranscict.org www.policeir.com
www.hbi.dmr.or.ir www.tehrancouncil.com www.afghaniran.com www.ghest.com
www.iran-bonyad.org
www.gov.ir
www.majlis.ir
www.president.ir
www.fco.gov.uk
www.majlis.ir
www.ambadane.tehran.suite.dk
www.irandoc.ac.ir www.dialoguecenter.org www.irsteel.com
www.itc.ir
www.bhrc.gov.ir www.iranwomen.org www.iranstreetchildren.com www.sgccir.com
www.iranologyof.ir
www.dr-mfa.gov.ir
www.mfa,gov.ir
www.mmm.gov.ir
www.economicaffairs.ir
www.farhang.gov.ir
www.icic.gov.ir
www.icm.gov.ir www.iranministryofcommerce.com
www.mefa.gov.ir www.irall.com
www.ptt.gov.ir
www.moe.or.ir www.iranindustry.com
www.hbi.ir www.policeiri.org
www.itrc.ir
www.icic.gov.ir
www.dci.co.ir
www.issi.ir www.iranreri.com
www.culture-education.org www.irost.com
www.wrm.or.ir www.irantvto.com www.nyoir.org www.tavanir.org www.irpost.com
www.icro-euroamerica.com www.irisl.net www.iranmiras.org www.mporo.com www.elixiran.com www.doimil.com
www.gsi-iran.org/p/index.html www.iramdoe.org
www.tto-ir.org
www.csro-iran.org www.tto.org
www.oic.un.org www.idro.org www.irantpcnet.com www.ncc.org.ir www.irrcs.org www.sanjedh.org www.iranprisons.org
www.tehran-gis.com
www.nigc.ir www.farhangnet.org www.nahad.net
www.ncsd.iran.org
www.radtel.or.ir
www.fcic.ir.org
balatarin.com
www.irna.ir
more
http://www.schoolnet.ir/~darolelm/urls.htm
more
the top
http://www.medianews.ir/fa/2009/05/01/iran-top-websites-1387.html
more
http://www.topshia.com/
Fuck all shia iran
(2010-01-15 00:16:43)