In the ever-evolving cybersecurity landscape, malware continues to pose significant threats, evading and subverting analysis and detection tools with techniques like code packing. Run-time packers compress and/or encrypt malicious code to obfuscate it, but packed code must be decompressed/decrypted in memory before execution. Tracing memory accesses can help to detect unpacking attempts by malicious programs to secure systems. Virtual machines have long been used for malware detection and analysis since the hypervisor sits at a privileged position and has broad visibility on the system, allowing it to intercept memory accesses and detect suspicious activity. Researchers in both industry and academia proposed various monitoring solutions, but their performance overhead has not been thoroughly studied yet. This thesis aims to address this issue, restricting the view to the slowdown resulting from real-time code unpacking detection. We study two solutions, Drakvuf and HVMI. We show that in the worst case, these tools introduce a slowdown factor of more than 2000x on memory accesses but, when monitoring real-world programs, performance penalties are at most 3.80x for Drakvuf and 1.11x for HVMI. Despite HVMI being efficient and potentially suitable for real-time monitoring, we identify a corner case not correctly handled by it. We also explore the potential of the hypervisor-based debugger HyperDbg. We retrofit it as a monitor for code unpacking detection and show that, although HyperDbg-based memory tracing is less invasive than HVMI and Drakvuf from a performance standpoint, the tool is not a viable option for efficient memory analysis. The contributions of this thesis are an analysis of the performance overhead on memory accesses in the presence of memory hooks, a characterization of the impact of hypervisor-based monitoring for code unpacking detection, a comparison between two different approaches for memory hooking and execution tracing, and the definition of guidelines for the implementation of hypervisor-based monitoring for real-time code unpacking detection.
Nel costante evolversi del panorama della sicurezza informatica, i malware rappresentano una minaccia importante, eludendo gli strumenti di analisi e rilevamento con tecniche come il packing del codice. I packer sono programmi che comprimono e crittografano il codice maligno per offuscarlo, ma il codice "packato" deve essere decompresso in memoria prima di essere eseguito. Tracciare gli accessi alla memoria può aiutare a individuare tentativi di "unpacking" da parte di malware e contribuire alla sicurezza dei sistemi. Le macchine virtuali sono da tempo utilizzate per la rilevazione e l'analisi del malware, grazie alla posizione privilegiata del hypervisor e alla sua ampia visibilità sul sistema. I ricercatori in accademia e industria hanno proposto varie soluzioni di monitoring ma il loro impatto sulle performance non è stato adeguatamente studiato. In questa tesi puntiamo a colmare questa lacuna restringendo il campo di studio alla rilevazione in tempo reale di "unpacking" di codice. Studiamo due soluzioni, Drakvuf e HVMI. Nei nostri esperimenti mostriamo che, nel caso peggiore, il fattore di rallentamento sugli accessi in memoria introdotto supera 2000x, ma non per i programmi reali dove si attesta a 3.80x per Drakvuf e 1.11x per HVMI. Anche se HVMI permette di monitorare in tempo reale, noi identifichiamo un caso particolare in cui si dimostra inaffidabile. La tesi esplora anche le potenzialità del debugger basato su hypervisor HyperDbg. Lo adattiamo al task del monitoraggio della memoria per il rilevamento di "unpacking" e dimostriamo che, sebbene sia meno invasivo rispetto a HVMI e Drakvuf dal punto di vista delle prestazioni, lo strumento non è un'opzione valida per un'analisi efficiente. I contributi alla ricerca di questa tesi includono un'analisi dell'overhead prestazionale sugli accessi alla memoria dovuto al monitoring, la caratterizzazione dell'impatto del monitoraggio basato su hypervisor per la rilevazione dell'unpacking di codice sulle prestazioni delle applicazioni reali, il confronto tra due diversi approcci per risolvere il problema, e la definizione di linee guida per l'implementazione di soluzioni efficient.
On the performance of hypervisor-assisted memory monitoring for code unpacking detection
Mileto, Alessandro
2022/2023
Abstract
In the ever-evolving cybersecurity landscape, malware continues to pose significant threats, evading and subverting analysis and detection tools with techniques like code packing. Run-time packers compress and/or encrypt malicious code to obfuscate it, but packed code must be decompressed/decrypted in memory before execution. Tracing memory accesses can help to detect unpacking attempts by malicious programs to secure systems. Virtual machines have long been used for malware detection and analysis since the hypervisor sits at a privileged position and has broad visibility on the system, allowing it to intercept memory accesses and detect suspicious activity. Researchers in both industry and academia proposed various monitoring solutions, but their performance overhead has not been thoroughly studied yet. This thesis aims to address this issue, restricting the view to the slowdown resulting from real-time code unpacking detection. We study two solutions, Drakvuf and HVMI. We show that in the worst case, these tools introduce a slowdown factor of more than 2000x on memory accesses but, when monitoring real-world programs, performance penalties are at most 3.80x for Drakvuf and 1.11x for HVMI. Despite HVMI being efficient and potentially suitable for real-time monitoring, we identify a corner case not correctly handled by it. We also explore the potential of the hypervisor-based debugger HyperDbg. We retrofit it as a monitor for code unpacking detection and show that, although HyperDbg-based memory tracing is less invasive than HVMI and Drakvuf from a performance standpoint, the tool is not a viable option for efficient memory analysis. The contributions of this thesis are an analysis of the performance overhead on memory accesses in the presence of memory hooks, a characterization of the impact of hypervisor-based monitoring for code unpacking detection, a comparison between two different approaches for memory hooking and execution tracing, and the definition of guidelines for the implementation of hypervisor-based monitoring for real-time code unpacking detection.File | Dimensione | Formato | |
---|---|---|---|
2024_04_Mileto_Tesi_01.pdf
Open Access dal 14/03/2025
Descrizione: Elaborato finale.
Dimensione
1.19 MB
Formato
Adobe PDF
|
1.19 MB | Adobe PDF | Visualizza/Apri |
2024_04_Mileto_Executive Summary_02.pdf
non accessibile
Descrizione: Executive Summary dell'elaborato finale.
Dimensione
426.48 kB
Formato
Adobe PDF
|
426.48 kB | Adobe PDF | Visualizza/Apri |
I documenti in POLITesi sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.
https://hdl.handle.net/10589/219213