BenjiTrapp/MostShittyEDR
GitHub: BenjiTrapp/MostShittyEDR
一个故意设计得非常脆弱的教育性 EDR Agent,帮助安全研究人员通过 20 项实践挑战学习端点检测机制及其绕过技术。
Stars: 1 | Forks: 0
# MostShittyEDR
### *世界上最故意设计得糟糕的端点检测与响应 Agent*
[](https://nim-lang.org/)
[](LICENSE)
[](https://www.microsoft.com/windows)
[](README.md)
**一个使用 Nim 构建的教育性 EDR Agent,旨在演示进程监控、检测技术及其绕过方法。**
[功能](#-features) • [快速开始](#quick-start) • [挑战](#-the-challenge) • [架构](#-architecture) • [检测方法](#-detection-methods-explained) • [EDR 解释](https://benjitrapp.github.io/MostShittyEDR/edr-explained/) • [资源](#-resources)
## 概述
**MostShittyEDR** 是一个故意设计得很弱的 EDR Agent,专为**安全研究**、**教育**和**红队训练**而设计。它实现了模拟真实 EDR 引擎的基础检测方法,但故意留下了针对特定绕过挑战的弱点.
## 功能
|
### 检测引擎
- **进程名称黑名单**
- 大小写敏感的精确匹配
- 12 个硬编码的工具名称
- 无路径或哈希验证
- **命令行分析**
- 关键词子字符串搜索
- 不支持去混淆
- 仅支持 ASCII 的 toLower
- **LSASS 转储检测**
- 工具名称 + 关键词双重匹配
- 很容易通过重命名来绕过
|
### 技术特性
- **进程监控**
- Toolhelp32 快照轮询
- 通过读取 PEB 获取命令行
- 支持 64 位进程
- **响应动作**
- 终止进程(可配置)
- 仅检测模式(--no-kill)
- 可调节的轮询间隔
- **详细日志**
- 带时间戳的输出
- 颜色分级的严重级别
- 逐步的检测追踪
|
## 快速开始
### 前置条件
```
# Windows 与 Nim 2.0+
winget install nim-lang.Nim
```
### 构建与运行
```
# 安装依赖并构建
make build
# 或者手动:
nimble install winim -y
nim c -d:release --opt:size -o:edr_agent.exe src/edr_agent.nim
# 运行 EDR agent (verbose mode)
.\edr_agent.exe --verbose
# 以 detection-only mode 运行(不终止进程)
.\edr_agent.exe --verbose --no-kill
# 设置自定义轮询间隔
.\edr_agent.exe --interval 1000
```
### 实验环境使用
```
# Terminal 1:启动 EDR agent
.\edr_agent.exe --verbose --no-kill
# Terminal 2:尝试在未被检测到的情况下执行命令
whoami # This WILL be detected
# 你能找到一种不会被检测到的方法吗?
```
## 挑战
### 已知漏洞
- :unlock: 大小写敏感的黑名单 (`Mimikatz.exe` != `mimikatz.exe`)
- :unlock: 没有命令行去混淆(插入符、环境变量、编码都可以绕过)
- :unlock: 侦察检测形同虚设(规则 3 会检测但会丢弃结果)
- :unlock: LSASS 规则需要双重匹配(重命名工具或省略 "lsass" 关键字)
- :unlock: 只监控 `powershell.exe`(不监控 `pwsh.exe`)
- :unlock: 空的哈希数据库(规则 6 没有任何条目)
- :unlock: 基于轮询的监控(扫描之间存在时间间隔)
- :unlock: 无现有进程分析(在 EDR 之前启动 = 隐形的)
**跨越 5 个类别的 20 项挑战,难度从简单到困难!**
## 示例输出
```
__ __ _ ___ _ _ _ _ ___ ___ ___
| \/ |___ ___| |_/ __| |_ (_) |_| |_ _ _ | __| \| _ \
| |\/| / _ (_-< _\__ \ ' \| | _| _| || | | _|| |) | /
|_| |_\___/__/\__|___/_||_|_|\__|\__|\_, | |___|___/|_|_\
|__/
The World's Most Intentionally Terrible EDR
"If you can't bypass this, you definitely need more practice"
Detection Rules:
[1] Process Name Blacklist (12 entries)
[2] Command Line Keywords (12 patterns)
[3] Recon Command Detection (13 commands) [WARN ONLY]
[4] LSASS Dump Detection (8 indicators)
[5] PowerShell Flag Analysis (8 flags)
[6] Hash-Based Detection (0 hashes) [EMPTY]
[14:23:01.337] Initial snapshot: 142 processes
[14:23:01.337] Monitoring for new processes... (Ctrl+C to stop)
============================================================
[14:23:05.841] [CRITICAL] Blacklisted process detected: mimikatz.exe
PID: 8472 | Image: mimikatz.exe
[ACTION] Terminating PID 8472
[+] Process terminated successfully
[14:23:12.105] [OK] chrome.exe (PID: 9104)
```
## 架构
### 检测流水线
```
New Process Detected (via Toolhelp32 polling)
|
+-> Rule 1: Process Name Blacklist --> KILL (case-sensitive!)
+-> Rule 2: Command Line Keywords --> KILL (no deobfuscation!)
+-> Rule 3: Recon Detection --> discard (never blocks!)
+-> Rule 4: LSASS Dump Detection --> KILL (needs both conditions!)
+-> Rule 5: PowerShell Analysis --> ALERT (only powershell.exe!)
+-> Rule 6: Hash Check --> discard (empty database!)
```
### 项目结构
```
MostShittyEDR/
├── src/
│ ├── edr_agent.nim # User-mode EDR agent (Nim)
│ └── driver/
│ └── driver.cpp # Kernel driver (C++, reference only)
├── _challenges/ # 20 bypass challenges
├── _solutions/ # Detailed solution walkthroughs
├── docs/ # Technical documentation
├── static/ # Logo and assets
├── _config.yml # GitHub Pages config
├── _layouts/ # Jekyll layouts
├── assets/css/ # Site styles
├── Makefile # Build automation
└── MostShittyEDR.nimble # Nim package config
```
## 检测方法详解
### 1. 进程名称黑名单
```
const blacklist = [
"mimikatz.exe", "rubeus.exe", "sharphound.exe",
"procdump.exe", "psexec.exe", "cobaltstrike.exe", ...
]
```
与静态列表进行大小写敏感的精确匹配。重命名 = 绕过。
### 2. 命令行关键字
```
const keywords = [
"sekurlsa", "kerberos::list", "invoke-mimikatz",
"dump", "hashdump", "lsass", ...
]
```
没有去混淆的子字符串搜索。插入符、环境变量和编码都可以绕过。
### 3. 侦察检测(安全演戏)
```
const reconCmds = ["whoami", "ipconfig", "netstat", "systeminfo", ...]
# 结果被 `discard` - 检测但从不阻断
```
触发了检测,但结果被丢弃了。纯粹是演戏。
### 4. LSASS 转储检测
```
# 需要同时满足两个条件:
# 1. Tool 名称匹配
# 2. Command line 包含 "lsass"
```
重命名工具或省略关键字,规则就会失效。
### 5. PowerShell 标志分析
```
# 仅检查名为 "powershell.exe" 的进程
# pwsh.exe、cmd.exe /c powershell 和 PowerShell ISE 是不可见的
```
### 6. 基于哈希的检测
```
const hashDB: seq[string] = @[] # Empty!
```
零条目。企业级的安全演戏。
## 挑战类别
| 类别 | 挑战 | 难度 | 目标 |
|----------|-----------|-----------|--------|
| **进程名称规避** | 01-04 | Easy | 规则 1 |
| **命令行混淆** | 05-09 | Easy-Medium | 规则 2, 3, 5 |
| **进程监控绕过** | 10-14 | Medium | 架构, 规则 4 |
| **执行规避** | 15-18 | Medium-Hard | 架构, 规则 5 |
| **高级绕过** | 19-20 | Easy-Hard | 架构, 规则 6 |
请参阅 [挑战浏览器](https://benjitrapp.github.io/MostShittyEDR/challenges/) 获取带有提示的完整描述,以及 [解决方案](https://benjitrapp.github.io/MostShittyEDR/solutions/) 获取详细的操作指南。
## 内核驱动(高级参考)
`src/driver/driver.cpp` 包含一个 Windows 内核驱动程序,提供:
- 通过 `PsSetCreateProcessNotifyRoutineEx` 实现进程创建/退出回调
- 通过 `PsSetCreateThreadNotifyRoutine` 实现线程创建/退出回调
- 通过 `ObRegisterCallbacks` 实现 LSASS 句柄保护
- 内核级的进程拦截规则
- 与用户态 Agent 的 IOCTL 通信
## 教育价值
本项目演示了:
- :white_check_mark: **EDR 架构** - Agent 模式、轮询、检测流水线
- :white_check_mark: **进程监控** - Toolhelp32 快照、读取 PEB
- :white_check_mark: **检测规则** - 黑名单、关键字、启发式、哈希
- :white_check_mark: **规则弱点** - 大小写敏感、缺少去混淆、时间间隔
- :white_check_mark: **规避技术** - 重命名、编码、时间、权限提升
- :white_check_mark: **内核态 vs 用户态** - 为什么用户态轮询从根本上受到限制
- :white_check_mark: **Nim 编程** - Windows API、进程操作、系统编程
## 资源
### EDR 内部原理
- [EDR 解释 (MostShittyEDR)](https://benjitrapp.github.io/MostShittyEDR/edr-explained/) - 真实的 EDR 是如何工作的
- [理解并攻击 EDR](https://benjitrapp.github.io/attacks/2024-08-21-edr-and-malware/) - 深入探讨 hooking、系统调用和内核绕过
- [EDR 绕过路线图](https://benjitrapp.github.io/attacks/2026-01-18-EDR-bypass-roadmap/) - 绕过 EDR 的策略方法
### 配套项目
- [MostShittyAV](https://github.com/BenjiTrapp/MostShittyAV) - AMSI 绕过配套实验环境
### Nim 语言
- [Nim 官方网站](https://nim-lang.org/)
- [Nim 文档](https://nim-lang.org/documentation.html)
- [winim 包](https://github.com/nickelc/winim) - Nim 的 Windows API 绑定
### 安全研究
- [MITRE ATT&CK - 防御规避](https://attack.mitre.org/tactics/TA0005/)
- [LOLBAS 项目](https://lolbas-project.github.io/) - Living Off The Land Binaries
## 许可证
本项目基于 MIT 许可证授权 - 详见 [LICENSE](LICENSE) 文件。
## :warning: 法律声明
**本工具仅供教育和研究目的使用。**
- :x: 请勿在您不拥有或未获得明确测试权限的系统上使用
- :x: 请勿用于恶意目的
- :x: 不能替代真正的端点安全
- :white_check_mark: 仅在受控的实验环境中使用
- :white_check_mark: 了解您所在司法管辖区适用的法律和法规
**作者对滥用本软件不承担任何责任。**
### 祝狩猎愉快!
*使用 Nim 为安全研究社区制作*
**[:star: 收藏本仓库](../../stargazers)** • **[:bug: 报告 Bug](../../issues)** • **[:bulb: 提出新功能](../../issues)**