SlideShare a Scribd company logo
Stealthy,
Hypervisor-based
Malware Analysis
Tamas K Lengyel
tamas.lengyel@zentific.com
Sergej Proskurin
proskurin@sec.in.tum.de
#who
Tamas:
- Maintainer of Xen, LibVMI and DRAKVUF
- Co-Founder of Zentific
- Chapter lead of Malware Analytics at Scale at the
Honeynet Project
- PhD from UConn
Sergej:
- PhD Student at TUM Chair for IT Security
- Honeynet GSoC 2016
Agenda
1. Motivation
2. DRAKVUF behind the scenes
3. Xen behind the scenes
4. What’s next?
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
CheckRemoteDebugger
Present
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/antidebug_antivm.yar
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 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?
Rootkits are either not that big of a deal
Or are we just bad / getting worse at
detecting them?
Improving Stealth #2
Move the monitoring component into a
hypervisor
Harder to detect
Greater visibility
A lot easier said than done
2014: DRAKVUF released
https://youtu.be/EZPXy314q3E
Lots of work behind the scenes
https://github.com/tklengyel/drakvuf
Complete rework in Xen
Are we 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
CPUID VM vendor IDs
Leaf 0x40000000
- EBX-EDX: XenVMMXenVMM
No way to override without recompiling
- Introduce CPUID events in Xen 4.8
- On-the-fly filtering of CPUID results
from dom0
Hacktivity 2016: Stealthy, hypervisor based malware analysis
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
https://tklengyel.com/nss2013-100.pdf
CoW memory over time
https://tklengyel.com/nss2013-100.pdf
Fun fact
Memory sharing based honeypots first
tested live at Hacktivity 2012!
Was really looking forward for those 1337
h4ck3rs on the public wifi!
Got nothing. Network is very nicely VLAN
isolated between clients (broadcast traffic
still got through)...
Xen memory-sharing status
It works but marked ‘experimental’
Fixes for Xen 4.8 to co-exist with other
‘experimental’ features
Memory sharing is known to open the
gates for cross-VM RowHammer attacks
For more details see:
https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_razavi.pdf
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
DRAKVUF tracing in the beginning
1. Inject 0xCC into target function entry points
2. Mark pages Execute-only in the EPT
3. If anything tries to read the page
a. Remove 0xCC and mark page R/W/X
b. Singlestep
c. Place 0xCC back and mark page X-only
4. When 0xCC traps to Xen
a. Remove 0xCC
b. Singlestep
c. Place 0xCC back
EPT-lookup
EPT-lookup
All vCPUs share a single EPT
Standard way hypervisors use EPT
Race with multi-vCPU EPT
RACE
Using 0xCC is also racy
We have to remove 0xCC to allow
execution to continue
Another vCPU could fetch the instruction
just at that moment
We can potentially miss an event from
being logged
Some ways around
We can pause CPUs
We can emulate instructions
...or!
Xen alternate p2m (altp2m)
Xen altp2m
Introduced by Intel to support #VE and
VMFUNC
- Allow the guest to handle EPT faults without the
associated cost of a VMEXIT
- Allow the guest to switch around EPTs without
trapping into the hypervisor
- Also allows external tools to make use of
multiple tables
Xen altp2m
Also includes a pretty exotic feature
- GFN remapping
Similar to memory-sharing, but intra-VM
- Allow a GFN to point to a different MFN
https://blog.xenproject.org/2016/04/13/stealthy-monitoring-with-xen-altp2m
Xen altp2m GFN remapping
Normal mapping with EPT
Guest physical memory
Machine physical memory
DRAKVUF’s altp2m setup
Altp2m view 0
Used only when
singlestepping
Machine physical
memory
DRAKVUF’s altp2m setup
Altp2m view 1
Default during
execution
Machine physical
memory
DRAKVUF’s altp2m setup
Altp2m view 2
Used only when
singlestepping
Machine physical
memory
Xen altp2m exposure
By default the altp2m interface is guest
accessible
- Required for VMFUNC
- NOT required for DRAKVUF
DRAKVUF XSM policy
- Prohibit guest-access to altp2m
- Will be a lot easier on Xen 4.8
The fix verified
I/O activity? Time?
I/O can be relatively easily emulated
- TODO
RDTSC is trappable but..
- Hiding time-dilation from all possible
time-sources is likely not possible
- TODO
Detect virtualization vs DRAKVUF
Virtualization is now everywhere
- Not enough to detect if environment is virtual
- Likely not possible to hide all virtualization
artifacts anyway
Guest should not be able to detect
DRAKVUF!
- Stealth = indistinguishable from a regular VM
New: guest debug events
Malware is known to perform
self-debugging
- Prevents other debuggers to attach
- Can be used for stealth
Case in point:
https://blog.avast.com/2013/05/29/analysis-of-a-self-debugging-sirefef-cryptor
https://blog.malwarebytes.com/threat-analysis/2013/07/zeroaccess-anti-debug-
uses-debugger/
http://research.dissect.pe/docs/blackhat2012-paper.pdf
Hacktivity 2016: Stealthy, hypervisor based malware analysis
Tricky tricky breakpoints
0xCC can also be used by in-guest
debuggers
- These will also trap to DRAKVUF
- Need to be reinjected into the guest
- Not that big of a deal.. If you do it right..
What’s the length of 0xCC?
/*
* Injects a hardware/software CPU trap, to take effect the next time the HVM
* resumes.
*/
int xc_hvm_inject_trap(
xc_interface *xch, domid_t dom, int vcpu, uint32_t vector,
uint32_t type, uint32_t error_code, uint32_t insn_len,
uint64_t cr2);
Hint: 0xCC = 0b11001100
The obvious answer: 1
#define TRAP_int3 3
rc = xc_hvm_inject_trap(xch, domain_id, req.vcpu_id,
TRAP_int3, /* Vector 3 for INT3 */
HVMOP_TRAP_sw_exc, /* Trap type, here a software intr */
~0u, /* error code. ~0u means 'ignore' */
1, /* Instruction length. Xen INT3 events are
* exclusively specific to 0xCC with no operand,
* providing a guarantee that this is 1 byte only.
*/
0 /* cr2 need not be preserved */);
Correct answer: it depends
Intel® 64 and IA-32 Architectures Software Developer’s Manual
x86 instruction prefixes
Have absolutely no affect on 0xCC
- No sane debugger adds any for this reason
- You can use the same prefix multiple times
- The CPU just ignores them
- Except it changes the instruction length at VMEXIT…
Recommended read:
https://fgiesen.wordpress.com/2016/08/25/how-many-x86-instructions-are-there
What about Linux? And ARM?
ARM has virtualization extensions since
the Cortex A15
Some things are similar, some things are
not
Work in progress
Hacktivity 2016: Stealthy, hypervisor based malware analysis
The problems on ARM
altp2m only available on Intel systems
The ARM SLAT doesn’t have a concept
of Execute-only memory
- Memory has to be readable AND executable
No stealthy single-stepping
- No Monitor Trap Flag equivalent on ARM
Honeynet GSoC 2016
Porting Xen altp2m to ARM!
- 38 patches and counting
- Expected to land in Xen 4.9
- Some aspects of altp2m have been
revamped to better fit ARM
- Especially around TLB handling
https://github.com/sergej-proskurin/xen/tree/arm-altp2m-v4
Sneak peak into what’s next
Hiding shadow copies with R/X mapping
- Experiments with splitting the TLB on
ARM
- It works surprisingly well but there are
limitations and gotchas
Even more exotic altp2m setups
- TLB splitting vs TLB partitioning
Thanks!
Tamas K Lengyel
tamas.lengyel@zentific.com
@tklengyel
Sergej Proskurin
proskurin@sec.in.tum.de
Zentific https://zentific.com
DRAKVUF https://drakvuf.com
References
https://github.com/Yara-Rules/rules/blob/master/Antidebug_AntiVM/antidebug_antivm.yar
http://www.mcafee.com/us/resources/reports/rp-quarterly-threats-aug-2015.pdf
https://github.com/a0rtega/pafish
https://tklengyel.com/nss2013-100.pdf
https://fgiesen.wordpress.com/2016/08/25/how-many-x86-instructions-are-there
https://blog.xenproject.org/2016/04/13/stealthy-monitoring-with-xen-altp2m/
https://www.usenix.org/system/files/conference/usenixsecurity16/sec16_paper_razavi.pdf
https://blog.avast.com/2013/05/29/analysis-of-a-self-debugging-sirefef-cryptor
https://blog.malwarebytes.com/threat-analysis/2013/07/zeroaccess-anti-debug-uses-debu
gger/
http://research.dissect.pe/docs/blackhat2012-paper.pdf
https://github.com/sergej-proskurin/xen/tree/arm-altp2m-v4

