一、中国菜刀(Cknife)完整实战数据包 + 解码示例
1. 真实交互 POST 包
http
POST /test.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Accept: */*
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 32
z0=Y3htZCAgL2Jpbi9iYXNo
2. Base64 解码示例
Y3htZCAgL2Jpbi9iYXNo 解码 = cmd= /bin/bash
3. WAF 拦截规则示例(Nginx ModSecurity)
conf
SecRule ARGS_POST:z0 "@rx .+" "id:1001,deny,log,msg:'菜刀z0后门请求'"
4. Wireshark 过滤抓包实例
输入过滤表达式直接抓取菜刀流量:
plaintext
http.request.method == "POST" && http.request.body contains "z0"
二、蚁剑(AntSword)实战数据包 + 解码例子
1. 原生 Base64 模式数据包
http
POST /shell.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
Accept: */*
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Pragma: no-cache
Connection: keep-alive
Content-Length: 40
ant=bmV0c3RhdCAtYW4g
2. 解码
bmV0c3RhdCAtYW4g = netstat -an
3. ModSecurity 拦截规则
conf
SecRule ARGS_POST:ant "@rx .+" "id:1002,deny,log,msg:'蚁剑ant后门流量'"
4. Wireshark 过滤
plaintext
http.request.method == "POST" && http.request.body contains "ant"
三、冰蝎分版本完整实例
(1)冰蝎 2.0 握手 + 加密交互全套包
① GET 握手协商包
http
GET /shell.php?pass=123 HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0)
Accept: text/html, image/gif, image/jpeg, */*; q=.2
Cache-Control: no-cache
Pragma: no-cache
Connection: keep-alive
② 服务器响应密钥包(固定 16 位密钥)
http
HTTP/1.1 200 OK
Set-Cookie: PHPSESSID=abc123def456
Content-Length: 16
Content-Type: text/html
9f2ed7cc11a86429
9f2ed7cc11a86429 就是本次 AES 对称密钥
③ 后续加密 POST 包(无明文,纯 AES 密文)
http
POST /shell.php HTTP/1.1
Host: 127.0.0.1
Cookie: PHPSESSID=abc123def456
Accept: text/html, image/gif, image/jpeg, */*; q=.2
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 512
��û�Z�9�w�G�8������ # 二进制AES密文,无法直接解码
2.0 拦截规则
conf
SecRule REQUEST_URI "@contains pass=" "id:1003,deny,log,msg:'冰蝎2.0握手'"
(2)冰蝎 3.0 JSP 经典二进制包(面试高频样例)
http
POST /shell.jsp HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/10.0
Accept: application/json, text/javascript, */*; q=0.01
Content-Type: application/octet-stream
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 896
# 全段二进制AES密文,无任何参数名、无Base64
3.0 JSP 拦截规则
conf
SecRule REQUEST_CONTENT_TYPE "@streq application/octet-stream" "id:1004,deny,log,msg:'冰蝎3.0 JSP二进制后门'"
四、哥斯拉 God 斯拉实战样例
1. PHP 异或模式标准数据包
http
POST /shell.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Java/1.8.0_131
Accept: text/html, image/gif, image/jpeg, */*; q=.2
Content-Type: application/x-www-form-urlencoded
Connection: close
Content-Length: 620
pass=7s92kdLw09sdfJ29xc72sdk==
2. 核心识别点实例
- UA:Java/1.8.0_131 独有指纹
- 请求体必须带 pass=
- 连接头 Connection: close(短连接,和冰蝎 keep-alive 区分)
3. ModSecurity 拦截规则
conf
SecRule ARGS_POST:pass "@rx .+" "id:1005,deny,log,msg:'哥斯拉pass后门参数'"
SecRule REQUEST_HEADERS:User-Agent "@contains Java/" "id:1006,deny,chain"
SecRule ARGS_POST:pass "@rx .+"
4. Wireshark 精准过滤
plaintext
http.request.method == "POST" && http.user_agent contains "Java" && http.request.body contains "pass="
五、区分判断实操举例(面试口述标准答案例子)
例 1:抓到一条 POST 包,请求体 z0=xxxx
实操判断步骤:
例 2:POST 包内 ant=base64 字符串
步骤:
例 3:抓到 GET /shell.jsp?pass=456,响应长度 16
步骤:
例 4:POST /shell.jsp,Content-Type:application/octet-stream
步骤:
例 5:POST 包,UA 是 Java/1.8,body 里 pass=xxx,Connection:close
步骤:
六、加密强度实操对比例子
七、防火墙简单匹配拦截(Apache/Nginx 简易规则实例)
1. Nginx location 拦截
nginx
location ~* \\.php$ {
if ($request_body ~* "z0=") { return 403; }
if ($request_body ~* "ant=") { return 403; }
if ($request_uri ~* "pass=") { return 403; }
if ($http_user_agent ~* "Java/" && $request_body ~* "pass=") { return 403; }
if ($http_content_type ~* "octet-stream") { return 403; }
}
2. 安全设备(深信服 / 奇安信 SIP)特征库匹配实例
- 特征 1:POST 表单存在 z0 → 行为:阻断 + 告警【中国菜刀】
- 特征 2:POST 表单存在 ant → 阻断告警【蚁剑】
- 特征 3:URL 包含 pass = 数字 → 阻断告警【冰蝎 2.0 握手】
- 特征 4:请求头 Content-Type=application/octet-stream 且后缀 jsp → 阻断【冰蝎 3.0】
- 特征 5:UA 含 Java 且 POST 体含 pass → 阻断【哥斯拉】




