# AntiSanbox (p1) ![](https://i.imgur.com/RHY5iIR.png) - Một vài artifacts: files, processes, registry keys, services, network device adapters... # A. Delay execution: ![](https://hackmd.io/_uploads/S1Por6YZT.png) ### Evade sandbox by waiting timeout of sandbox: - NtDelayExecution (lowest in user mode: Sleep -> SleepEx -> NtDelayExecution ) - Sleep, SleepEx, - WaitForSingleObject,WaitForSingleObjectE , NtWaitForSingleObject WaitForMultipleObjects - WaitForMultipleObjectsEx, NtWaitForMultipleObjects - SetTimer, SetWaitableTimer, CreateTimerQueueTimer timeSetEvent (multimedia timers) - IcmpSendEcho - select (Windows sockets) # B. Hardening artifacts: ## 1. kiểm tra sự tồn tại của file trên hệ thống: Sử dụng các file khác nhau tồn tại trên host bình thường và môi trường ảo. - **GetFileAttributes** được sử dụng để kiểm tra sự tồn tại của file với tham số là đường dẫn của file. - Virtualbox: ![](https://i.imgur.com/kbKRA0M.png) ![](https://i.imgur.com/GTxvfcs.png) | VMware | Virtualbox | KVM| | -------- | -------- |--| | C:\Windows\System32\drivers\vm3dmp-debug.sys | %Programfiles%\oracle\virtualbox guest additions\ | %ProgramW6432%\Virtio-Win\ | | C:\Windows\System32\drivers\vm3dmp-stats.sys | | System32\\drivers\\balloon.sys | | C:\Windows\System32\drivers\vm3dmp.sys | | System32\\drivers\\netkvm.sys | | C:\Windows\System32\drivers\vm3dmp_loader.sys | | System32\\drivers\\pvpanic.sys | | C:\Windows\System32\drivers\vmhgfs.sys | | System32\\drivers\\viofs.sys | | C:\Windows\System32\drivers\vmmemctl.sys | | System32\\drivers\\viogpudo.sys | | C:\Windows\System32\drivers\vmmouse.sys || System32\\drivers\\vioinput.sys | | C:\Windows\System32\drivers\vmrawdsk.sys || System32\\drivers\\viorng.sys | | C:\Windows\System32\drivers\vmusbmouse.sys || System32\\drivers\\vioscsi.sys | | %Programfiles%\VMware\ | | System32\\drivers\\vioser.sys | | | | System32\\drivers\\viostor.sys | - Check full path (GetModuleFileName, GetProcessImageFileNameA/W, QueryFullProcessImageName) chứa các chuối: "sample", "virus", "sanbox", "malware"... ## 2. phát hiện dựa trên registry: | kernel32.dll | ntdll.dll | | -------- | -------- | | RegOpenKey/Ex | NtOpenKey| | RegQueryValue/Ex| NtEnumerateKey| | RegCloseKey| NtQueryValueKey| | RegEnumKeyEx| NtClose| - VMware: - HKLM\SYSTEM\CurrentControlSet\Enum\PCI\VEN_15AD&DEV_XXXX&SUBSYS_XXXX15AD&REV_XX - HKLM\SYSTEM\ControlSet001\Services\vm3dmp - HKLM\SYSTEM\ControlSet001\Services\vm3dmp-debug - HKLM\SYSTEM\ControlSet001\Services\vm3dmp-stats - HKLM\SYSTEM\ControlSet001\Services\vm3dmp_loader - HKLM\SYSTEM\ControlSet001\Services\vm3dservice - HKLM\SYSTEM\ControlSet001\Services\vmhgfs - VirtualBox: - HKLM\SYSTEM\CurrentControlSet\Enum\PCI\VEN_8086&DEV_xxxx&SUBSYS_xxxxxxxx&REV_xx - QEMU KVM: - SYSTEM\\ControlSet001\\Services\\vioscsi - SYSTEM\\ControlSet001\\Services\\viostor - SYSTEM\\ControlSet001\\Services\\VirtIO-FS Service - SYSTEM\\ControlSet001\\Services\\VirtioSerial - SYSTEM\\ControlSet001\\Services\\BALLOON - SYSTEM\\ControlSet001\\Services\\BalloonService - SYSTEM\\ControlSet001\\Services\\netkvm - C:\Program Files\Qemu-ga\qemu-ga.exe - C:\Program Files\qga\qga.exe ## 3. CPU instruction: **cpuid** (\x0f\xa2), với tham số là thanh ghi EAX, nó cũng chứa chuỗi đặc trưng của các htpervisor. ``` Microsoft Hv for Hyper-V KVMKVMKVM for KVM prl hyperv for Parallels VBoxVBoxVBox for VirtualBox VMwareVMware for VMWare XenVMMXenVMM for Xen. ``` ## 4. OS query: ### Check ram: **GetMemoryStatusEx** được sử dụng để ktra dung lượng ram - Ta sẽ hook vào **NtQuerSystemInformation** để trả về giá trị mới cho PhysicalPages trong SystemBasicInformation. - Tìm các chuỗi liên quan đến máy ảo. ### check screen resolution: - Các API có thể sử dụng: **GetDesktopWindow**, **GetWindowRect**, **GetSystemMetrics**, **SystemParametersInfo**, **GetMonitorInfo**. ### Kiểm tra drivers thường có trên VM: - EnumDeviceDrivers ### Number of processors/installed app: - Ta có thể thu thập thông tin này từ PEB, với offset = 0xb8 trên x32 và offset = 0x64 trên x64. - Installed app: MsiEnumProductsA, MsiGetProductInfoA ### testing tools - https://github.com/LordNoteworthy/al-khaser - https://github.com/a0rtega/pafish ### Refs: - https://research.checkpoint.com/2023/cloud-based-malware-delivery-the-evolution-of-guloader/ - https://evasions.checkpoint.com/ - [.vmx file params for VMware](https://sanbarrow.com/vmx.html)