More Related Content

PDF
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
PDF
Pipework: Software-Defined Network for Containers and Docker
PDF
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
ODP
SR-IOV Introduce
PDF
Address/Thread/Memory Sanitizer
PDF
High Availability PostgreSQL with Zalando Patroni
PPTX
Qt5 (minimal) on beaglebone, with Yocto
PDF
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
Pipework: Software-Defined Network for Containers and Docker
Almost Perfect Service Discovery and Failover with ProxySQL and Orchestrator
SR-IOV Introduce
Address/Thread/Memory Sanitizer
High Availability PostgreSQL with Zalando Patroni
Qt5 (minimal) on beaglebone, with Yocto
ceph::errorator<> throw/catch-free, compile time-checked exceptions for seast...

What's hot (20)

PPTX
Debug dpdk process bottleneck & painpoints
PDF
AARCH64 VMSA Under Linux Kernel
PDF
VXLAN and FRRouting
PDF
Spi drivers
PDF
PostgreSQL HA
ODP
eBPF maps 101
PPTX
Maria db 이중화구성_고민하기
PDF
MySQL Parallel Replication: inventory, use-case and limitations
PDF
ClickHouse Monitoring 101: What to monitor and how
PDF
Run Qt on Linux embedded systems using Yocto
PDF
CXL_説明_公開用.pdf
PDF
Performance tuning ColumnStore
PDF
A practical guide to buildroot
PDF
Android Internals at Linaro Connect Asia 2013
PDF
Dd and atomic ddl pl17 dublin
PDF
Oracle GoldenGate R12.2 セットアップガイド
DOCX
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
PDF
ACPI Debugging from Linux Kernel
PDF
Linux Networking Explained
Debug dpdk process bottleneck & painpoints
AARCH64 VMSA Under Linux Kernel
VXLAN and FRRouting
Spi drivers
PostgreSQL HA
eBPF maps 101
Maria db 이중화구성_고민하기
MySQL Parallel Replication: inventory, use-case and limitations
ClickHouse Monitoring 101: What to monitor and how
Run Qt on Linux embedded systems using Yocto
CXL_説明_公開用.pdf
Performance tuning ColumnStore
A practical guide to buildroot
Android Internals at Linaro Connect Asia 2013
Dd and atomic ddl pl17 dublin
Oracle GoldenGate R12.2 セットアップガイド
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
ACPI Debugging from Linux Kernel
Linux Networking Explained

