sebafvs/wraith
GitHub: sebafvs/wraith
一个无 CRT 依赖的 x64 Windows 进程操控静态库,为攻击性安全工具提供间接 syscall、动态 API 解析和进程注入等底层原语。
Stars: 0 | Forks: 0
# Wraith SDK
**[文档](https://cyber.sebafvs.com/tools/wraith) · [快速入门](https://cyber.sebafvs.com/tools/wraith/getting-started) · [贡献指南](https://cyber.sebafvs.com/tools/wraith/contribution)**
Wraith 是一组用 C 语言编写的独立静态库,可供攻击性工具进行链接。它提供了用于进程枚举、远程内存驻留、线程控制、间接 syscall 调度和 payload 加密的底层原语,且不依赖 C 运行时,链接生成的二进制文件中也不会留下高级 API 的痕迹。
间接 syscall 后端通过 `ntdll.dll` 内部的 gadget 来路由 `syscall` 指令,而不是使用二进制文件自身的 `.text` 节。API 解析使用带有 32 位哈希标识符的 PEB/EAT 遍历,取代了 `GetProcAddress`。
## 库
| 库 | 用途 |
|---|---|
| `wraith_syscalls` | SW3 风格的间接 syscall 存根,20 个 `Zw*` 函数 |
| `wraith_evasion` | 通过 PEB 和 EAT 遍历进行动态函数解析 |
| `wraith_process` | 进程枚举、句柄操作、检查、token |
| `wraith_memory` | 虚拟内存分配 / 读取 / 写入 / 保护 / 节映射 |
| `wraith_thread` | 线程枚举、上下文操作、APC 队列 |
| `wraith_pe` | 内存中的 PE 解析器、头信息、节、导出、文件 I/O |
| `wraith_payload` | Payload 编码和加密原语 |
| `wraith_strategies` | 注入封装、经典、RWX(更多功能开发中) |
## 前置条件
- Windows 10/11 x64
- [LLVM/Clang](https://github.com/llvm/llvm-project/releases) 17+
- [Ninja](https://ninja-build.org/)
- CMake 3.20+
可选:Visual Studio 2022(用于 IDE 集成)。
## 构建
```
cd build
ninja
```
输出的库文件将位于 `build/` 目录中:
```
wraith_syscalls.lib wraith_evasion.lib wraith_pe.lib
wraith_thread.lib wraith_process.lib wraith_memory.lib
wraith_payload.lib wraith_strategies.lib
```
## 测试
```
.\tests\test_syscalls.exe # 50 assertions, indirect syscall backend
.\tests\test_thread.exe # 19 assertions, thread pillar
.\tests\test_pe.exe # 41 assertions, PE parser
.\tests\test_process.exe # 19 assertions, process pillar
.\tests\test_memory.exe # 21 assertions, memory pillar
.\tests\test_payload.exe # 3 assertions, payload XOR
```
在未经修改的构建版本中,所有 **153 项断言** 必须全部通过。
## 快速入门
### CMake
```
cmake_minimum_required(VERSION 3.20)
project(my_tool C)
set(WRAITH_ROOT "C:/path/to/wraith")
include_directories("${WRAITH_ROOT}/include")
link_directories("${WRAITH_ROOT}/build")
add_executable(my_tool main.c)
# 仅链接你使用的。依赖最多的放在最后。
target_link_libraries(my_tool PRIVATE
wraith_process
wraith_memory
wraith_thread
wraith_payload
wraith_pe
wraith_evasion
wraith_syscalls
kernel32
ntdll
)
```
### Visual Studio (MSVC)
Wraith 的 `.lib` 文件是使用 Clang 构建的,但遵循标准的 x64 ABI,MSVC 可以直接链接它们。
右键点击项目 → **属性**(设置配置: 所有配置 / 平台: x64):
| 属性页 | 字段 | 值 |
|---|---|---|
| C/C++ → 常规 | 附加包含目录 | `\include` |
| 链接器 → 常规 | 附加库目录 | `\build` |
| 链接器 → 输入 | 附加依赖项 | `wraith_process.lib; wraith_memory.lib; wraith_thread.lib; wraith_payload.lib; wraith_pe.lib; wraith_evasion.lib; wraith_syscalls.lib; ntdll.lib` |
### 最小示例
```
#include
#include
#include "wraith.h"
int main(void) {
// Initialise the indirect syscall backend before any memory operations.
W_RESULT r = w_sc_init();
if (W_FAIL(r)) return 1;
W_PROCESS_LIST list = {0};
r = w_enum_processes(&list);
if (W_FAIL(r)) return 1;
printf("Found %lu processes\n", list.count);
W_PROCESS_ENTRY entry = {0};
r = w_find_by_name(&list, L"notepad.exe", &entry);
w_free_process_list(&list);
if (W_FAIL(r)) return 1;
HANDLE hProc = NULL;
r = w_open_process(entry.pid, PROCESS_ALL_ACCESS, &hProc);
if (W_FAIL(r)) return 1;
PVOID remote = NULL;
r = w_alloc(hProc, 0x1000, &remote);
if (W_FAIL(r)) { w_close_handle(hProc); return 1; }
BYTE payload[] = {0x90, 0x90, 0xC3};
static const BYTE key[] = {0xDE, 0xAD, 0xBE, 0xEF};
w_xor_key(payload, sizeof(payload), key, sizeof(key));
w_xor_key(payload, sizeof(payload), key, sizeof(key));
r = w_write_exec(hProc, remote, payload, sizeof(payload));
if (W_FAIL(r)) w_free(hProc, remote);
w_close_handle(hProc);
return W_OK(r) ? 0 : 1;
}
```
## 发布版本
预构建的库归档文件附带在每个 [GitHub Release](../../releases) 中:
| 资产 | 内容 |
|---|---|
| `wraith-libs-vX.Y.Z.zip` | 所有 `.lib` 文件,无需从源码构建即可直接链接 |
| `Source code (zip/tar.gz)` | 由 GitHub 自动生成 |
## 文档
完整的 API 参考、技术原理解析和集成指南:
**https://cyber.sebafvs.com/tools/wraith**
## 许可证
[MIT + 安全研究免责声明](./LICENSE),可自由使用,欢迎标明出处,作者不对滥用行为负责。
*由 [@sebafvs](https://github.com/sebafvs) 构建*
标签:Awesome列表, Bash脚本, SSH蜜罐, Windows底层, XML 请求, 安全开发, 客户端加密, 端点可见性, 进程注入, 间接系统调用