HackCert
Intermediate 10 min read May 25, 2026

Indirect Syscalls: আধুনিক এন্ডপয়েন্ট সিকিউরিটি সিস্টেমকে ফাঁকি দেওয়ার অ্যাডভান্সড কৌশল!

Indirect syscall technique, EDR bypass কৌশল এবং আধুনিক offensive security operation-এ এর গুরুত্বপূর্ণ ভূমিকা।

Mohammad Saiful Islam
Red Team Operator
share
Indirect Syscalls: আধুনিক এন্ডপয়েন্ট সিকিউরিটি সিস্টেমকে ফাঁকি দেওয়ার অ্যাডভান্সড কৌশল!
Overview

আধুনিক offensive security-র জগতে EDR বা Endpoint Detection and Response সলিউশন red team operator-দের জন্য সবচেয়ে বড় বাধা হয়ে দাঁড়িয়েছে। CrowdStrike Falcon, SentinelOne, Microsoft Defender for Endpoint — এই সব সলিউশন এমনভাবে design করা হয়েছে যে তারা প্রতিটি critical system call পর্যবেক্ষণ করে এবং সন্দেহজনক pattern শনাক্ত করে। কয়েক বছর আগে user-mode API hooking-এর বিরুদ্ধে direct syscall একটি বিপ্লবী technique ছিল, কিন্তু EDR ইতোমধ্যে এই কৌশলের বিরুদ্ধে detection method develop করেছে। এর প্রতিক্রিয়ায় উদ্ভাবিত হয়েছে indirect syscall — একটি আরো sophisticated technique যা বর্তমান যুগের EDR evasion-এর জন্য essential।

এই বিস্তারিত আলোচনায় আমরা দেখব কীভাবে indirect syscall কাজ করে, কেন এটি direct syscall-এর চেয়ে শক্তিশালী, এবং responsible offensive security operation-এ এর ব্যবহার। এটি একটি advanced technical topic যেখানে Windows kernel internals এবং assembly programming-এর knowledge অপরিহার্য।

Syscall এবং EDR Detection-এর পটভূমি

প্রতিটি modern Windows application যখন kernel-এর সাথে interact করে — file open, network connection, memory allocation, process creation — তখন এটি ntdll.dll-এর Nt* function ব্যবহার করে। উদাহরণস্বরূপ, kernel32.dll!CreateFileW ultimately ntdll.dll!NtCreateFile-কে call করে, যা একটি syscall instruction-এর মাধ্যমে kernel-এ transition করে।

EDR সলিউশনগুলো এই path-এ multiple location-এ hook বসায়। সবচেয়ে common হলো user-mode hooking, যেখানে EDR ntdll-এর গুরুত্বপূর্ণ function-গুলোর শুরুতে inline hook বসায়। যখন কোনো process এই function call করে, control প্রথমে EDR-এর monitoring code-এ যায়, তারপর actual function-এ।

Direct syscall এই hook-কে bypass করার একটি কৌশল। ntdll-এর hooked function call না করে, malware সরাসরি syscall instruction execute করে। উদাহরণস্বরূপ:

mov eax, 0x55       ; NtCreateFile syscall number
mov r10, rcx
syscall
ret

এই code একটি stub হিসেবে কাজ করে যেটা ntdll-এর actual NtCreateFile function-কে replicate করে কিন্তু hooked path অতিক্রম করে।

কিন্তু EDR vendor-রা এই technique-এর বিরুদ্ধে adapt করেছে। তারা এখন detect করতে পারে যখন syscall instruction এমন একটি memory location থেকে execute হয় যা ntdll.dll-এর code section নয়। এটিই indirect syscall-এর উদ্ভাবনের পটভূমি।

Direct vs Indirect Syscall

Direct syscall-এর প্রধান problem হলো call stack এবং execution context। যখন syscall instruction unknown memory region থেকে execute হয়, EDR এর kernel callback এই anomaly catch করতে পারে। Threat intelligence stack walking-এর মাধ্যমে আক্রমণকারীর code-কে চিহ্নিত করতে পারে।