Similar to Hacktivity 2016: Stealthy, hypervisor based malware analysis (20)

PDF
BSides Denver: Stealthy, hypervisor-based malware analysis
ODP
Stealthy, Hypervisor-based Malware Analysis
ODP
Hacktivity2014: Virtual Machine Introspection to Detect and Protect
PDF
Virtual Machine Introspection with Xen
PDF
31c3 Presentation - Virtual Machine Introspection
PDF
DEF CON 27 - ALI ISLAM and DAN REGALADO WEAPONIZING HYPERVISORS
ODP
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
PDF
Breaking paravirtualized devices
PDF
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
PDF
Применение виртуализации для динамического анализа
PDF
XPDDS19: Xen API Archaeology: Creating a Full-Featured VMI Debugger for the...
PPTX
Zero footprint guest memory introspection from xen
PDF
Pitfalls and limits of dynamic malware analysis
PDF
XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...
PDF
BlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel Protector
PDF
Rootlinux17: An introduction to Xen Project Virtualisation
PDF
XS Boston 2008 Debugging Xen
PPS
Xen Euro Par07
PDF
Breaking hardware enforced security with hypervisors
PDF
HITBSecConf 2017-Shadow-Box-the Practical and Omnipotent Sandbox
BSides Denver: Stealthy, hypervisor-based malware analysis
Stealthy, Hypervisor-based Malware Analysis
Hacktivity2014: Virtual Machine Introspection to Detect and Protect
Virtual Machine Introspection with Xen
31c3 Presentation - Virtual Machine Introspection
DEF CON 27 - ALI ISLAM and DAN REGALADO WEAPONIZING HYPERVISORS
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Breaking paravirtualized devices
Don't Tell Joanna the Virtualized Rootkit is Dead (Blackhat 2007)
Применение виртуализации для динамического анализа
XPDDS19: Xen API Archaeology: Creating a Full-Featured VMI Debugger for the...
Zero footprint guest memory introspection from xen
Pitfalls and limits of dynamic malware analysis
XPDS14 - Zero-Footprint Guest Memory Introspection from Xen - Mihai Dontu, Bi...
BlackHat Asia 2017-Myth and Truth about Hypervisor-Based Kernel Protector
Rootlinux17: An introduction to Xen Project Virtualisation
XS Boston 2008 Debugging Xen
Xen Euro Par07
Breaking hardware enforced security with hypervisors
HITBSecConf 2017-Shadow-Box-the Practical and Omnipotent Sandbox

