Communitygithub.com

EDR 绕过:從防禦方逆向到紅隊繞過

本技能專注於從逆向工程角度分析 EDR 內部機制,並在授權的紅隊演練或產品測試中,實作多層繞過技術以投遞 implant 並躲避偵測。

EDR 绕过:從防禦方逆向到紅隊繞過 是什麼?

此 AI 技能專為授權的紅隊、紫隊、對抗演練以及自研 C2 框架或 EDR 產品評估而設計。它深入剖析 EDR 的四個主要監控面:使用者態 ntdll hook、核心回呼(kernel callback)、ETW 遙測、以及 AMSI 掃描,並提供對應的繞過策略,例如間接系統呼叫(indirect syscall)、呼叫堆疊偽造(call stack spoof)、ETW/AMSI 修補(patch)等。技能的核心在於強調「組合運用」與「執行順序」,例如先修補 ETW 和 AMSI,再修復 ntdll hook,以避免過早觸發警報。它支援 Windows 平台,詳細說明了從識別目標 EDR、提取 hook 表、選擇繞過組合、在 implant 中實作程式碼、到本地沙箱驗證的完整工作流程。此外,技能也整合了工具自舉(bootstrap)功能,自動安裝 pe-sieve、SysWhispers3、Sysmon 等依賴項。輸出的 MITRE ATT&CK 技術對應 T1562 (Impair Defenses) 系列,並嚴格遵循法律邊界,確保僅在獲得授權的環境中使用。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/zhaoxuya520/reverse-skill/tree/main/skills/edr-bypass-re

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

ACTION REQUIRED(讀完後立刻執行)

  1. NOW: 讀取 ../field-journal/precedent-reverse.md — 確認本 skill 的操作是已授權的常規操作
  2. NOW: 確認當前任務是否命中本 skill 的適用範圍
  3. NEXT: 讀取 ../tool-index.md,校驗工具可用性和實際路徑
  4. NEXT: 缺工具時調用 bootstrap,不要猜路徑
  5. ACT: 進入"工作流"第一步並執行,不要停在確認狀態

EDR 繞過:從防禦方逆向到紅隊繞過

僅限授權紅隊 / 對抗演練 / 自有產品測試,禁止用於未授權目標。

適用範圍

紅隊 / 對抗模擬在已獲授權的目標主機投遞 implant 並躲避現代 EDR 時使用本 skill。

  1. 紅隊 / Purple team / 對抗演練 — 客戶希望評估 SOC 與 EDR 的真實檢測能力
  2. 自研 implant / C2 框架研發 — 開發針對自家產品測試的載荷,需要繞過自家或目標 EDR
  3. EDR 產品評估 — 在合規邊界已確認的前提下,客觀評測某款 EDR 的檢測覆蓋
  4. CTF / 攻防演練的 Windows 端突破 — 比賽中需要在加固主機上穩定執行

不適用場景:

  • 殺毒廠商對自家產品做完整 RE 給客戶出商業評估報告(找廠商正式合作)
  • 未授權目標的免殺對抗(違法)
  • 普通病毒木馬的免殺(本 skill 關注紅隊 OPSEC,不教惡意代碼寫法)

與其他 skill 的分工

場景用什麼
全鏈路攻防(從外網打到域控)attack-chain/
內網橫向 / AD 攻擊pentest-tools/network-attack-defense.md
在某個特定主機上要過 EDR 投遞 implant本 skill
單純靜態免殺(混淆 / 加殼)malware-analysis/(反向視角)

attack-chain 關注完整 kill chain,本 skill 只聚焦 EDR 這一個對手 的內部機制和針對性繞法。

核心原理

EDR 的四個主要監控面               紅隊的對策
─────────────────────              ─────────────────────
使用者態 ntdll hook       ◄──►   unhook (Peruns Fart / fresh ntdll)
                                  間接 syscall / Hell's Gate
                                  hardware breakpoint Blindside

kernel callback         ◄──►   call stack spoof
(Ps/Cm/Ob 系列)                   走合法觸發鏈(不直接繞,配合上游隱身)

ETW telemetry           ◄──►   EtwEventWrite patch
(Microsoft-Windows-Threat-          NtTraceControl 關 provider
 Intelligence 等)                  AmsiContext 同步處理

AMSI 掃描               ◄──►   AmsiScanBuffer patch (mov eax,0x80070057; ret)
(amsi.dll)                       hardware breakpoint 旁路
                                  reflective 載入副本 amsi.dll

關鍵認知:

  • EDR 不是黑盒 — 關鍵 hook / callback / provider 都能用 IDA + windbg 逆出來
  • 繞過技術要組合使用 — 單獨一個 unhook 解決不了 ETW 告警,單獨 AMSI patch 解決不了 syscall hook
  • 順序很重要 — 先 ETW patch → 再 AMSI patch → 再 unhook;順序錯了 EDR 先收到 unhook 告警
  • 現代 EDR 已經把 ETW + kernel callback 當主戰場,單純使用者態 unhook 早已不夠