Indirect syscall এই problem solve করে syscall instruction-কে ntdll.dll-এর ভেতর-ই execute করে। অর্থাৎ আমরা ntdll-এর কোনো legitimate syscall instruction-এ jump করি, যা ব্যবহার করে আমাদের desired operation সম্পন্ন হয়।

পদ্ধতিগতভাবে এই কাজ এভাবে হয়:

  1. NTDLL থেকে syscall number resolve করি (টার্গেট API-এর জন্য)
  2. NTDLL-এ একটি বৈধ syscall instruction-এর address খুঁজে বের করি
  3. Argument register-এ সঠিক value সেট করি
  4. syscall number-কে EAX-এ load করি
  5. সেই legitimate syscall address-এ jump (jmp) করি

ফলাফল — call stack-এ ntdll-এর entry দেখা যায়, যা suspicion arouse করে না।

C-এর সাথে assembly mix করে একটি simplified indirect syscall stub এমন দেখতে পারে:

// Find syscall number and instruction address dynamically
DWORD ssn = GetSyscallNumber("NtAllocateVirtualMemory");
PVOID syscallAddr = GetSyscallInstructionAddress();

// Setup arguments and call
__asm {
    mov r10, rcx
    mov eax, ssn
    jmp [syscallAddr]
}

প্রকৃত implementation আরো জটিল কারণ Windows x64 calling convention এবং argument passing handle করতে হয়।

Syscall Number Resolution

Indirect syscall-এর প্রথম challenge হলো syscall number determine করা। এই number Windows version-এর সাথে পরিবর্তন হয়, তাই hardcoded value reliable নয়।

একটি জনপ্রিয় technique হলো Hell's Gate — এতে ntdll-এর export-এ থাকা প্রতিটি Nt* function-এর প্রথম bytes পরীক্ষা করে syscall number extract করা হয়। সাধারণত একটি Nt* function এভাবে শুরু হয়:

mov r10, rcx       ; 4C 8B D1
mov eax, XXX       ; B8 XX XX XX XX (XX XX XX XX is syscall number)
syscall            ; 0F 05
ret                ; C3

কিন্তু hooked function-এ এই pattern পরিবর্তিত থাকে, তাই Hell's Gate hooked function-এ ব্যর্থ হয়।

Halo's Gate এই সমস্যা সমাধান করে। যদি একটি function hooked থাকে, তবে এটি কাছাকাছি unhooked function-গুলো থেকে syscall number derive করে। যেহেতু syscall number সাধারণত sequential — neighbor function-এর number থেকে calculation করা যায়।

Tartarus' Gate Halo's Gate-এর further refinement, এটি আরো robust pattern matching ব্যবহার করে।

আধুনিক technique-এ SysWhispers3 framework-ও জনপ্রিয়। এটি compile-time-এ syscall stub generate করে যা runtime overhead কমায়।

Syscall Instruction Address Discovery

Indirect syscall-এর দ্বিতীয় challenge হলো ntdll-এ একটি valid syscall instruction-এর address খুঁজে বের করা। এর জন্য সাধারণত ntdll-এর code section scan করতে হয় byte pattern 0F 05 (syscall instruction)-এর জন্য।

PVOID FindSyscallInstruction(HMODULE hNtdll) {
    PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)hNtdll;
    PIMAGE_NT_HEADERS ntHeaders = (PIMAGE_NT_HEADERS)((BYTE*)hNtdll + dosHeader->e_lfanew);
    
    PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(ntHeaders);
    for (DWORD i = 0; i < ntHeaders->FileHeader.NumberOfSections; i++) {
        if (memcmp(section[i].Name, ".text", 5) == 0) {
            BYTE* codeStart = (BYTE*)hNtdll + section[i].VirtualAddress;
            DWORD codeSize = section[i].SizeOfRawData;
            
            for (DWORD j = 0; j < codeSize - 1; j++) {
                if (codeStart[j] == 0x0F && codeStart[j+1] == 0x05) {
                    return &codeStart[j];
                }
            }
        }
    }
    return NULL;
}

আরো sophisticated technique-এ একটি specific Nt* function-এর syscall instruction location ব্যবহার করা হয়। এতে call stack pattern আরো natural দেখায়।

EDR Evasion-এর প্রযুক্তিগত বিশ্লেষণ

