# Implementing Memory Protection With Dep Aslr

> 实施内存保护机制，包括 DEP（数据执行防护）、ASLR（地址空间布局随机化）、 CFG（控制流防护）和其他漏洞利用缓解措施，以防御内存损坏攻击。适用于加固端点 以抵御缓冲区溢出利用、ROP 链和代码注入的场景。适用于涉及内存保护、漏洞利用缓解、 DEP、ASLR 或 CFG 配置的请求。

- Skill: `killvxk/implementing-memory-protection-with-dep-aslr` (Agent Skill, multi-file: 8 files)
- Install (CLI): `npx skillmds@latest add killvxk/implementing-memory-protection-with-dep-aslr`
- Raw SKILL.md: https://api.skillmd.com/api/skills/killvxk/implementing-memory-protection-with-dep-aslr/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: Apache-2.0
- Author: killvxk (https://skillmd.com/u/killvxk)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/killvxk/implementing-memory-protection-with-dep-aslr

---

# 使用 DEP 和 ASLR 实施内存保护

## 使用场景

在加固端点以抵御基于内存的漏洞利用时使用本技能，通过配置 DEP、ASLR、CFG 和 Windows Exploit Protection 实施系统级和应用程序级缓解措施。

## 操作流程

### 步骤 1：配置系统级缓解措施

```powershell
# 启用系统范围的 DEP（数据执行防护）
# 引导配置：OptIn（默认）、OptOut（推荐）、AlwaysOn
bcdedit /set nx AlwaysOn

# 验证 ASLR 状态（现代 Windows 默认启用）
Get-ProcessMitigation -System
# MandatoryASLR、BottomUpASLR、HighEntropyASLR 应为 ON

# 启用所有系统级缓解措施
Set-ProcessMitigation -System -Enable DEP,SEHOP,ForceRelocateImages,BottomUp,HighEntropy
```

### 步骤 2：配置应用程序级缓解措施

```powershell
# 加固高风险应用程序（浏览器、Office、PDF 阅读器）
Set-ProcessMitigation -Name "WINWORD.EXE" -Enable DEP,SEHOP,ForceRelocateImages,CFG,StrictHandle
Set-ProcessMitigation -Name "EXCEL.EXE" -Enable DEP,SEHOP,ForceRelocateImages,CFG,StrictHandle
Set-ProcessMitigation -Name "AcroRd32.exe" -Enable DEP,SEHOP,ForceRelocateImages,CFG
Set-ProcessMitigation -Name "chrome.exe" -Enable DEP,CFG,ForceRelocateImages
Set-ProcessMitigation -Name "msedge.exe" -Enable DEP,CFG,ForceRelocateImages

# 导出配置以供部署
Get-ProcessMitigation -RegistryConfigFilePath "C:\exploit_protection.xml"
# 通过 Intune 或 GPO 部署
```

### 步骤 3：通过 Intune/GPO 部署

```
Intune：端点安全 → 攻击面减少 → Exploit Protection
  导入 exploit_protection.xml 模板

GPO：计算机配置 → 管理模板 → Windows 组件
  → Windows Defender Exploit Guard → Exploit Protection
  → "使用通用的 Exploit Protection 设置" → 已启用
  → 指向网络共享上的 XML 文件
```

## 关键概念

| 术语 | 定义 |
|------|------|
| **DEP** | 将内存页面标记为不可执行，防止在数据区域执行 shellcode |
| **ASLR** | 随机化已加载模块的内存地址，以挫败硬编码的 ROP 小工具 |
| **CFG** | 在运行时验证间接调用目标，防止控制流劫持 |
| **SEHOP** | 验证 SEH 链完整性，防止基于 SEH 的漏洞利用 |

## 工具与系统
- **Windows Exploit Protection**：内置的逐进程缓解管理
- **EMET（旧版）**：增强缓解体验工具包（前身，现已弃用）
- **ProcessMitigations PowerShell**：Get/Set-ProcessMitigation cmdlet

## 常见误区
- **DEP 兼容性**：旧版 32 位应用程序在 DEP AlwaysOn 下可能崩溃。对例外情况使用 OptOut。
- **强制 ASLR 破坏应用程序**：某些应用程序不兼容 ASLR。在强制执行 ForceRelocateImages 前进行测试。
- **CFG 仅限编译时支持**：CFG 仅适用于使用 /guard:cf 编译的应用程序，无法追溯应用。