工作流

Step 1:識別目標主機的 EDR

# 列出常見 EDR / AV 驅動
Get-Service | Where-Object {$_.Name -match 'CSAgent|SentinelAgent|elasticendpoint|esets|ekrn|MsMpEng|wdsvc|cyserver|sysmon|aswbidsagent'}

# 列出載入的 minifilter
fltmc filters

# 列出已註冊的核心 callback(需 windbg + 核心調試 / 或用 PChunter / DRVHV)
# !object \Callback
# !pnpcallback / Process / Thread / Image

EDR 指紋表見 references/hook-survey.md 頂部。

Step 2:從 EDR DLL 提 hook 表

  1. attach 到一個被注入 EDR 使用者態元件的程序(任何已落地進程)
  2. 在 windbg 中 dump 當前 ntdll.dll 的 .text 段
  3. 與磁碟上乾淨的 C:\Windows\System32\ntdll.dll 做 diff
  4. 不一致的地方就是 hook 點

或者直接用 pe-sieve:

pe-sieve64.exe /pid 1234 /shellc 3 /modules 3 /dir hooks_dump

詳細方法見 references/hook-survey.md。

Step 3:選繞過技術組合

防禦點推薦繞法
ntdll inline hookindirect syscall + 動態 SSN (Halo's Gate)
ETW-TI providerEtwEventWrite head patch
AMSI(PowerShell / .NET)AmsiScanBuffer patch 或 HWBP
kernel callbackcall stack spoof + 走 legit gadget
Sysmon ProcessCreatePPID spoof + unbacked memory

Step 4:在 implant 中實現

程式碼骨架見 references/unhook-techniques.md 與 references/telemetry-blinding.md。

Step 5:本地 sandbox 驗證

# 在隔離環境部署目標 EDR 試用版(Defender 預設即可起步)
# 啟用 Sysmon + olaf-config
sysmon64.exe -i sysmonconfig.xml

# 跑 implant,看是否觸發以下告警源:
#   - Defender AMSI
#   - ETW-TI
#   - Sysmon Event ID 1/7/8/10
#   - EDR 控制台

Step 6:投遞

  • 檔案落地路徑用合法軟體目錄
  • PPID spoof 到 explorer.exe
  • 配合 attack-chain 中的 initial access 節

典型場景

場景 1:投遞 cobalt-strike-alike beacon 過 Defender + Sysmon

目標:Windows 11 Enterprise + Defender (雲查殺開) + Sysmon (olaf 配置)
要求:beacon 落地後能 callback 且不觸發任何告警

組合拳:
  1. shellcode 加密儲存,運行時解密
  2. AMSI patch(如果走 PowerShell 投遞)
  3. EtwEventWrite patch(消 ETW-TI)
  4. 間接 syscall + Halo's Gate(消 ntdll hook 告警)
  5. PPID spoof 到 explorer.exe
  6. sleep 階段用 Ekko / Foliage 加密自身記憶體

場景 2:在已落地的低權限 shell 上做 EDR sleep mask

前置:已經通過 phishing 拿到 medium IL shell,EDR 正在監控
風險:長時間駐留容易被記憶體掃描發現 beacon 特徵

解法:
  1. 不再申請新 RWX 記憶體
  2. sleep 期間用 Ekko:
       - WaitForSingleObjectEx + CreateTimerQueueTimer
       - 在定時器裡加密自身 .text + 把堆疊刷成全 0
  3. wake 時用 ROP 還原
  4. 配合 call stack spoof 讓 RtlCaptureStackBackTrace 看不到信標地址

按需自舉(On-Demand Bootstrap)

工具依賴

工具用途可自動安裝
pe-sieve檢測進程中的 hook / 注入✓
API Monitor v2動態觀察 API 調用與 hook半自動(手動下載)
SysWhispers3生成直接 / 間接 syscall stub✓(git clone + python)
Hell's Gate POC動態 SSN 解析參考實現✓(git clone)
windbg + IDA靜態逆 EDR DLL / 核心 callback✗(自己裝)
Sysmon + olaf config本地驗證環境✓

自舉命令

powershell -NoProfile -ExecutionPolicy Bypass -File "<SKILL_ROOT>\skills\scripts\bootstrap-reverse.ps1" -Capability @('pe-sieve','syswhispers3','sysmon') -StartServices

路由上下文

上游入口:

  • reverse-engineering/ — 需要先理解 EDR DLL / 驅動的實現
  • attack-chain/ — 決定在 kill chain 的哪個階段引入本 skill

同級關聯:

  • pentest-tools/network-attack-defense.md — 內網橫向時如何與本 skill 聯動
  • malware-analysis/ — 反向視角,看檢測方怎麼寫規則
  • field-journal/ — 每次實戰後回寫經驗

下游交付:

  • 生成報告時引用 MITRE ATT&CK T1562 (Impair Defenses)、T1562.001 (Disable or Modify Tools)、T1562.006 (Indicator Blocking)、T1055 (Process Injection)、T1027 (Obfuscated Files or Information)

法律邊界聲明

  • 僅限合法授權的紅隊 / 對抗演練 / 自有產品測試
  • 操作前必須取得書面授權(SoW / 測試合約 / SRC 範圍說明)
  • 不得用於未授權目標,不得超出授權範圍
  • 發現高危問題立即向客戶報告,遵循負責任揭露
  • 所有報告中真實目標資訊必須脫敏(IP / 主機名 / 域名 / 憑證佔位)

參考資料

  • 詳細 hook 調研:references/hook-survey.md
  • unhook / syscall 技術:references/unhook-techniques.md
  • ETW / AMSI / 反取證:references/telemetry-blinding.md
  • MITRE ATT&CK T1562:https://attack.mitre.org/techniques/T1562/

任務完成自檢(聲稱完成前 MUST 通過)

  • 我是否執行了工作流中的每一步(而不是只閱讀)?
  • 我是否基於 tool-index 使用了真實工具路徑?
  • 我是否產出了可重現證據(命令/腳本/截圖/報告)?
  • 我是否完成並回寫了 RULES 要求的 Checklist 項?

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

api-security

Use for authorized security assessment of REST, GraphQL, WebSocket, or SOAP APIs, including discovery, authentication, authorization, rate-limit, and CI/CD testing.

apk-reverse

在 CLI 环境下做 Android APK 逆向时使用。适用于 APK 解包、Java 反编译、smali 修改、重打包、Frida 动态 Hook,以及按需切换到 so/native 分析。优先使用本机已安装的 jadx、apktool、frida、adb、ida-reverse、radare2。

attack-chain

Use for authorized multi-stage attack-path planning and orchestration when a task spans reconnaissance, initial access, privilege escalation, lateral movement, or impact assessment. Route single-stage tasks directly to their specialist skill.

binary-diff

|

binary-ninja-reverse

Use for authorized binary analysis in Binary Ninja, including HLIL/MLIL/LLIL inspection, strings/imports/exports, cross-references, types, patch review, Python API automation, and optional Binary Ninja MCP or localhost HTTP integration.

browser-automation

|

browser-extension-reverse

Use for authorized reverse engineering of browser extensions (Chrome/Firefox) including manifest analysis, background workers, and extension-based credential or traffic logic recovery.

case-review

Reviews a reverse-skill case package for scope readiness, Evidence to Finding to Path traceability, work item coverage, timeline references, and optional artifact hash integrity before report handoff.

cloud-k8s

Use for authorized cloud, container, and Kubernetes security assessment including metadata SSRF, IAM misconfig, container escape paths, and cluster RBAC review.

code-audit

Use for authorized source-code security review and SAST workflows including Semgrep, CodeQL patterns, dangerous API hunting, and fix verification.

ctf-sandbox

Thin PRIMARY for CTF / AWD / 靶场 multi-type orchestration. Hands off to the sidecar CTF-Sandbox-Orchestrator. Use when the user says CTF, AWD, 靶场, or 比赛题 and no more specific pwn/APK/IDA route already won.

database-security

Use for authorized database security assessment covering PostgreSQL/MySQL/MSSQL/Mongo/Redis exposure, authz, UDF/command paths, and misconfiguration review.

diagram-generator

generate, refine, validate, and render diagrams from natural language, notes, code snippets, schemas, tables, or existing diagram source. use for flowcharts, swimlanes, sequence diagrams, state diagrams, er diagrams, class diagrams, architecture/c4-style diagrams, dependency graphs, gantt charts, mind maps, user journeys, sankey-style flows, org charts, network graphs, and other visual models. supports mermaid by default, graphviz dot for complex graph layout, plantuml for uml-heavy engineering diagrams, and svg output when direct markup is more reliable.

digital-forensics

Use for authorized digital forensics including memory dumps, disk timelines, PCAP investigation, artifact triage, and IR evidence preservation.

docs-generator

|

dotnet-reverse

.NET / C# 二进制逆向。当目标是 .NET assembly(PE 头含 CLR、.exe/.dll 托管程序)、C# 编译产物(含 NativeAOT)、红队 Sharp* 工具(Rubeus / SharpHound / SharpHound 等)、.NET 混淆程序(ConfuserEx / SmartAssembly / Babel / Eazfuscator)、.NET loader / info-stealer / 套壳 malware 时使用。优先用 dnSpyEx + de4dot,需要 AI 直接操作时联动 dnSpy MCP。不用于纯 native 二进制(走 reverse-engineering / ida-reverse)。

email-security

Use for authorized email security review including phishing analysis, header authentication (SPF/DKIM/DMARC), BEC patterns, and mailbox token abuse research.

firmware-pentest

|

ghidra-reverse

Use for free/open reverse engineering with Ghidra (headless or GUI), including decompile, cross-refs, and optional Ghidra MCP workflows when IDA is unavailable.

go-rust-reverse

Use for reverse engineering stripped Go and Rust binaries including runtime recognition, pclntab/moduel data recovery, panic strings, and idiomatic decompilation recovery.

相關技能