0x01 前言
從某群的故事改編而來,都是些老套路各位看官看得高興就好;第一次在i春秋發帖有點緊張,如果有什么不周到的地方請去打死阿甫哥哥。你沒聽錯,阿甫哥哥推薦。
0x02 什么是任意文件下載
說到文件下載各位童鞋都不陌生(老司機請跳過),我們要下載網站上某個文件(.zip、.doc、.pdf)直接請求這個文件即可格式一般為:域名+相對路徑+文件名,如http://www.test.com/downlad/test.zip。而在網站上下載文件一般分為兩種,一種就是剛才所說的直接請求某個文件,還有一種就是網站運營者提供了一個下載腳我們只需要請求:http://www.test.com/download.php?filename=test.zip(文件名)這樣的url也可以下載文件。
眾所周知,我們請求一個網站上的腳本文件(這里以php為例)是不會被下載的,如:http://www.test.com/test.php。那任意文件下載是怎么造成的呢?這里就是上面說到的第二種情況了,網站運營者提供了http://www.test.com/download.php?filename=test.zip這樣一個連接本意是想訪問者下載test.zip文件,但是沒有做好安全措施導致任意文件下載。 舉個栗子:
測試環境(phpstudy):windows7+php-5.5.38+apache
一個任意文件下載腳本test.php,代碼如下:
<?phpif(empty($_GET['filename'])){ echo 'i春秋任意文件下載測試~'."<br>請輸入需要下載的文件名";}else{ $filename = $_GET['filename']; $fileinfo = pathinfo($filename); header('Content-type: application/x-'.$fileinfo['extension']); header('Content-Disposition: attachment; filename='.$fileinfo[' name']); header('Content-Length: '.filesize($filename)); readfile($filename); exit(); }?>
直接訪問該文件,文件并沒有被下載而是解析了其中的代碼
在網站根目錄下新建一個文件夾inc并新建一個名為ichunqiu.php的文件
現在來嘗試下載該文件,訪問:http://127.0.0.1/test/test.php?filename=/inc/ichunqiu.php成功下載該文件
0x03 某集團任意文件下載
之前挖某集團的漏洞時發現一個任意文件下載,兩個思路:①下載源碼審計-發現漏洞-利用;②下載數據庫文件-如果支持外聯-登錄后臺-嘗試getshell,這里我選擇了第二種。
首先下載了index.php文件,代碼如下:
<?define('IN_W3CWEB',true);require(dirname(__FILE__) . '/include/global.php'); @header("Content-type: text/html; charset=utf-8"); InitGP(array("action","do","gid","id")); $smarty->assign("pagetag","about"); $smarty->assign("page ","index");$lng=isset($_GET['lng']) && $_GET['lng']=='en'?'en':'cn';$sql="select * from $table_article where channel='1' and cat_id in(38,39)order by show_style desc,art_addtime desc limit 6 ";if($array=$DB->GetAll($sql)){ //print_r($row); $smarty->assign("article_index",$array); }//print_r($GLOBALS);/*seo*/$seo_ =""; $seo_keywords =""; $seo_de ion =""; seo_print();//print_r($_COOKIE);$smarty->assign("action",$action);$tpl="cn/index.html";$smarty->display($tpl);//print_r($GLOBALS);?>
新聞熱點
疑難解答