কেন indirect syscall EDR-কে fool করতে পারে? এর উত্তর কয়েকটি technical detail-এ।

প্রথমত, kernel-side stack walk-এ ntdll-এর address visible থাকে। EDR যখন process করার আগে syscall-এর origin verify করে, এটি ntdll-কে legitimate code source হিসেবে accept করে।

দ্বিতীয়ত, user-mode hook bypass হয় কারণ আমরা hooked entry point use করছি না। যদিও আমরা ntdll-এর ভেতরে jump করছি, এটি function-এর ঐ অংশে যা hook-এর পরে।

তৃতীয়ত, return address spoofing-এর সাথে combined হলে detection আরো কঠিন হয়। কিছু advanced framework call stack-কে এমনভাবে manipulate করে যেন call একটি legitimate caller থেকে এসেছে।

কিন্তু indirect syscall ১০০% undetectable নয়। আধুনিক EDR কয়েকটি technique ব্যবহার করছে এই attack catch করতে।

Stack frame anomaly detection — যদি stack frame ntdll-এর Nt* function-এর expected pattern follow না করে, alert generate হয়।

Kernel callback monitoring — PsSetCreateProcessNotifyRoutine, PsSetCreateThreadNotifyRoutine-এর মতো kernel callback-এ context inspection হয়।

ETW (Event Tracing for Windows) telemetry kernel-side থেকে event collect করে। ETW-এর kernel provider বিভিন্ন sensitive operation-এ event generate করে যা bypass করা challenging।

Hardware-based detection-এ Intel CET (Control-flow Enforcement Technology) এবং Intel PT (Processor Trace) ব্যবহৃত হয়। এগুলো instruction-level visibility প্রদান করে যা software-only mitigation দিয়ে bypass করা প্রায় অসম্ভব।

Famous Tool এবং Framework

SysWhispers একটি popular framework Felipe Winther-এর তৈরি। এটি Python-based tool যা header file এবং assembly stub generate করে যা C/C++ project-এ integrate করা যায়। SysWhispers3 latest version যা indirect syscall এবং egg hunting support করে।

FreshyCalls Crowdfense team-এর তৈরি একটি alternative যা runtime-এ syscall number resolution করে, যা Windows version compatibility আরো ভালো করে।

InflativeLoading এবং Donut-এর মতো shellcode loader indirect syscall integrate করে তাদের stealth বাড়িয়েছে।

Cobalt Strike-এর Beacon Object File বা BOF community-তে অনেক indirect syscall implementation available। UDRL (User-Defined Reflective Loader) capability ব্যবহার করে operator নিজস্ব evasion technique implement করতে পারেন।

Sliver, Mythic, Havoc — open-source C2 framework-গুলোতেও indirect syscall support আছে।

বাস্তব Operation-এ প্রয়োগ

Red team engagement-এ indirect syscall ব্যবহারের কয়েকটি practical scenario।

Initial payload execution-এর সময় indirect syscall ম্যালিশাস activity detect হওয়ার সম্ভাবনা কমায়। উদাহরণস্বরূপ, process injection (NtAllocateVirtualMemory, NtWriteVirtualMemory, NtCreateThreadEx) traditional API call-এর মাধ্যমে easily detected, কিন্তু indirect syscall-এর মাধ্যমে অনেক বেশি stealthy।

Credential dumping operation যেমন LSASS process-এ access নেওয়া (NtOpenProcess, MiniDumpWriteDump-এর syscall equivalent) এই technique-এর সাথে আরো effective।

Privilege escalation, persistence, এবং lateral movement-এর প্রতিটি ধাপে indirect syscall integration consider করা উচিত।

কিন্তু এটি একটি silver bullet নয়। অন্যান্য OPSEC measure-এর সাথে combined হওয়া উচিত — string obfuscation, anti-debug, anti-VM, এবং proper persistence mechanism।

Ethical Considerations

Indirect syscall একটি powerful technique যা ভুল হাতে devastating ক্ষতি করতে পারে। তাই এর ব্যবহার সম্পর্কে clear ethical framework অপরিহার্য।

Authorized engagement-এ মাত্র এই technique ব্যবহার করুন। Penetration test, red team exercise, এবং security research — এই context-এ proper agreement এবং scope-এর মধ্যে। কোনো unauthorized system-এ এই কৌশল ব্যবহার করা criminal offense।

