Cobalt Strike的配置文件講解
簡介
Beacon是Cobalt Strike為高級攻擊者建模的Payload。使用Beacon通過HTTP,HTTPS或DNS出口網絡。而且Beacon非常靈活,支持異步和交互式通信。異步通信既低又慢。Beacon將通訊本地,下載任務,然后進入睡眠狀態。交互式通信實時發生。
cobalt Strike 的Beacon(信標)的一些Http特征信息可以由C2配置文件進行修改和定制化,所以可定制的C2配置文件可以指定服務端如何發送,接受數據的規律和格式,防止被WAF,IDS對流量進行識別導致被發現。
可以在啟動cs服務端的時候,指定一個配置文件進行加載
./teamserver [external IP] [password] [/path/to/my.profile]
配置文件詳解
檢查配置文件
cobalt Strike提供了一個小程序C2lint,用來檢查你編寫的配置文件是否是可用的,是否有錯誤,這個程序會檢查你的語法是否正確,並且會生成一個簡單的交互過程讓你預覽,cobalt Strike強烈推薦你在正式使用之前用這個小程序來檢查一下。
./c2lint [/path/to/my.profile]
編寫配置文件
編寫一個配置文件最好的方式就是根據現有的配置文件進行修改,現在提供一個github上面的C2-Profiles例子:
https://github.com/rsmudge/Malleable-C2-Profiles
可以看到配置文件大概長這樣:
set global_option "value";
protocol-transaction {
set local_option "value";
client {
# customize client indicators
}
server {
# customize server indicators
}
}
所有的配置信息都是寫在{}
大括號里面。
例如:
http-get {
set uri "/fengxuan";
client {
metadata {
base64;
prepend "user=";
header "Cookie";
}
}
}
這個配置定義了在HTTP協議中Get請求的傳輸,第一句set uri
, 表示,在當請求/fengxuan
這個URL的時候,會執行以下的配置。
那么整段配置是什么意思呢?
就是在請求/fengxuan
這個地址的時候,http header中的 user字段里面的內容會進行base64加密然后再進行傳輸,從這個地址接受的返回包,http header中的 user字段會進行base64解密。
數據傳輸的標記語法
Statement | Action | Inverse |
---|---|---|
append "string" | 追加"string"參數 | 去除strings參數的字符串 |
base64 | Base64 編碼 | Base64 解碼 |
base64url | 對url進行Base64 編碼 | 對url進行Base64 解碼 |
mask | XOR mask w/ random key | XOR mask w/ same random key |
netbios | NetBIOS 編碼 | NetBIOS 解碼 |
netbiosu | NetBIOS 編碼(大寫) | NetBIOS 解碼(大寫) |
prepend "string" | 添加"string"參數 | 去除strings參數的字符串 |
對標記語法處理的四種方式
Statement | What |
---|---|
header "header" | 把編碼過后的參數作用於header中 |
parameter "key" | 把編碼過后的參數作用於URL參數中 |
把編碼過后的參數作用於POST方式中的body中 | |
uri-append | 將編碼過后的參數追加到URL中 |
其他的選項
Option | Context | Default Value | Changes |
---|---|---|---|
data_jitter | 0 | 向http get和http post服務器輸出中附加隨機長度字符串(取決於data_jitter的值)。 | |
dns_idle | 0.0.0.0 | 用於采用DNS信標時的ip地址 | |
dns_max_txt | 252 | 最大的 DNS TXT 返回的長度 | |
dns_sleep | 0 | 在每個dns請求之前的休眠時間. (毫秒值) | |
dns_stager_prepend | Prepend text to payload stage delivered to DNS TXT record stager | ||
dns_stager_subhost | .stage.123456. | DNS TXT記錄階段使用的子域名。 | |
dns_ttl | 1 | DNS的TTL值 | |
headers_remove | 在客戶端請求中去掉的header值 | ||
host_stage | true | Host payload for staging over HTTP, HTTPS, or DNS. Required by stagers. | |
jitter | 0 | 默認增加的隨機值的比例(0-99%) | |
maxdns | 255 | 上傳數據時最大的DNS主機名 | |
pipename | msagent_## | 使用SMB信標時點對點的名稱 | |
pipename_stager | status_## | Name of pipe to use for SMB Beacon's named pipe stager. Each # is replaced with a random hex value. | |
sample_name | My Profile | The name of this profile (used in the Indicators of Compromise report) | |
sleeptime | 60000 | 默認休眠時間(毫秒值) | |
smb_frame_header | Prepend header to SMB Beacon messages | ||
ssh_banner | Cobalt Strike 4.2 | SSH client banner | |
ssh_pipename | postex_ssh_#### | Name of pipe for SSH sessions. Each # is replaced with a random hex value. | |
tcp_frame_header | Prepend header to TCP Beacon messages | ||
tcp_port | 4444 | TCP Beacon listen port | |
uri | http-get, http-post | [required option] | 交互時候的URI地址 |
uri_x86 | http-stager | x86 payload stage URI | |
uri_x64 | http-stager | x64 payload stage URI | |
useragent | Internet Explorer (Random) | 默認的User-Agent | |
verb | http-get, http-post | GET, POST | 傳輸的請求協議 |
編寫好的配置文件模板
#
# Etumbot Profile
# http://www.arbornetworks.com/asert/2014/06/illuminating-the-etumbot-apt-backdoor/
#
# Author: @harmj0y
#
set sample_name "Etumbot";
set sleeptime "5000";
set jitter "0";
set maxdns "255";
set useragent "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/5.0)";
http-get {
set uri "/image/";
client {
header "Accept" "text/html,application/xhtml+xml,application/xml;q=0.9,*/*l;q=0.8";
header "Referer" "http://www.google.com";
header "Pragma" "no-cache";
header "Cache-Control" "no-cache";
metadata {
netbios;
append "-.jpg";
uri-append;
}
}
server {
header "Content-Type" "img/jpg";
header "Server" "Microsoft-IIS/6.0";
header "X-Powered-By" "ASP.NET";
output {
base64;
print;
}
}
}
http-post {
set uri "/history/";
client {
header "Content-Type" "application/octet-stream";
header "Referer" "http://www.google.com";
header "Pragma" "no-cache";
header "Cache-Control" "no-cache";
id {
netbiosu;
append ".asp";
uri-append;
}
output {
base64;
print;
}
}
server {
header "Content-Type" "img/jpg";
header "Server" "Microsoft-IIS/6.0";
header "X-Powered-By" "ASP.NET";
output {
base64;
print;
}
}
}
c2lint檢查
這個過程可以檢查並且預覽交互過程
注意:有些警告,這個警告有時候會影響運行,不過大多數都不會。
實戰
啟動服務進行攻擊
啟動服務並且加載我們的配置文件
獲取權限
WireShark分析流量
分析get流量
分析post流量
總結
cobalt strike 的配置文件可以進行高級定制化的攻擊,有效防止WAF,和IDS的追查。可以達到長期的維持訪問,在APT攻擊中還是比較重要的。
如果圖文看不懂可以看視頻