CobaltStrike去除流量特征

CobaltStrike去除流量特征

​普通CS没有做流量混淆会被防火墙拦住流量,所以偶尔会看到CS上线了机器但是进行任何操作都没有反应。这里尝试一下做流量混淆。参考网上的文章,大部分是两种方法,一种更改teamserver 里面与CS流量相关的内容,一种是利用Keytool工具生成新的store证书。而我们需要做的修改大概为3个地方:

1. 修改默认端口                                                                                                                                                                                                        
2. 去除store证书特征                                                                                                                                                                                                   
3. 修改profile                                                                                                                                                                                                     

0x00 关闭后台运行的CS

 ps -aux                                                                                                                                                                                                          
 找到CS相关的进程                                                                                                                                                                                                        
 kill -9 pid                                                                                                                                                                                                      

0x01 修改默认端口

编辑teamserver文件,更改server port部分 50433

vim teamserver                                                                                                                                                                                                   

image-20210311141032045

0x02 去除store证书特征

查看证书,默认密码123456

 keytool -list -v -keystore cobaltstrike.store                                                                                                                                                                    

可以看到未修改的证书还是有很明显的cs特征的,比如 Alias name Owner Issuer 字段

image-20210311141820651

而Keytool是一个Java的证书管理工具,下面用Keytool生成一个store证书。

keytool -h                                                                                                                                                                                                       
Illegal option:  -h                                                                                                                                                                                              
ey and Certificate Management Tool                                                                                                                                                                              


Commands:                                                                                                                                                                                                        

-certreq            Generates a certificate request                                                                                                                                                              

-changealias        Changes an entry's alias                                                                                                                                                                     

-delete             Deletes an entry                                                                                                                                                                             

-exportcert         Exports certificate                                                                                                                                                                          

-genkeypair         Generates a key pair                                                                                                                                                                         

-genseckey          Generates a secret key                                                                                                                                                                       

-gencert            Generates certificate from a certificate request                                                                                                                                             

-importcert         Imports a certificate or a certificate chain                                                                                                                                                 

-importpass         Imports a password                                                                                                                                                                           

-importkeystore     Imports one or all entries from another keystore                                                                                                                                             

-keypasswd          Changes the key password of an entry                                                                                                                                                         

-list               Lists entries in a keystore                                                                                                                                                                  

-printcert          Prints the content of a certificate                                                                                                                                                          

-printcertreq       Prints the content of a certificate request                                                                                                                                                  

-printcrl           Prints the content of a CRL file                                                                                                                                                             

-storepasswd        Changes the store password of a keystore                                                                                                                                                     

使用以下命令生成一个新的store证书,-alias-dname 可以自由发挥,也可以用其他的来混淆流量。

                                                                                                                                                                                                             
keytool -keystore CobaltStrikepro.store -storepass 123456 -keypass 123456 -genkey -keyalg RSA -alias Microsec.com -dname "CN=Microsec e-Szigno Root CA, OU=e-Szigno CA, O=Microsec Ltd., L=Budapest, S=HU, C=HU" 
                                                                                                                                                                                                             

参数               含义    
    
`-alias`          指定别名
`-storepass`      指定更改密钥库的存储口令
`‐keypass pass`   指定更改条目的密钥口令
`-keyalg`         指定算法
`-dname`          指定所有者信息                                                                                                                                                                                    

新生成的证书看着就很nice

image-20210311143223559

当然也可以编辑 teamserver 文件来生成证书

image-20210311143353621

0x03 Malleable-C2-Profiles

因为现在很多WAF都能检测出CS的流量特征,而CS的流量由Malleable C2配置来掌控的,所以我们需要定向去配置这个Malleable-C2

Beacon与teamserver端c2的通信逻辑

1.stager的beacon会先下载完整的payload执行                                                                                                                                                                                  
2.beacon进入睡眠状态,结束睡眠状态后用 http-get方式 发送一个metadata(具体发送细节可以在malleable_profie文件里的http-get模块进行自定义),metadata内容大概是目标系统的版本,当前用户等信息给teamserver端 。                                                                         |
3.如果存在待执行的任务,则teamserver上的c2会响应这个metadata发布命令。beacon将会收到具体会话内容与一个任务id。                                                                                                                                           
4.执行完毕后beacon将回显数据与任务id用post方式发送回team server端的C2(细节可以在malleable_profile文件中的http-post部分进行自定义),然后又会回到睡眠状态。                                                                                                         

首先需要先下载profile文件

 git clone https://github.com/rsmudge/Malleable-C2-Profiles.git                                                                                                                                                   

CS中集成了一个包含在Linux平台下的C2lint工具,可以检查profile代码是否有问题

chmod 777 c2lint
./c2lint ./Malleable-C2-Profiles/APT/havex.profile

之后改一下profile的内容就好了网上有很多例子,我这里简单改了下。

因为0.0.0.0是Cobalt Strike DNS Beacon特征,可以在profile内加一段 set dns_idle "8.8.8.8"; 之后profile内默认的能改则改。

image-20210311152404107

http-get部分,包括uri和header都可以根据实战抓包进行修改。

image-20210311152545164

Reference

https://www.adminxe.com/1489.html

https://www.chabug.org/web/832.html

https://paper.seebug.org/1349/

https://blog.csdn.net/shuteer_xu/article/details/110508415

所有内容仅限于维护网络安全学习参考
原文地址:https://www.cnblogs.com/Zh1z3ven/p/14518441.html