HackCert
Intermediate 10 min read May 25, 2026

Direct Syscalls: অ্যান্টিভাইরাস সিস্টেমকে পাশ কাটিয়ে অপারেটিং সিস্টেমের সাথে যোগাযোগ!

Direct Syscalls কীভাবে EDR এবং antivirus user-mode hook bypass করে এবং কর্পোরেট নিরাপত্তায় এর প্রভাব।

Imran Hossain Chowdhury
Offensive Security Specialist
share
Direct Syscalls: অ্যান্টিভাইরাস সিস্টেমকে পাশ কাটিয়ে অপারেটিং সিস্টেমের সাথে যোগাযোগ!
Overview

Windows operating system-এ যেকোনো application যখন একটি file খোলে, memory allocate করে, বা একটি process তৈরি করে— সব ক্ষেত্রেই শেষ পর্যন্ত একটি system call বা syscall execute হয়। এই syscall-গুলো user-mode এবং kernel-mode-এর মধ্যে boundary cross করার পথ। নিরাপত্তা সরঞ্জাম— Endpoint Detection and Response বা EDR এবং antivirus— এই boundary-তে hook বসিয়ে suspicious activity পর্যবেক্ষণ করে।

কিন্তু modern attacker এই hook-গুলোকে সম্পূর্ণভাবে এড়িয়ে যেতে শিখেছে। তারা user-mode-এর intermediary library skip করে সরাসরি kernel-এ syscall পাঠায়— এই কৌশলকে বলা হয় Direct Syscalls। ফলে EDR-এর pre-deployed hook সম্পূর্ণ bypass হয়ে যায়, এবং malicious operation নজরদারির বাইরে সম্পন্ন হয়। এই নিবন্ধে আমরা Direct Syscalls-এর প্রযুক্তিগত কাঠামো, এর offensive ব্যবহার, এবং defensive counter-measure বিশদভাবে আলোচনা করব।

মূল ধারণা

Windows operating system-এর architecture বুঝতে হবে প্রথমে। CPU দুটি প্রধান mode-এ কাজ করে— User Mode (Ring 3) এবং Kernel Mode (Ring 0)। User mode-এ application চলে; এদের সীমিত privilege এবং restricted memory access। Kernel mode-এ OS-এর core component চলে— device driver, scheduler, memory manager। Kernel-এর সব hardware এবং memory access।

User mode application-কে যখন kernel-এর কোনো সেবা প্রয়োজন— file open করা, network send করা, memory allocate করা— তখন সে syscall ব্যবহার করে। এই process-এর normal path বহুস্তরীয়। প্রথমে application Windows API (Win32 API) call করে— যেমন CreateFile, WriteFile, VirtualAlloc। এই API kernel32.dll-এ implemented।

Kernel32-এর function-গুলো আরো nিম্ন-স্তরের ntdll.dll-এর function call করে— যেমন NtCreateFile, NtWriteFile, NtAllocateVirtualMemory। এই Native API ntdll-এ implemented। এই function-গুলোতেই actual syscall transition হয়— x64-এ syscall instruction এবং x86-এ sysenter বা int 2e

syscall instruction execute হলে CPU kernel mode-এ switch করে এবং kernel-এর System Service Dispatch Table (SSDT)-এ lookup করে— syscall number-এর ভিত্তিতে সঠিক kernel function-এ jump করে। Kernel function কাজ সম্পন্ন করে user mode-এ return করে।

EDR এবং antivirus-এর নজরদারির প্রধান point হলো ntdll.dll-এর Nt* function। এরা সাধারণত এই function-গুলোতে inline hook বসায়— function-এর শুরুতে কয়েকটি instruction overwrite করে একটি jump instruction-এ replace করে, যা EDR-এর own analysis function-এ নিয়ে যায়। সেখানে context, parameter এবং caller information বিশ্লেষণ হয়, এবং তারপর প্রায়শই original function call করে।

Direct Syscalls-এর কৌশল

Direct Syscalls-এর মূল idea হলো ntdll-এর hooked function-কে সম্পূর্ণভাবে bypass করে সরাসরি syscall instruction execute করা। যেহেতু syscall instruction CPU-এর native instruction এবং kernel-এ direct transition করে, কোনো user-mode hook এটিকে intercept করতে পারে না।