Knowledge sharing community-র জন্য valuable। Conference talk, research paper, এবং blog post-এর মাধ্যমে অন্য researcher-দের শেখার সুযোগ দিন। তবে weaponized malware বা ready-to-use exploit publicly share করা responsible disclosure-এর বিপরীত।

Detection improvement-এর জন্য defenders-এর সাথে collaborate করুন। যেকোনো নতুন evasion technique-এর সাথে detection method develop করা একটি healthy ecosystem নিশ্চিত করে।

Detection ও Defense

Defender-দের জন্য indirect syscall detect করা চ্যালেঞ্জিং কিন্তু সম্ভব। প্রথমত, ETW telemetry leverage করুন। SilentEtw এবং similar tool kernel-level visibility প্রদান করে।

দ্বিতীয়ত, call stack analysis করুন। সমস্ত sensitive syscall-এর call stack expected pattern follow করছে কিনা verify করুন। Microsoft-এর Process Monitor এবং similar tool stack trace capability প্রদান করে।

তৃতীয়ত, hardware-assisted feature enable করুন। Intel CET, Memory Protection Key, এবং hypervisor-protected code integrity (HVCI) deploy করুন।

চতুর্থত, behavior-based detection-এ invest করুন। কোনো individual technique না detect করে, full attack chain-এর pattern শনাক্ত করুন। Process tree analysis, command-line argument monitoring, network behavior correlation — এই multi-signal approach more effective।

পঞ্চমত, threat hunting program establish করুন। Hypothesis-driven hunt চালান specific TTP-এর জন্য। MITRE ATT&CK-এর T1620 (Reflective Code Loading), T1106 (Native API), T1055 (Process Injection)-এর সাথে indirect syscall closely related।

ষষ্ঠত, modern EDR সলিউশন deploy করুন এবং properly tune করুন। Vendor recommendation follow করে advanced detection feature enable করুন।

ভবিষ্যৎ Evolution

Offensive এবং defensive technique-এর এই arms race থামবে না। আগামী কয়েক বছরে আমরা আরো sophisticated evasion technique দেখব।

Hardware-level evasion ক্রমেই গুরুত্বপূর্ণ হবে। CPU feature manipulation, microarchitectural side channel, এবং firmware-level technique।

Kernel-mode attack আবার ফিরে আসতে পারে। বহু বছর driver signing এবং HVCI-এর কারণে kernel-mode malware কম দেখা গেছে, কিন্তু BYOVD (Bring Your Own Vulnerable Driver) technique এই trend reverse করছে।

AI-driven evasion এবং detection উভয়ই develop হবে। Attacker behavioral AI ব্যবহার করে evasive code generate করবে, defender AI দিয়ে subtle anomaly detect করবে।

WASM-based evasion এবং browser exploitation নতুন frontier হবে। Modern application-এর জটিলতা নতুন attack surface তৈরি করছে।

Key Takeaways

Indirect Syscall আধুনিক offensive security-এর একটি essential technique যা EDR-এর evolving capability-এর সাথে তাল মিলিয়ে চলার প্রয়োজনে এসেছে। এটি একটি technical mastery requiring deep understanding of Windows internals, assembly programming, এবং security tool behavior। Red team operator, penetration tester, এবং security researcher-দের জন্য এই technique-এর জ্ঞান valuable, কিন্তু এর সাথে আসে গভীর responsibility। অনুমোদিত context-এ এই knowledge ব্যবহার করুন এবং detection method উন্নয়নে অবদান রাখুন। যে কোনো advanced offensive technique-এর মতো, indirect syscall-এর শক্তি defensive improvement-এ ব্যবহৃত হলে cybersecurity community-র সকলের জন্য benefit। প্রতিটি new evasion technique একটি opportunity — better detection, better tooling, এবং better overall security architecture-এর জন্য। বাংলাদেশের security professional-দের জন্য এই ক্ষেত্রে দক্ষতা অর্জন করা ভবিষ্যৎ red team এবং threat hunting career-এর জন্য অপরিহার্য।

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

Related articles

back to all articles