More from Tamas K Lengyel (15)

PDF
Estimating Security Risk Through Repository Mining
PDF
OffensiveCon2022: Case Studies of Fuzzing with Xen
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
Malware Collection and Analysis via Hardware Virtualization
PDF
CyberSEED: Virtual Machine Introspection to Detect and Protect
PDF
Cloud Security with LibVMI
PDF
Troopers15 Lightning talk: VMI & DRAKVUF
PDF
CrySys guest-lecture: Virtual machine introspection on modern hardware
ODP
Virtual Machine Introspection with Xen on ARM
ODP
Pitfalls of virtual machine introspection on modern hardware
PDF
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
PDF
Virtual Machine Introspection in a Hyberid Honeypot Architecture
PDF
Dfrws eu 2014 rekall workshop
Estimating Security Risk Through Repository Mining
OffensiveCon2022: Case Studies of Fuzzing with Xen
VM Forking and Hypervisor-based Fuzzing with Xen
VM Forking and Hypervisor-based fuzzing
Anti-evil maid with UEFI and Xen
Malware Collection and Analysis via Hardware Virtualization
CyberSEED: Virtual Machine Introspection to Detect and Protect
Cloud Security with LibVMI
Troopers15 Lightning talk: VMI & DRAKVUF
CrySys guest-lecture: Virtual machine introspection on modern hardware
Virtual Machine Introspection with Xen on ARM
Pitfalls of virtual machine introspection on modern hardware
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
Virtual Machine Introspection in a Hyberid Honeypot Architecture
Dfrws eu 2014 rekall workshop

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
assetexplorer- product-overview - presentation
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
AutoCAD Professional Crack 2025 With License Key
PDF
Website Design Services for Small Businesses.pdf
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Designing Intelligence for the Shop Floor.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Operating system designcfffgfgggggggvggggggggg
Why Generative AI is the Future of Content, Code & Creativity?
Design an Analysis of Algorithms II-SECS-1021-03
assetexplorer- product-overview - presentation
Weekly report ppt - harsh dattuprasad patel.pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Complete Guide to Website Development in Malaysia for SMEs
Monitoring Stack: Grafana, Loki & Promtail
Reimagine Home Health with the Power of Agentic AI​
AutoCAD Professional Crack 2025 With License Key
Website Design Services for Small Businesses.pdf
Computer Software and OS of computer science of grade 11.pptx
Download FL Studio Crack Latest version 2025 ?
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev

Hacktivity 2016: Stealthy, hypervisor based malware analysis