এর জন্য attacker-কে কয়েকটি জিনিস জানতে হয়। প্রথমত, Syscall Number বা Service Service Number (SSN)। প্রতিটি Nt* function-এর জন্য Windows-এর specific syscall number থাকে। কিন্তু এই number Windows version-এর সাথে, এমনকি update-এর সাথে পরিবর্তিত হয়। Windows 10-এর 21H1 release-এ যে syscall number, 22H2-এ ভিন্ন হতে পারে।

দ্বিতীয়ত, একটি custom function যা parameter setup করে এবং syscall instruction execute করে। Assembly code-এ লেখা একটি ছোট stub— এটি প্রতিটি Nt* function-এর জন্য আলাদাভাবে তৈরি করা হয়।

প্রাথমিক approach-এ আক্রমণকারীরা hardcoded syscall number ব্যবহার করতেন। প্রতিটি Windows version-এর জন্য আলাদা list maintain করতে হতো। এটি error-prone এবং fragile।

পরবর্তী evolution— Hell's Gate। ২০২০ সালে Am0nsec এবং RtlMateusz-এর প্রকাশিত technique। Runtime-এ ntdll.dll থেকে syscall number dynamically extract করা। ntdll-এর Nt* function-এর shellcode pattern parse করে— mov r10, rcx; mov eax, <syscall_number>— এবং সেই syscall_number ব্যবহার করে। Hooked function-এও এই pattern intact থাকলে কাজ করে।

Halo's Gate— Hell's Gate-এর evolution। যদি target function hooked হয় (অর্থাৎ pattern detect হয় না), তাহলে neighboring unhooked function-এর syscall number থেকে calculate করে। ntdll-এর Nt* function syscall number সাধারণত sequential, তাই কাছের function থেকে offset হিসেব করে target-এর syscall number পাওয়া যায়।

Tartarus Gate— আরো advanced approach যা multiple verification করে এবং anti-anti-syscall defense detect করতে পারে।

Indirect Syscalls— সম্প্রতি জনপ্রিয় technique। Direct syscalls-এর সমস্যা হলো syscall instruction যদি আক্রমণকারীর code-এ থাকে (যেমন process memory-এর custom shellcode region-এ), সেটা suspicious। Indirect syscalls-এ আক্রমণকারী ntdll-এর legitimate syscall instruction-এর address খুঁজে বের করে এবং সেই address-এ jump করে। ফলে call stack normal দেখায়— শেষ frame ntdll-এ।

কেন এটি কার্যকর

User-mode hook-এর মৌলিক limitation হলো এগুলো user mode-এ থাকে এবং user mode application দ্বারা bypass করা সম্ভব। EDR vendor-রা এই সমস্যা জানেন, কিন্তু সম্পূর্ণ kernel-mode monitoring তৈরি করা— Windows Driver-এর মাধ্যমে— complex এবং unstable।

Modern EDR যেমন CrowdStrike, SentinelOne, Microsoft Defender for Endpoint, Carbon Black— সবাই কোনো না কোনো ধরনের user-mode hook ব্যবহার করে। তারা ntdll-এর প্রতিটি critical Nt* function-এ hook বসায়— NtAllocateVirtualMemory, NtWriteVirtualMemory, NtCreateThreadEx, NtMapViewOfSection, NtOpenProcess এই ধরনের API।

যখন একটি malware এই function call করে normal path-এ, EDR-এর hook code execute হয়। কিন্তু যদি malware সরাসরি syscall instruction execute করে, এই hook পুরোপুরি bypass হয়।

Microsoft-ও এই সমস্যা বুঝে। Windows-এ Event Tracing for Windows (ETW), Kernel Patch Protection (PatchGuard), Hypervisor-protected Code Integrity (HVCI), Control Flow Guard (CFG)— এই ধরনের defense layered। কিন্তু কোনোটিই syscall-level monitoring-এর সম্পূর্ণ বিকল্প নয়।

Offensive ব্যবহার

Red team এবং penetration tester Direct Syscalls ব্যবহার করেন EDR evasion-এর জন্য। Popular tool এবং framework:

