Skip to content
Lidk1Public

About

Windows下的轻量化沙箱

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

SecBoxie

一套 Windows 沙箱原型,覆盖注入 / 存根劫持 / 系统调用重定向 / 文件过滤兜底 / 反对抗 / LLM 行为链研判 的完整链路。

架构

┌────────────────────────────────────────────────────────────────────────┐
│                             用户态 (Ring3)                              │
│                                                                        │
│  ┌────────────┐   注入      ┌─────────────────────────────────┐        │
│  │ SandBox.exe│ ─────────▶  │  被沙箱进程 (loaded Dll.dll)     │        │
│  └─────┬──────┘             │  ┌──────────────────────────┐   │        │
│        │ IPC/DeviceIoControl│  │ Trampoline (HookHelper)  │   │        │
│        │                    │  │ IpcHook / ObjectHook / ...│   │        │
│        │                    │  ├──────────────────────────┤   │        │
│        │                    │  │ ⭐ AntiEvasion 反对抗层  │   │        │
│        │                    │  │  · CpuidEvasion (VEH)    │   │        │
│        │                    │  │  · SysInfoEvasion        │   │        │
│        │                    │  │  · AntiDebugEvasion      │   │        │
│        │                    │  │  · TimeEvasion (虚拟时间)│   │        │
│        │                    │  └──────────────┬───────────┘   │        │
│        │                    └─────────────────┼───────────────┘        │
│        │                                     ▼                        │
│        │                        \\.\pipe\SecBoxie.AntiEvasion         │
│        │                                     │                        │
│        │                                     ▼                        │
│        │             ┌────────────────────────────────────────┐       │
│        │             │  ⭐ SecBoxie Agent (Python, ReAct)     │       │
│        │             │  · WindowCollector (滑动窗口 128/10s)   │       │
│        │             │  · ATT&CK RAG (FAISS + MiniLM)         │       │
│        │             │  · MCP: pe_static_analysis / iat_parse │       │
│        │             │  · LangChain-OpenAI tool loop          │       │
│        │             └───────────────┬────────────────────────┘       │
│        │                             │                                │
│        │           \\.\pipe\SecBoxie.Ring0Feedback (双向)             │
│        │                             │                                │
│        ▼                             ▼                                │
├────────────────────────────────────────────────────────────────────────┤
│                             内核态 (Ring0)                              │
│                                                                        │
│  ┌────────────────────┐        ┌───────────────────────────────┐      │
│  │ KSandBox 驱动       │        │ ⭐ SecBoxieMF Minifilter      │      │
│  │  · Syscall 劫持     │        │  · PreCreate: 规则匹配         │      │
│  │  · ProcessNotify    │        │  · 高风险落地 -> Agent 研判   │      │
│  │  · Object/File 隔离 │        │  · IoReplaceFileObjectName    │      │
│  └────────────────────┘        │  · RuleTable (下发 SEC_MF_RULE)│      │
│                                └───────────────────────────────┘      │
└────────────────────────────────────────────────────────────────────────┘

目录说明

目录 说明
Dll 用户态注入 DLL,包含 Trampoline / 各类 API Hook;⭐ AntiEvasion* 反对抗层
KSandBox 内核态主驱动:Syscall 劫持 / Process/Image Notify / Object 隔离
Minifilter ⭐ 新增:MiniFilter 文件过滤驱动兜底 + SandBox.exe 桥接层
SandBox 用户态主程序:注入调度 / IPC 管理
LowLevel 底层支持库
Agent ⭐ 新增:Python ReAct Agent (LangGraph + FAISS + MCP)
Test 测试工程

编译

用 Visual Studio 2022 + WDK 11 打开 SandBox.sln,包含以下工程:

  • SandBox (WinExe)
  • Dll (DynamicLibrary,输出 Dll.dll)
  • LowLevel (StaticLibrary)
  • KSandBox (WDM Driver)
  • SecBoxieMF (Minifilter Driver,⭐ 新增)
  • Test (Console)

运行 Agent

cd Agent
pip install -e .
export SECBOXIE_LLM_API_KEY=sk-...        # 或 OPENAI_API_KEY
python -m secboxie_agent

详见 Agent/README.md。

功能对照表

需求 实现位置
1. 抢占式注入 & 存根劫持 (LdrInitializeThunk + Detours-style Trampoline) SandBox/InjectHelper.cpp + Dll/Trampoline.cpp / HookHelper.cpp
2a. IPC & Nt* 参数替换重定向 Dll/IpcHook.cpp / Dll/ObjectHook.cpp / KSandBox/Syscall.c
2b. MiniFilter 文件过滤兜底 Minifilter/*
3. VEH + CPUID / 反调试 / 时间伪造 Dll/AntiEvasion*.cpp
4. ReAct Agent + ATT&CK RAG + MCP + 滑动窗口 + 反哺 Ring0 Agent/secboxie_agent/*

About

Windows下的轻量化沙箱

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages