Tylous/SourcePoint
GitHub: Tylous/SourcePoint
一款用 Go 编写的 Cobalt Strike 多态 C2 配置文件生成器,旨在通过流量伪装和行为混淆规避安全检测。
Stars: 1199 | Forks: 167
# SourcePoint
SourcePoint 是一个用 Go 语言编写的多态 C2 配置文件生成器,专为 Cobalt Strike C2 设计。SourcePoint 允许即时生成独特的 C2 配置文件,这有助于减少我们的威胁指标,并允许操作人员以最小的精力启动复杂的配置文件。这是通过广泛查阅[文章](https://www.cobaltstrike.com/help-malleable-c2)以及[补丁说明](https://www.cobaltstrike.com/releasenotes.txt)来识别关键功能和可修改特性而完成的。SourcePoint 的设计初衷是为了解决如何使我们的 C2 活动更难被检测的问题,重点在于从恶意 IoCs 转向可疑 IoCs。这里的目标是,如果我们的 IoCs 本质上不是恶意的,并且需要额外的研究才能发现其可疑性质,那么检测我们的 C2 就会变得更加困难。SourcePoint 包含许多不同的可配置选项供您选择以修改您的配置文件(在大多数情况下,如果留空,SourcePoint 会为您随机选择)。生成的配置文件会修改您 C2 的各个方面。该项目的目标不仅是帮助规避基于检测的控制,还有助于将 C2 流量和活动融入环境中,使该类活动难以被检测。
```
go install github.com/Tylous/SourcePoint
```
## 安装
```
$go get gopkg.in/yaml.v2
$go build SourcePoint.go
```
## 使用方法
```
#./SourcePoint -h
_____ ____ _ __
/ ___/____ __ _______________ / __ \____ (_)___ / /_
\__ \/ __ \/ / / / ___/ ___/ _ \/ /_/ / __ \/ / __ \/ __/
___/ / /_/ / /_/ / / / /__/ __/ ____/ /_/ / / / / / /_
/____/\____/\__,_/_/ \___/\___/_/ \____/_/_/ /_/\__/
(@Tyl0us)
Usage of ./SourcePoint:
-Allocation string
Minimum amount of memory to request for injected content (must be higher than 4096)
-BeaconGate string
Specify beacon gate options (All, Comms, Core, Cleanup) or specific APIs
-CDN string
CDN cookie name (typically used for AzureEdge profiles)
-CDN-Value string
CDN cookie value (typically used for AzureEdge profiles)
-Customuri string
The base URI for custom HTTP GET/POST profile - Cannot be used with CustomuriGET or CustomuriPOST
-CustomuriGET string
The base URI for custom HTTP GET profile - Must be used with CustomuriPOST
-CustomuriPOST string
The base URI for custom HTTP POST profile - Must be used with CustomuriGET
-Datajitter string
Appends a value to HTTP-Get and HTTP-Post server output (default "50")
-Forwarder
Enabled the X-forwarded-For header (Good for when your C2 is behind a redirector)
-Host string
Team server domain name
-Httplib string
Select the default HTTP Beacon library:
[*] wininet
[*] winhttp' (default "winhttp")
-Injector string
Select the preferred method to allocate memory in the remote process:
[*] VirtualAllocEx (Great for cross architecture i.e x86 -> x64 and x64->x86)
[*] NtMapViewOfSection (A more stealthly option, however fails over to VirtualAllocEx, generating more events when it does)
-Jitter string
Jitter percentage for beacon call home
-Keylogger string
Select the preferred method the beacon will use to log keystrokes:
[*] GetAsyncKeyState (Uses GetAsyncKeyState API (Separate DLL for x86/x64 process))
[*] SetWindowsHookEx (Uses SetWindowsHookEx API)
-Keystore string
SSL keystore name
-Metadata string
Specifies how to transform and embed metadata into the HTTP request:
[*] base64
[*] base64url
[*] netbios
[*] netbiosu (default "base64url")
-Outfile string
Name of output file
-PE_Clone string
PE file beacon will mimic (Use the number):
[1] ActivationManager.dll
[2] audioeng.dll
[3] AzureSettingSyncProvider.dll
[4] BingMaps.dll
[5] DIAGCPL.dll
[6] EDGEHTML.dll
[7] FILEMGMT.dll
[8] FIREWALLCONTROLPANEL.dll
[9] GPSVC.dll
[10] gpupvdev.dll
[11] libcrypto.dll
[12] srvcli.dll
[13] srvsvc.dll
[14] Windows.Storage.Search.dll
[15] Windows.System.Diagnostics.dll
[16] Windows.System.Launcher.dll
[17] Windows.System.SystemManagement.dll
[18] Windows.UI.BioFeedback.dll
[19] Windows.UI.BlockedShutdown.dll
[20] Windows.UI.Core.TextInput.DLL
[21] winsqlite3.dll
[22] WMNetMgr.DLL
[23] wwanapi.dll
[24] WWANSVC.DLL
[25] wow64win.dll
[26] wow64.dll
[27] ctiuser.dll (Carbon Black's DLL)
[28] InProcessClient.dll (SentinelOne's DLL)
[29] umppc.dll (CrowdStrike's DLL)
[30] CyMemDef64.dll (Cylance's DLL)
-Password string
SSL certificate password
-PostEX_Name string
File Post-Ex activities will spawn and inject into (Use the number):
[1] WerFault.exe
[2] WWAHost.exe
[3] choice.exe
[4] bootcfg.exe
[5] dtdump.exe
[6] expand.exe
[7] fsutil.exe
[8] gpupdate.exe
[9] gpresult.exe
[10] logman.exe
[11] mcbuilder.exe
[12] mtstocom.exe
[13] pcaui.exe
[14] powercfg.exe
[15] svchost.exe
-Profile string
HTTP GET/POST profile (Use the number):
[1] Windowsupdate
[2] Slack
[3] Gotomeeting
[4] Outlook.Live
[5] Safebrowsing [Cloudfront Compatible]
[6] AzureEdge [AzureEdge Compatible]
[7] Field-Keyword [Cloudfront Compatible]
[8] Custom (Used with ProfilePath)
-ProfilePath string
Path of custom HTTP GET/POST profile...
-Sleep string
Initial beacon sleep time
-Stage string
Disable host staging (Default: False) (default "false")
-Syscall string
Defines the ability to use direct/indirect system calls instead of the standard Windows API functions calls:
[*] None
[*] Direct
[*] Indirect (default "None")
-TasksDnsProxyMaxSize string
The maximum size (in bytes) of proxy data to transfer via the DNS communication channel at a check in
-TasksMaxSize string
The maximum size (in bytes) of task(s) and proxy data that can be transferred through a communication channel at a check in
-TasksProxyMaxSize string
The maximum size (in bytes) of proxy data to transfer via the communication channel at a check in
-ThreadSpoof
Sets post-ex DLLs to spawn threads with a spoofed start address. These are generated randomly (default true)
-Uri string
The number URIs a profile for beacons to choose from
-Useragent string
UserAgent string for the beacon to use (Leave blank to randomly select one):
[*] Win10Chrome
[*] Win10Edge
[*] Win10IE
[*] Win10
[*] Win6.3
[*] Linux
[*] Mac
-Yaml string
Path to the Yaml config file
```
## 重要提示
SourcePoint 主要自动化了配置文件的构建过程。了解这些配置文件中修改的所有功能非常重要。了解这些功能确实有助于提高您的成功率。
## 选项
虽然 SourcePoint 的帮助功能中描述了许多设置和功能,但每个配置文件中都内置了许多重要的功能,熟悉这些功能非常重要。这些功能包括:
### 全局选项
这部分配置文件修改 beacon 的运作方式。一些用于修改行为的功能包括:
* Host Stage - 允许团队服务器托管用于 HTTP、HTTPS、DNS 的分阶段 shellcode。如果启用此功能,任何发送带有特定值(如 `/9ZXq`)的 GET 请求的人也可以提取 shellcode
* Sleep - beacon 回连的时间长度
* Jitter - 在 beacon 回连时间上追加一个百分比
* Useragent - 传输 HTTP 和 HTTPS 流量时使用的 useragent 字符串。使用适当的 useragent 字符串有助于融入环境
* Data Jitter - 为所有 GET 和 POST 请求添加随机长度的字符串,以确保传入请求的长度不相同
* SMB Frame Header - 为 SMB beacon 消息添加标头值
* Pipename - 设置 beacon 用于通信的 SMB 管道名称
* Pipename Stager - 为 beacon 设置 SMB stager 的名称
* TCP Frame Header - 为 TCP beacon 消息添加标头值
* SSH Banner - 使用的 SSH 标语
* SSH Pipename - 用于 SSH 标语的名称
* HttpLib - library 属性允许用户指定配置文件生成的 beacon 所使用的默认库。该值可以是 "wininet" 或 "winhttp"
### 阶段
这部分配置文件控制如何将 beacon 加载到内存中并编辑 beacon DLL 的内容。一些用于修改行为的功能包括:
* Obfuscate - 混淆反射式 DLL 的导入表
* Stomppe - 要求 payload 在加载后清除 MZ、PE 和 e_lfanen 值
* Clean up - 告诉 beacon 释放与其初始化相关的反射式 DLL 的内存
* UseRWX - 确保 shellcode 不使用读取、写入、执行权限
* Magic_MZ - 使用另一个值覆盖 Beacon 反射式 DLL 的前几个字节(包括 MZ 标头)(目前仅适用于 x64)
* Magic_PE - 使用另一个值覆盖 Beacon 反射式加载器使用的 PE 字符标记
* Syscall - 定义使用系统调用而非标准 Windows API 函数的能力
* Smart Inject - 使用嵌入的函数指针提示来引导 beacon 代理,而无需遍历 kernel32 EAT
* Sleep Mask - TCP 和 SMB beacon 在等待连接建立时将在静态状态下自我混淆
* PE Header - 更改 beacon 反射式 DLL 的特征,使其在内存中看起来像其他东西
* Transformation - 通过移除或向 .rdata 添加字符串来转换 beacon 的反射式 DLL 阶段
### Process-Inject
这部分配置文件控制 beacon 如何塑造注入内容并控制进程注入行为。一些用于修改行为的功能包括:
* Allocator - 决定 beacon 的反射式加载器如何分配内存
* Minimum Allocation - 为注入内容请求的最小内存量
* Userwx - 确保 shellcode 不使用读取、写入、执行权限(替代方案是 RW)
* Startrwx - 对注入内容使用读取、写入、执行作为初始权限(替代方案是 RW)
* Transformer - 添加由 beacon 注入的一块填充内容
* Execute - 此部分决定如何执行注入的代码
### Post-Exec
这部分配置文件控制 beacon 如何处理后渗透模块和命令。一些用于修改行为的功能包括:
* Spawnto - 决定 beacon 为其后渗透命令和选项将生成的默认临时进程
* Obfuscate - 混淆反射式 DLL 的导入表
* Smart Inject - 将关键函数指针从 beacon 传递给其子作业
* AMSI disable - 为 powerpick、execute-assembly 和 psinject 禁用 AMSI(某些 EDR 可以检测到这一点,最好避免使用这些工具)
* Keylogger - 决定键盘记录 API 如何用于捕获击键
* Cleanup - 加载后渗透 DLL 时清理后渗透用户定义反射式 DLL ("UDRL") 内存
* Threadhint - 允许后渗透 DLL 生成具有伪造起始地址的线程
### 配置文件
目前 SourcePoint 为 HTTP/HTTPS 流量配置文件提供了 7 个内置选项,这些选项基于现有的配置文件。在这 6 个中,有 4 个受以下内容影响并基于:
* Microsoft Window's Update Communication
* Slack's Message Communication
* Gotomeeting's Active Meeting Communication
* Microsoft Outlook's Email Communication
其中 3 个配置文件选项(5、6 和 7)专为以下内容设计:
* Cloudfront.net
* AzureEdge.net
最后一个选项(8)旨在输入自定义配置文件。此选项旨在允许操作人员使用完全自定义的流量配置文件。在许多情况下,完全独特的流量配置文件会比这些配置文件产生更高的成功率。这也允许操作人员将 SourcePoint 的可塑性功能与他们常用或喜欢的流量配置文件结合使用。由于这允许生成独特的配置文件,因此务必调整和修改配置文件以确保 SourcePoint 正常工作。至少:
* 替换 - `header "Host" "acme.com";` 为 `header "Host" "{{.Variables.Host}}";`
* 替换 - GET 字段下的 `/pathtolegitpage/` 为 `{{.Variables.HTTP_GET_URI}}`
* 替换 - POST 字段下的 `/pathtolegitpage/` 为 `{{.Variables.HTTP_POST_URI}}`
为此,请使用以下选项 `-Customuri` 和 `-ProfilePath` 以及 `-Profile 8`。要为 GET 和 POST 使用不同的 URI 基础,应使用 `-CustomuriGET` 和 `-CustomuriPOST` 来代替 `-Customuri`。在开发配置文件时,强烈建议使用原生的 ./c2lint 来验证一切是否正常工作。
## 示例
通过将这些选项组合到一个配置文件中,您可以创建一个高效的 beacon,从而规避预防性和检测性控制。虽然这仍然是一场不断演变的猫捉老鼠游戏,但针对特定的安全堆栈组合正确的选项可能非常有效。
## 示例 Yaml 配置
```
Stage: "False"
Host: "acme-email.com"
Keystore: "acme-email.com.store"
Password: "Password"
Metadata: "netbios"
Injector: "VirtualAllocEx"
Outfile: "acme.profile"
PE_Clone: 20
Profile: 4
Allocation: 5312
Jitter: 30
Debug: true
Sleep: 35
Uri: 3
Useragent: "Mac"
Post-EX Processname: 11
Datajitter: 40
Keylogger: "SetWindowsHookEx"
Customuri:
CDN:
CDN_Value:
ProfilePath:
Syscall_method:
Httplib:
ThreadSpoof: true
Customuri:
CustomuriGET:
CustomuriPOST:
Forwarder: False
TasksMaxSize:
TasksProxyMaxSize:
TasksDnsProxyMaxSize:
```
## SSL 证书
配置文件模式 1-4 可以在没有有效 SSL 的情况下使用,SourcePoint 将生成与配置文件类型相关的自签名证书。但是,有效的 SSL 证书对于任何类型的 C2 的成功都极其重要。原因很多,但显然没有证书意味着流量将是未加密的(即 HTTP,这永远不应被使用),但使用自签名证书也有其明显的局限性。有许多方法可以获得有效的 SSL 证书来制作 keystore,我常用的方法是使用由 [Cham423](https://github.com/cham423/cs-tools) 创建的 [HTTPsC2DoneRight.sh](https://github.com/killswitch-GUI/CobaltStrike-ToolKit/blob/master/HTTPsC2DoneRight.sh) 的修改版本。
## DNS
目前,SourcePoint 不直接提供 DNS 自定义功能。为了仍然允许基于 dns 的 beacon,每个生成的配置文件中都有一段注释掉的 dns-beacon 部分。
## 待办事项列表
- [ ] 添加更多配置文件
- [ ] DNS 分阶段