SysWhispers (jthuraisamy)— SysWhispers, SysWhispers2, SysWhispers3— প্রতিটি Nt* function-এর জন্য syscall stub generator। C/Assembly code generate করে যা malware project-এ include করা যায়।

Inceptor (klezVirus)— shellcode-এ direct syscalls inject করার automated pipeline।

Hells Hall (kyxrec)— Hell's Gate, Halo's Gate এবং indirect syscalls combine করে।

Cobalt Strike Sleep Mask Kit— Cobalt Strike-এ syscall-based malleable C2 customization।

Maelstrom (h4wkst3r)— modern syscall framework।

Open source এই tool-গুলো red team work, malware development এবং academic research-এ ব্যবহৃত হয়। তবে এই same tool ম্যালিশিয়াস actor-রাও ব্যবহার করেন— Lazarus, APT29, এবং অনেক ransomware group-এর kit-এ syscall-based evasion দেখা গেছে।

বাস্তব ransomware-এ syscall-based injection-এর কয়েকটি উদাহরণ। BlackCat (ALPHV) ransomware modern syscall technique ব্যবহার করে। Conti-এর successor groups— Royal এবং Black Basta— SysWhispers-style code observe হয়েছে। Pegasus-এর Windows version-এ-ও sophisticated syscall usage দেখা গেছে।

Detection এবং Defense

Direct Syscalls detect করা challenging কিন্তু impossible নয়। কয়েকটি defensive approach:

Kernel Callback Function। Windows kernel API— PsSetCreateProcessNotifyRoutineEx, PsSetCreateThreadNotifyRoutine, PsSetLoadImageNotifyRoutine, CmRegisterCallbackEx, ObRegisterCallbacks— এসব kernel-mode callback-এ register করে। EDR এই callback-গুলোর মাধ্যমে process creation, thread creation, image load, registry access— monitor করে। এই monitoring user-mode bypass-নিরপেক্ষ।

Event Tracing for Windows (ETW)। Windows-এর built-in tracing facility। ETW-Ti (Threat Intelligence) provider— Microsoft-Windows-Threat-Intelligence— sensitive Nt* function-এর call trace করে। EDR এই data subscribe করে syscall-level visibility পেতে পারে।

কিন্তু advanced attacker ETW-Ti কেও bypass করার চেষ্টা করেন। ETW patching, provider disabling— এই counter-technique উদ্ভাবিত হয়েছে। Microsoft এই attack-এর বিরুদ্ধে continuously hardening করছে।

Hardware-Assisted Detection। Intel Processor Trace (IPT) এবং AMD-এর equivalent— processor-level instruction trace। EDR এই trace বিশ্লেষণ করে syscall-related anomaly শনাক্ত করতে পারে। কিন্তু performance overhead-এর কারণে full-time enabled রাখা impractical।

Stack Anomaly Detection। Direct syscall-এ call stack abnormal দেখায়— syscall instruction-এর caller সাধারণত ntdll-এ থাকে; যদি custom memory region-এ থাকে, suspicious। EDR call stack walk করে এই pattern শনাক্ত করতে পারে।

Memory Region Permission Analysis। Custom shellcode region সাধারণত RWX (read-write-execute) permission-এ থাকে, যা legitimate program-এ rare। RWX region থেকে syscall execute হলে high suspicion।

Unbacked Memory Execution। Code execution হচ্ছে এমন memory region থেকে যা কোনো file-এ backed না (যেমন legitimate DLL)— এটি একটি strong indicator of injected/malicious code।

Vectored Exception Handler (VEH) এবং Hardware Breakpoint। EDR syscall instruction-এ hardware breakpoint বসিয়ে প্রতিটি syscall intercept করতে পারে, কিন্তু performance impact বিশাল।

Defense-in-Depth Strategy

কোনো একক technique direct syscalls-এর বিরুদ্ধে complete protection দেয় না। Defense-in-depth প্রয়োজন:

Application Whitelisting— Microsoft AppLocker, WDAC (Windows Defender Application Control)। অননুমোদিত binary execute হতে দেওয়া হবে না। যদি malicious payload execute না করতে পারে, syscall করার সুযোগও পাবে না।

