首页 > 网站 > 建站经验 > 正文

某集团任意文件下载到虚拟主机getshell的方法

2019-11-02 16:54:41
字体:
来源:转载
供稿:网友

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);?>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表