1 730
💣 "Bypassing EDR Hooks with Reverse Engineering"
📌 چرا این بمبه؟
چون EDRها (مثل CrowdStrike SentinelOne ) برای شناسایی فعالیت مشکوک روی APIهای حساس (مثل CreateRemoteProcess, NtWriteVirtualMemory, NtOpenProcess) Inline Hook میزنن
این یعنی وقتی تو بدافزارت از این APIها استفاده کنی اول میری تو کد EDR → بعد تازه سیستمکال اصلی
🔎 ساختار :
فکر میکنی وقتی OpenProcess صدا میزنی واقعا داری مستقیماً با Windows حرف میزنی؟ نه!
اول میری تو تور EDR و اونجاست که همه چی لو میره
2 توضیح ساده:
EDR با Inline Hook
اولین چند بایت تابع رو با یه jmp به خودش عوض میکنه
مثال (شکل ساده):
; اصل تابع NtOpenProcess
mov eax, 23h mov edx, offset args syscall retبعد از Hook شدن 👇 jmp EDR_Handler بقیه کد بازنویسی شده 3 ترفند : مهندس معکوس با بررسی DLL (مثلا ntdll.dll) متوجه Hook میشه راه بایپس: مستقیما با syscall کار کنه یا ntdll clean copy لود کنه 4 نمونه کد (C + Inline ASM) :
__asm { mov eax, 0x23 ; NtOpenProcess syscall number mov edx, args syscall }👉 اینجا دیگه EDR هیچی نمیفهمه چون Hook فقط رو API سطح بالا بوده 🚨 Why EDR Hooking is a Problem EDRs (CrowdStrike, SentinelOne, Defender ATP, etc...) need visibility into sensitive APIs : CreateRemoteThread NtWriteVirtualMemory NtOpenProcess NtCreateSection They inline-hook these APIs : The first few bytes of the function (in ntdll.dll) are overwritten with a jmp into the EDR’s handler This means: whenever your malware (or tool) calls OpenProcess, you first land inside EDR code, not Windows So you think you’re talking to Windows → actually you’re talking to CrowdStrike first 🔎 Reverse Engineering View Disassembling hooked functions reveals this: Before hook clean ntdll :
mov eax, 23h ; syscall number NtOpenProcess mov edx, offset args syscall retAfter hook (with EDR) :
jmp EDR_Handler ; patched jump by EDR ; original bytes are gone⚡ Why bypassing hooks works Inline hooks live in user-mode DLLs (ntdll.dll, kernel32.dll) But the actual system call still exists in the kernel If you: 1 Call the syscall directly syscall instruction 2 Or load a clean, unhooked ntdll.dll (from disk or from a suspended process) → You skip the EDR trampoline and go straight to the kernel 🧑💻 Minimal Example (C + Inline ASM)
__asm { mov eax, 0x23 ; NtOpenProcess syscall number mov edx, args ; pointer to arguments struct syscall ; direct transition to kernel }👉 EDR hook is bypassed, because it only patched ntdll!NtOpenProcess, not the raw syscall 🎯 Why this is a bomb It exposes a fundamental design weakness in user-mode monitoring Reverse engineers can detect hooks by scanning DLLs (memcmp with clean disk copy) Attackers can patch back the original bytes or just issue syscalls directly EDR vendors try to move detection deeper kernel callbacks ETW hypervisor tricks but inline hooks are still everywhere
11 сент. 2025, 17:26