Memory Protection— DEP (Data Execution Prevention), ASLR, CFG, CET (Control-flow Enforcement Technology)। Modern processor এবং Windows feature যা memory corruption-based exploit ঠেকায়।

Behavioral Analytics। প্রতিটি syscall শনাক্ত না করেও— overall behavior pattern, file modification, network connection, registry change-এর correlation— anomaly শনাক্ত করতে পারে।

Threat Hunting। Reactive detection-এর পরিপূরক proactive hunting। Memory dump analysis-এ injected code search, anomalous module load detection, suspicious thread activity।

Patch Management। Windows update, EDR update, library update— সব up-to-date রাখা। নতুন detection capability নিয়মিত deploy হয়।

Network Segmentation। যদি একটি endpoint compromise হয়, lateral movement যাতে limit থাকে। East-west traffic monitoring।

Principle of Least Privilege। User account, service account-এর সর্বনিম্ন privilege। যদি malicious code execute হয়, তার capability সীমিত।

আক্রমণকারী এবং Defender-এর Arms Race

Direct Syscalls এবং তার counter-defense-এর মধ্যে একটি ongoing arms race। প্রতিটি নতুন evasion technique-এর সাথে নতুন detection method, এবং প্রতিটি detection-এর সাথে নতুন evasion।

Microsoft Defender for Endpoint, CrowdStrike Falcon, SentinelOne Singularity— এদের latest version-এ syscall-aware detection। AMSI (Antimalware Scan Interface) এবং ETW-Ti expansion।

আক্রমণকারীরা এর reply-এ AMSI bypass, ETW patching, এবং in-memory hooking-এর নতুন variation নিয়ে এসেছেন। PSExec-এর alternative tool, custom C2 framework, এবং memory-only execution— এই পরিবেশে evolved।

Cobalt Strike এবং তার আঘাতে fork— Brute Ratel C4, Sliver, Havoc— প্রতিটি modern syscall capability এবং OPSEC consideration যোগ করেছে।

আইনি এবং Ethical দিক

Direct Syscalls technique itself ম্যালিশিয়াস নয়। এটি legitimate red team operation, malware research, এবং defensive engineering-এ ব্যবহৃত। কিন্তু এই knowledge-এর misuse-এর সম্ভাবনাও আছে।

Responsible Disclosure principle এই space-এ গুরুত্বপূর্ণ। নতুন evasion technique-এর research published হওয়ার আগে relevant vendor-কে inform করা— যাতে তারা detection update করতে পারেন। Conference talk (DEF CON, Black Hat, OffensiveCon) এ technique disclose করার সময় ethical framework অনুসরণ করা হয়।

Tooling-এর open source release-এ trade-off আছে। SysWhispers public-ভাবে available— ম্যালিশিয়াস actor-রাও ব্যবহার করতে পারেন। কিন্তু defender-রাও এই tool থেকে শিখে detection improve করতে পারেন। Community consensus হলো— security through obscurity বেশিদিন কাজ করে না; transparency-ই overall security level বাড়ায়।

Key Takeaways

Direct Syscalls modern offensive security-র একটি advanced কৌশল যা পরিচয় করিয়ে দিয়েছে user-mode hook-এর fundamental limitation-এর সাথে। এটি একটি reminder— security একটি static state নয়, একটি continuous process। প্রতিটি new defensive technique-এর জন্য নতুন bypass আসে, এবং প্রতিটি bypass-এর জন্য নতুন detection আবশ্যক।

Defender-দের জন্য এই reality-র সাথে একাত্ম হওয়া অপরিহার্য। শুধু একটি EDR install করে assume করা যে protection complete— এটি একটি বিপজ্জনক mindset। Layered defense, continuous monitoring, threat hunting, এবং regular adversary simulation— এই সবই প্রয়োজন modern threat landscape-এ। Direct Syscalls-এর মতো advanced technique-এর সম্পর্কে জানা— developer, red teamer এবং defender— সবার জন্যই essential, কারণ এই knowledge ছাড়া আপনি না বুঝে যা হারিয়ে যাচ্ছে, সেটা রক্ষা করতে পারবেন না।

আপনার জ্ঞান যাচাই করতে প্রস্তুত? আজই HackCert-এ Direct Syscalls MCQ Quiz-টি দিন!

Related articles

back to all articles