MaorSabag/NaX
GitHub: MaorSabag/NaX
NaX 是一款适配 Adaptix Framework 的自定义 C2 beacon,结合 PIC shellcode、module stomping 和多种规避技术,为红队提供隐蔽的后渗透执行能力。
Stars: 95 | Forks: 17
# NoNameAx (NaX)
面向 [Adaptix Framework](https://github.com/Adaptix-Framework/Adaptix) 的位置无关 C2 beacon,具备 module stomping、malleable C2 profiles、BOF 执行以及 Stardust 模式的 UDRL 加载器。




## 功能
- **PIC shellcode beacon** -- 单一 `.text` 段,无 CRT,无导入,所有 API 均通过 PEB walk 解析
- **Module stomping** -- beacon 运行于 image-backed DLL 内存 (IMG) 中,而非私有分配 (PRV)
- **干净的栈回溯** -- `.pdata`/`.xdata` 被填充至 DLL 中且具有正确的 RVA,LDR 条目使用完整的 PEB 标志进行了修补(ImageDll, LoadNotificationsSent, ProcessStaticImport, EntryProcessed)
- **感知 Control Flow Guard (CFG)** -- 在 runtime 查询 CFG 状态,将 beacon 入口(加载器)、BOF 的 go() 和 sleep_mask() 通过 SetProcessValidCallTargets 加入 CFG bitmap 的白名单;在启用了 CFG 的进程中安全运行
- **Malleable C2 profiles** -- 可配置的编码 pipeline(base64/hex/raw、XOR 掩码、body 模板、header/cookie/parameter 放置方式),支持 runtime 切换 profile
- **DLL 加载通知脱钩** -- 在启动时移除所有 `LdrRegisterDllNotification` 回调,防止 EDR 的 DLL 加载遥测;始终启用,也可在 runtime 通过 `dll-notify list/remove` 使用
- **BeaconGate + Sleepmask** -- 可扩展的 API 调用代理通过 sleepmask BOF(module-stomped, image-backed)路由 Sleep/WaitForSingleObject/WaitForMultipleObjects;附带了一个使用 `NtWaitForSingleObject` 替代 Sleep 的 WFSO PoC(基于虚拟事件)—— 您可以引入自己的睡眠混淆技术
- **BOF 执行** -- 具备 module stomping 的进程内 COFF 加载器(image-backed BOF .text,IFT .pdata 注入)
- **Stardust UDRL 加载器** -- 带有 TLS egghunter 全局变量和线程池执行的自重定位 PIC 加载器
- **TCP 隧道** -- 通过 beacon 进行 SOCKS4/5 代理、本地端口转发和反向端口转发,同时适用于 HTTP 和 SMB 传输
- **Token 操作** -- 窃取、模拟、基于凭据创建(4 种登录类型)、权限列表、控制台 header 更新
- **26 个内置命令** -- 文件 I/O、进程管理、token 操作、屏幕截图、下载、上传、SMB pivoting
- **AES-128-CBC 加密** -- 所有帧均通过 BCrypt 进行端到端加密
- **感知代理的传输** -- 带有自动代理检测 (PAC/WPAD) 的 WinHTTP
## 架构
```
+------------+ +----------------+ +--------------+ +-------+ +-------+
| UDRL | | NaxHeader v2 | | PIC Beacon | | .pdata| | .xdata|
| Loader | | (160 bytes) | | (.text) | | | | |
| Stardust | | magic, sizes | | NaxMain() | | RUNTM | | UNWIND|
| PEB walk | | flags, DLL | | + commands | | _FUNC | | _INFO |
| Mod stomp | | | | + transport | | | | |
+------------+ +----------------+ +--------------+ +-------+ +-------+
|
HTTP(S) / SMB
|
+---------------------------------------------------------------+
| Adaptix Framework Server |
| +------------------------+ +-----------------------------+ |
| | listener_nonameax_http | | agent_nonameax | |
| | Profile-driven HTTP |->| BuildPayload, CreateCommand| |
| | AES crypto, transforms | | ProcessData, AxScript UI | |
| +------------------------+ +-----------------------------+ |
+---------------------------------------------------------------+
```
## 快速开始
### 前置条件
```
sudo apt install gcc-mingw-w64-x86-64 nasm binutils golang python3
```
### 构建
```
make # Release build
make debug # Debug build (NaxDbg output)
make MODULE_STOMP=1 STOMP_PDATA=1 # Module stomping + unwind data
make MODULE_STOMP=1 STOMP_DLL=mshtml.dll # Custom sacrificial DLL
# Go server 插件
cd src_server/agent_nonameax && make
cd src_server/listener_nonameax_http && make
```
### 部署
1. 将 `.so` 插件复制到 `Server/extenders/`
2. 在 `Server/profile.yaml` 中注册
3. 启动 Adaptix,创建监听器,生成 payload
## 命令
| 命令 | 描述 |
|---------|-------------|
| `whoami` | 当前身份 (domain\user) |
| `sleep [jitter%]` | 设置回调间隔 |
| `sleepmask-set` | 发送 sleepmask BOF(连接时自动触发) |
| `ls`, `cd`, `pwd`, `mkdir`, `rmdir` | 目录导航 |
| `cat`, `rm`, `download`, `upload` | 文件操作 |
| `ps list`, `ps kill`, `ps run` | 进程管理 |
| `token getuid/steal/use/list/rm/revert/make/privs` | Token 操作与模拟 |
| `screenshot` | GDI 桌面捕获 |
| `bof [-a] ` | 执行 BOF(同步或异步) |
| `bof-stomp sync/async/show` | 重新配置 BOF 的 module stomping |
| `profile ` | 运行时切换 C2 profile |
| `link`, `unlink` | SMB pivot 管理 |
| `socks start/stop` | SOCKS4/5 代理(通过 Adaptix 隧道系统) |
| `lportfwd` / `rportfwd` | TCP 隧道转发(通过 Adaptix UI) |
| `terminate thread/process` | 退出 beacon |
## 文档
完整文档位于 [wiki/](wiki/) 文件夹中:
### 核心
- **[Beacon 架构](wiki/Beacon-Architecture.md)** -- NAX_INSTANCE、bootstrap、心跳循环、PIC 约束
- **[通信协议](wiki/Wire-Protocol.md)** -- 帧格式、消息类型、命令 ID、加密
- **[Malleable C2 Profiles](wiki/Malleable-C2-Profiles.md)** -- OutputConfig 编码 pipeline、profile JSON、runtime 切换
- **[Module Stomping](wiki/Module-Stomping.md)** -- Loader 阶段的 beacon stomping、DLL 选择、LDR 修补
### BOF 系统
- **[BOF 执行](wiki/BOF-Execution.md)** -- COFF 加载器、同步/异步分发、Beacon API 参考
- **[BOF Module Stomping](wiki/BOF-Module-Stomping.md)** -- Image-backed BOF .text、IFT .pdata 注入、slot 池
### 规避
- **[BeaconGate 与 Sleepmask](wiki/BeaconGate-Sleepmask.md)** -- API 调用代理、WFSO PoC sleepmask、可扩展的 gate 架构
### 后渗透
- **[Token 命令](wiki/Token-Commands.md)** -- Token 窃取、模拟、凭据登录、权限列表
### 网络
- **[隧道](wiki/Tunneling.md)** -- 本地/反向端口转发、通信协议、OPSEC、流控制
### 扩展 NaX
- **[添加命令](wiki/Adding-Commands.md)** -- 从 Wire.h 到 AxScript 的端到端演示
- **[Stardust 加载器指南](wiki/Stardust-Loader-Guide.md)** -- UDRL 架构、如何编写自己的加载器
### 操作
- **[构建与部署](wiki/Build-and-Deploy.md)** -- 前置条件、构建命令、Adaptix 设置
- **[操作指南](wiki/Operator-Reference.md)** -- 包含语法和示例的所有命令
## 项目结构
```
Makefile # Top-level: loader + beacon -> nax.x64.bin
src_beacon/ # PIC shellcode beacon (C, MinGW cross-compile)
include/ # Instance.h, Wire.h, Config.h, Macros.h, Bof.h
src/Core/ # Bootstrap, Ldr (PEB walk), Config, Crypto, Packer
src/Transport/ # Http.c (WinHTTP), HttpCodec.c, Smb.c
src/Commands/ # Dispatch + command handlers + Tunnel.c
src/Bof/ # COFF loader, Beacon API, module stomping
src_loader/ # Stardust UDRL loader
src/ # PreMain, Main, Ldr, Stomp, Pe, Exec, Entry.asm
src_sleepmask/ # Sleepmask BOF (COFF .o, loaded by beacon at runtime)
src/ # main.c (WFSO PoC — extend with your own technique)
include/ # Gate.h, Imports.h
src_server/ # Go plugins for Adaptix Framework
agent_nonameax/ # Agent extender (build, commands, results, AxScript)
listener_nonameax_http/ # HTTP listener (profile transforms, crypto)
profiles/ # Malleable C2 profile JSON files
scripts/ # Build scripts (pack_nax.py)
```
## 致谢
- [Adaptix Framework](https://github.com/Adaptix-Framework/Adaptix) -- C2 框架与操作控制台
- [Stardust](https://github.com/Cracked5pider/Stardust) -- 由 Paul Ungur 编写的 PIC 加载器模板
- [ZeroPoint Security](https://training.zeropointsecurity.co.uk/) -- UDRL 与 Sleepmask 课程
- [Kharon](https://github.com/Adaptix-Framework/Kharon) -- Adaptix agent 参考
标签:C2框架, DNS 反向解析, Gophish, Go语言, 免杀技术, 安全学习资源, 客户端加密, 日志审计, 暴力破解检测, 程序破解, 网络信息收集, 道德黑客