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
0x02 去除store證書特征
查看證書,默認密碼123456
keytool -list -v -keystore cobaltstrike.store
可以看到未修改的證書還是有很明顯的cs特征的,比如 Alias name
Owner
Issuer
字段
而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
當然也可以編輯 teamserver
文件來生成證書
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內默認的能改則改。
http-get部分,包括uri和header都可以根據實戰抓包進行修改。
Reference
https://www.adminxe.com/1489.html
https://www.chabug.org/web/832.html