SlideShare a Scribd company logo
Tamas K Lengyel
@tklengyel
Stealthy,
Hypervisor-based
Malware Analysis
#whoami
Open source enthusiast
Maintainer of Xen, LibVMI and
DRAKVUF
PhD from UConn: Malware Collection
and Analysis via Hardware Virtualization
Agenda
1. Motivation
2. Anti-sandbox tricks
3. Using a hypervisor for monitoring
4. Mo’ problems!
5. Fixing the problems
6. Mo’ problems!
7. Conclusion
An early warning
This presentation will get technical
Don’t be afraid of the assembly
Don’t worry if some of it makes no sense
Sandboxes & honeypots
“Let’s just see what happens”
Most of our tools for observing software at
run-time are built with an assumption that
misbehavior is accidental
- Debuggers
Stealth
Debuggers were not designed to be
stealthy
Debugged process can detect the
debugger
Observer effect
Strings in MultiPlug
$:hash:procexp.exe
$:hash:procmon.exe
$:hash:processmonitor.exe
$:hash:wireshark.exe
$:hash:fiddler.exe
$:hash:vmware.exe
$:hash:vmware-authd.exe
$:hash:windbg.exe
$:hash:ollydbg.exe
$:hash:winhex.exe
$:hash:processhacker.exe
$:hash:hiew32.exe
$:hash:vboxtray.exe
$:hash:vboxservice.exe
$:hash:vmwaretray.exe
$:hash:vmwareuser.exe
Some other popular strings
CheckRemoteDebuggerPresent
IsDebuggerPresent
VIRTUALBOX
VBoxGuestAdditions
QEMU
Prod_VMware_Virtual_
XenVMM
MALTEST
TEQUILABOOMBOOM
VIRUS
MALWARE
SANDBOX
WinDbgFrameClass
SAMPLE
https://github.com/Yara-Rules/rules/blob/master/antidebug_antivm.yar
AntiCuckoo
Detect & crash the Cuckoo process
- Ouch..
Real malware would probably just falsify
the results to not stand out..
https://github.com/David-Reguera-Garcia-Dreg/anticuckoo
..or not: HackedTeam
https://github.com/hackedteam/scout-win/blob/master/core-scout-win32/antivm.cpp
Improving Stealth #1
Move the monitoring component into the
kernel
Windows doesn’t like it if you just
randomly hook stuff (PatchGuard)
What about rootkits?
Rootkit problem 2014
http://www.mcafee.com/us/resources/reports/rp-quarterly-threat-q1-2014.pdf
Rootkit problem 2015
http://www.mcafee.com/us/resources/reports/rp-quarterly-threats-aug-2015.pdf
That’s only about
0.36% of all
malware observed
by McAffee
Rootkit problem?
Based on these numbers rootkits may
seem to be not that big of a deal
High cost of development may mean you
don't use one unless you have to
Or are we just bad at detecting them?
Improving Stealth #2
Move the monitoring component into a
hypervisor
Harder to detect
Greater visibility
Harder to develop
Emulation vs. virtualization
Emulation Pro:
- Easier to monitor
Emulation Con:
- Easy to detect
- Easy to get it wrong
- Unlikely in production environment
How to start the malware?
Our goal is to do everything without the
need of an in-guest agent
No startup scripts, no client process
Straight up memory and CPU
manipulation can get us what we need!
Done?
Nope
Malware can detect if it’s running in a
virtualized environment
Hypervisors were not designed to be
stealthy either
Pafish
https://github.com/a0rtega/pafish
CPUID hypervisor guest status
static inline int cpuid_hv_bit() {
int ecx;
__asm__ volatile("cpuid" 
: "=c"(ecx) 
: "a"(0x01));
return (ecx >> 31) & 0x1;
}
CPUID hypervisor guest status
cpuid =
['0x1:ecx=0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx']
The fix verified
60GB free disk space?
LVM copy-on-write allows us to quickly
deploy lightweight duplicates
Analysis clones will only use extra space
if they change files
And only as much space as they actually
changed
The fix verified
Uptime check
int gensandbox_uptime() {
/* < ~12 minutes */
return GetTickCount() < 0xAFE74 ?
TRUE : FALSE;
}
Uptime check
Let your VM sit idle for a while, take
memory snapshot
Start each analysis clone by loading this
memory snapshot
Could also just return fake value
The fix verified
Memory size check
Who uses a machine with <1Gb RAM?
We can increase sandbox memory size
but that limits how many we can run
Xen memory sharing allows CoW!
CoW memory
CoW memory over time
Xen memory-sharing status
It works but it’s very experimental
Original developer no longer around
May not work with other experimental
Xen features
CPU count check
Multi-vCPU tracing
Particularly challenging due to how
external monitoring is implemented
Easy to end up in a race-condition with
concurrently active CPUs
EPT-lookup
EPT-lookup
All vCPUs share a single EPT
Standard way hypervisors use EPT
Race with multi-vCPU EPT
RACE
Some ways around
We can pause CPUs
We can emulate instructions
...or!
Xen altp2m
Xen altp2m
The fix verified
I/O activity
It’s all emulated so we could fake it
We could even reconstruct the location of
buttons / pop-ups from memory!
Click on “Install” buttons?
- Doesn’t seem to make much difference
- http://laredo-13.mit.edu/~brendan/BSIDES_NOLA_2015.pdf
Other CPUID leaks
hypervisor_id = "XenVMMXenVMM" (0x40000000/ebx-edx)
hypervisor version (0x40000001/eax):
version = 4.6
hypervisor features (0x40000002):
number of hypercall-transfer pages = 0x1 (1)
MSR base address = 0x40000000
MMU_PT_UPDATE_PRESERVE_AD supported = false
vtsc = false
host tsc is safe = true
boot cpu has RDTSCP = true
tsc mode = 0x0 (0)
tsc frequency (kHz) = 3392364
incarnation = 0x1 (1)
PCI leaks
00:02.0 VGA compatible controller: Cirrus Logic GD 5446 (prog-if 00 [VGA controller])
Subsystem: Red Hat, Inc QEMU Virtual Machine
Physical Slot: 2
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR-
FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR-
<PERR- INTx-
Latency: 0
Region 0: Memory at f0000000 (32-bit, prefetchable) [size=32M]
Region 1: Memory at f2072000 (32-bit, non-prefetchable) [size=4K]
Expansion ROM at f2060000 [disabled] [size=64K]
Kernel driver in use: cirrus
Disk vendor leaks
description: ATA Disk
product: QEMU HARDDISK
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: 1
serial: QM00001
size: 93GiB (100GB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=a6b04d21
Some more things to look for
Screen resolution
File modification timestamps
Username
Malware executable file-name
GeoIP
Telling time
Telling time
RDTSC is trappable to the hypervisor
- We could actually fake the value it returns
Not the only way to measure time
- HPET, NTP, covert channels..
Discussion
Often-made argument:
Virtualization is so wide-spread,
detection of it may not be indicative of
an analysis environment
It's true.. to an extent!
Does malware really care?
Most malware authors are lazy
Why go all this way if you could just..
sleep!
Stalling malware
Stalling malware
Halting problem
We can hook Sleep()
We can randomize execution time
Advanced Stalling malware
Spam system calls that normally finish
fast
- NtCreateSemaphore
Monitoring incurs overhead on each call
so this will time out the sandbox
http://www.syssec-project.eu/m/page-media/3/hasten-ccs11.pdf
Advanced Stalling malware
How to detect syscall spam?
We need some baseline
100k malware syscalls
Advanced Stalling malware
Average # of calls of NtCreateSemaphore
- 10
API spamming malware?
- 1
- Calls it 17453 times in 60s
Discussion
There is no absolute stealth
Making stealthier tools require malware to
run more checks
But only if our analysis tools span the
entire spectrum
Conclusion
No end in sight
Still many low-hanging fruits for malware
to detect
A lot more tools available
We need to use them all or malware
becomes resilient faster
Thanks!
Tamas K Lengyel
tamas@tklengyel.com
@tklengyel
LibVMI http://libvmi.com
DRAKVUF http://drakvuf.com
References
https://hacktivity.com/en/downloads/archives/429/
https://github.com/Yara-Rules/rules/blob/master/antidebug_
https://github.com/David-Reguera-Garcia-Dreg/anticuckoo
https://github.com/a0rtega/pafish
https://github.com/hackedteam/scout-win/blob/master/core-

More Related Content

PPT
PPT
Android architecture
PPTX
Android architecture
PPT
active-directory-domain-services
PPT
Red hat linux 9 ppt2003
DOC
SOFTWARE ENGINEERING
PPT
RedHat Linux
 
PPT
Versions of android
Android architecture
Android architecture
active-directory-domain-services
Red hat linux 9 ppt2003
SOFTWARE ENGINEERING
RedHat Linux
 
Versions of android

What's hot (20)

PDF
UNIFIED MODELING LANGUAGE
PPTX
software configuration management ppt
PPT
Introduction to Android, Architecture & Components
PPT
Software Configuration Management
PPTX
Linuxppt.pptx
PPT
Mobile Application Development With Android
PDF
Best Practices for Upgrading Your Portal to SAP NetWeaver 7.3
PPT
Configuration Management
PPTX
Android - Application Framework
PPTX
Android ppt
PPTX
Software configuration management
PPTX
Defect prevention
PPTX
Unified process Model
PPTX
Linux security
PPT
Introduction to Android
PPTX
2.Modular Design.pptx
PPTX
SDLC ITS MODEL AND SOFTWARE TESTING
DOCX
computer system Assingment Ncc
PDF
High Performance Software Engineering Teams
UNIFIED MODELING LANGUAGE
software configuration management ppt
Introduction to Android, Architecture & Components
Software Configuration Management
Linuxppt.pptx
Mobile Application Development With Android
Best Practices for Upgrading Your Portal to SAP NetWeaver 7.3
Configuration Management
Android - Application Framework
Android ppt
Software configuration management
Defect prevention
Unified process Model
Linux security
Introduction to Android
2.Modular Design.pptx
SDLC ITS MODEL AND SOFTWARE TESTING
computer system Assingment Ncc
High Performance Software Engineering Teams
Ad

Viewers also liked (11)

PDF
Malware Collection and Analysis via Hardware Virtualization
PDF
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
PDF
Virtual Machine Introspection with Xen
PDF
Cloud Security with LibVMI
ODP
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
ODP
Pitfalls of virtual machine introspection on modern hardware
PDF
31c3 Presentation - Virtual Machine Introspection
PDF
CrySys guest-lecture: Virtual machine introspection on modern hardware
ODP
Virtual Machine Introspection with Xen on ARM
PDF
Virtual Machine Introspection in a Hyberid Honeypot Architecture
PDF
CyberSEED: Virtual Machine Introspection to Detect and Protect
Malware Collection and Analysis via Hardware Virtualization
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
Virtual Machine Introspection with Xen
Cloud Security with LibVMI
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Pitfalls of virtual machine introspection on modern hardware
31c3 Presentation - Virtual Machine Introspection
CrySys guest-lecture: Virtual machine introspection on modern hardware
Virtual Machine Introspection with Xen on ARM
Virtual Machine Introspection in a Hyberid Honeypot Architecture
CyberSEED: Virtual Machine Introspection to Detect and Protect
Ad

Similar to Stealthy, Hypervisor-based Malware Analysis (20)

PDF
BSides Denver: Stealthy, hypervisor-based malware analysis
PDF
Hacktivity 2016: Stealthy, hypervisor based malware analysis
PDF
Kernel Recipes 2015 - Kernel dump analysis
PDF
Talk 160920 @ Cat System Workshop
PDF
2011-03 Developing Windows Exploits
PDF
Android Boot Time Optimization
PDF
syzkaller: the next gen kernel fuzzer
PDF
Deep Dive on Amazon EC2 Instances (March 2017)
PDF
See what happened with real time kvm when building real time cloud pezhang@re...
PPT
Joanna Rutkowska Subverting Vista Kernel
PDF
Intel DPDK Step by Step instructions
PDF
Pitfalls and limits of dynamic malware analysis
PDF
HKG18-TR14 - Postmortem Debugging with Coresight
PDF
Clear cache memory
PDF
OffensiveCon2022: Case Studies of Fuzzing with Xen
PDF
Fuzzing_with_Xen.pdf
ODP
Java gpu computing
PDF
Varnish http accelerator
PDF
LXC on Ganeti
PDF
PerfUG 3 - perfs système
BSides Denver: Stealthy, hypervisor-based malware analysis
Hacktivity 2016: Stealthy, hypervisor based malware analysis
Kernel Recipes 2015 - Kernel dump analysis
Talk 160920 @ Cat System Workshop
2011-03 Developing Windows Exploits
Android Boot Time Optimization
syzkaller: the next gen kernel fuzzer
Deep Dive on Amazon EC2 Instances (March 2017)
See what happened with real time kvm when building real time cloud pezhang@re...
Joanna Rutkowska Subverting Vista Kernel
Intel DPDK Step by Step instructions
Pitfalls and limits of dynamic malware analysis
HKG18-TR14 - Postmortem Debugging with Coresight
Clear cache memory
OffensiveCon2022: Case Studies of Fuzzing with Xen
Fuzzing_with_Xen.pdf
Java gpu computing
Varnish http accelerator
LXC on Ganeti
PerfUG 3 - perfs système

More from Tamas K Lengyel (7)

PDF
Estimating Security Risk Through Repository Mining
PDF
VM Forking and Hypervisor-based Fuzzing with Xen
PPTX
VM Forking and Hypervisor-based fuzzing
PDF
Anti-evil maid with UEFI and Xen
PDF
Troopers15 Lightning talk: VMI & DRAKVUF
ODP
Hacktivity2014: Virtual Machine Introspection to Detect and Protect
PDF
Dfrws eu 2014 rekall workshop
Estimating Security Risk Through Repository Mining
VM Forking and Hypervisor-based Fuzzing with Xen
VM Forking and Hypervisor-based fuzzing
Anti-evil maid with UEFI and Xen
Troopers15 Lightning talk: VMI & DRAKVUF
Hacktivity2014: Virtual Machine Introspection to Detect and Protect
Dfrws eu 2014 rekall workshop

Recently uploaded (20)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
cuic standard and advanced reporting.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Electronic commerce courselecture one. Pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
1. Introduction to Computer Programming.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
MIND Revenue Release Quarter 2 2025 Press Release
cuic standard and advanced reporting.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Big Data Technologies - Introduction.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
A comparative analysis of optical character recognition models for extracting...
SOPHOS-XG Firewall Administrator PPT.pptx
Spectral efficient network and resource selection model in 5G networks
Electronic commerce courselecture one. Pdf
Machine Learning_overview_presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Assigned Numbers - 2025 - Bluetooth® Document
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Programs and apps: productivity, graphics, security and other tools
1. Introduction to Computer Programming.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding

Stealthy, Hypervisor-based Malware Analysis