SlideShare a Scribd company logo
1 of 28
COUNTERING INNOVATIVE SANDBOX
EVASION TECHNIQUES USED BY
MALWARE
Frederic Besler, Carsten Willems, and Ralf Hund
• State of the Art malware analysis systems use hybrids of
static and dynamic analysis
• Dynamic analysis usually in form of behavior based
detection aka. sandbox
• Malware tries to detect and evade sandbox
• We need to talk about sandbox evasion and anti-evasion
Introduction
2
Evasion Techniques - Categories
1. Detect
the
Sandbox
2. Defeat
the Monitor
3. Context
Awareness
* Categories are fuzzy and overlap
3
1. Detect the Sandbox
• Actively detect the analysis environment
- If in analysis environment: Quit or act benign
- Else: Execute the malicious code
• Most commonly used methods:
- Detect underlying technology, e.g. hypervisor or emulator
- Detect specific sandbox product, e.g. check for files or processes
- Detect artificial environments, e.g. check for “clean” system
1. Detect the Sandbox
5
 Large attack surface
 Essential virtual devices are hard to
hide
Malware
Detect Virtualization via Artifacts
- Examples:
 Registry, Files (Software, Drivers), Processes
 Device Names, Device IDs, MACs
 SMBIOS, ACPI tables
 IO Ports (VMWare, KVM/Qemu)
1. Detect the Sandbox – Virtualization Artifacts
REG_BLACKLIST = ["vbox", "vmware", "bochs",
"qemu","red.?hat", "virt.?io", "kvmnet",
"netkvm", ...]
PROC_BLACKLIST = ["vbox.*.exe",
"vmware.*.exe", "prl_.*.exe", ...]
VENDOR_IDS = {
0x1a71: "XenSource, Inc."
0x5853: "XenSource, Inc."
0xfffd: "XenSource, Inc."
0x15ad: "VMware"
0xfffe: "VMWare Inc (temporary ID)"
# VBox
0x80ee: "InnoTek Systemberatung GmbH"
# QEMU/KVM
0x1af4: "Red Hat, Inc."
0x1b36: "Red Hat, Inc."
0x1ab8: "Parallels, Inc."
}
6
• Clean registry, remove files, …
• Don’t use paravirt. Devices
• Use custom hypervisor
Counterm.
CPUID
- CPU tells guest that it is
virtualized
- Examples:
 CPUID Hypervisor Bit
 CPUID Hypervisor Brand String
 Other CPUID Artifacts (e.g.
Function 0x80000009)
1. Detect the Sandbox – Virtualization
struct { int EAX; int EBX; int ECX; int EDX; } out;
__cpuidex((int*)&out, 1, 0);
if (!(out.ECX >> 31))
do_evil();
char out[4 * 4 + 1] = { 0 };
__cpuidex((int*)out, 0x40000000, 0);
if (strlen(out + 4) >= 4)
do_evil();
Real System Virtualized System
7
 No false positives
 Can be disabled (requires support of
HV)
Malwar
e
• Disable where possible
Counterm
.
1. Detect the Sandbox – Virtualization
Side Channels
- HV consumes CPU cycles
- HV and VM(s) share resources
- Examples:
 Time instructions
 Time caching side effects
long long s, acc = 0;
int out[4];
for (int i = 0; i < 100; ++i) {
s = __rdtsc();
__cpuidex(out, 0, 0);
acc += __rdtsc() - s;
}
if (acc / 100 < 200)
do_evil();
Real System Virtualized System
8
 Very hard to prevent
 Specific to hardware
 Can be noisy
Malware
• Heuristics to detect specific attacks
• Spoof timer values
Counterm
.
Unusual Hardware
Characteristics
- Examples:
 CPU type, number cores
 HD space, Ram
 Printers
 USB devices/sticks
 Display resolution
1. Detect the Sandbox – Artificial Environment
wmic cpu get NumberOfCores
wmic memorychip get capacity
wmic diskdrive get size
wmic printer get name
wmic desktopmonitor get screenheight, screenwidth
wmic path win32_VideoController get name
9
 Huge attack surface
 Expensive to fake
Malware
• Give VM realistic resources
• Fake values
Counterm
.
1. Detect the Sandbox – Artificial Environment
User Artifacts
- Examples:
 Installed software
 Cookies, entered URLs
 Recently used files
 Entered commands
REG_KEYS = [
# Office MRU lists
"SOFTWAREMicrosoftOfficeVERSIONPRODUCTFile MRU",
"SOFTWAREMicrosoftOfficeVERSIONPRODUCTPlace MRU",
"SOFTWAREMicrosoftOfficeVERSIONPRODUCTUser MRU",
# Explorer Artifacts
"SOFTWAREMicrosoftWindowsCurrentVersionExplorerTypedPaths"
"SOFTWAREMicrosoftWindowsCurrentVersionExplorerWordWheelQuery"
"SOFTWAREMicrosoftWindowsCurrentVersionExplorerRunMRU"
"SOFTWAREMicrosoftWindowsCurrentVersionExplorerComDlg32*",
# IE
"SOFTWAREMicrosoftInternet ExplorerTypedURLs",
"SOFTWAREMicrosoftInternet ExplorerTypedURLsTime",
...
]
10
 Huge attack surface
 Can be faked (laborious but not
complex)
Malware
• Add random data
Counterm
.
2. Defeat the Monitor
• Exploit weaknesses in the monitor
• Most attacks only work against a single product or
underlying technology
• Some methods only effective vs. in-guest monitoring (i.e.
Hooking)
• Others more generic and work in all sandboxes
2. Defeat the Monitor
12
Remove Hooks
• Examples:
- Restore instructions from
disk (check signature )
- Restore IAT, EAT
2. Defeat the Monitor – Hooking
0x00: call API
API
0x00: mov edi, edi
0x01: push ebp
0x03: mov ebp, esp
0x05: push ecx
0x07: … more …
0xff: ret
Hooked
0x00: jmp Hook
Reconstruct Instructions
0x00: call API
API
0x00: mov edi, edi
0x02: push ebp
0x03: mov ebp, esp
0x05: push ecx
0x07: … more …
0xff: ret
Regular
Hook Function
13
 Noticeable
 Can cause instability
Malware
• Check hook integrity
Counterm
.
2. Defeat the Monitor – Hooking
Circumvent Hooks
• Examples:
- Use System calls
- Use undocumented
APIs
- Unaligned function
calls
0x00: call API
API
0x00: mov edi, edi
0x02: push ebp
0x03: mov ebp, esp
0x05: push ecx
0x07: … more …
0xff: ret
Regular Call
0x00: call API
API
0x00: mov edi, edi
0x01: push ebp
0x03: mov ebp, esp
0x05: push ecx
0x07: … more …
0xff: ret
Hooked Call
0x00: jmp Hook
0x00: push 0x0c
0x02: mov edi, edi
0x04: push ebp
0x05: mov ebp, esp
0x07: jmp API+0x5
API
0x00: mov edi, edi
0x01: push ebp
0x03: mov ebp, esp
0x05: push ecx
0x07: … more …
0xff: ret
„Unaligned Call“
0x00: jmp Hook
14
 Hard to counter
 Can cause instability
Malware
• Move hooks deeper
into the system
Counterm
.
Delay Execution
• Execute malicious code after timeout
• Implementations range from simple to
complex
• Problems:
- Multitude of different time sources
 GetTickCount, RDTSC, SharedUserData,
internet, …
- Multitude of timer functions
 Sleep, WaitFor*Object, SetTimer,
timeSetEvent, …
2. Defeat the Monitor – Generic
Sleep(10 * 60 * 1000);
do_evil();
15
Time
Malware
Execution
Sandbox Timeout
Effective AnalysisTime
 Hard to counter (if done
right)
 Easy to implement
Malware
Delay Execution
Fast Forward Sandbox Execution
- Patch particular calls
 Problems: Risk of inconsistent state, e.g., all time sources need to be synced
- Manipulate timer behavior
 Problems: Could cause system instabilities, not trivial to implement
- Manipulate whole system time
 Problems: Could cause system instabilities, increases system load
2. Defeat the Monitor – Generic
16
DWORD evil_thread(void *p) {
Sleep(10 * 60 * 1000);
do_evil();
}
CreateThread(..., &evil_thread, ...);
Sleep(10 * 3600 * 1000);
TerminateProcess(-1, 0);
Counterm.
Exploit Monitoring Costs
• Monitoring consumes CPU time  malware execution takes longer
• Use code that is computationally intensive for the monitor
• Postpone malicious behavior until after sandbox timeout
• Examples:
- API hammering
2. Defeat the Monitor – Generic
Time
Normal
execution
Monitored
execution
Sandbox Timeout
Effective AnalysisTime
17
 Easy to implement
 Generally very noisy
Malware
• Adaptively (de)
activate the monitor
Counterm
.
Probabilistic JS decoding
- Decoder is generated in brute-force fashion
- Without monitoring, payload is generated in one minute
- With monitoring:
 Monitoring the interpreter costs time
 eval() calls are expensive for analysis environments
 Result: Execution time increases by an order of one magnitude
2. Defeat the Monitor – Case Study
function e37b0(){
return new Array('a7493','ret','ec468')[Math.floor(Math.random()*3)];
}
function b32eb(){
return new Array('a7493','arCode(parseIn','ec468')[Math.floor(Math.random()*3)];
}
function e46ef(){
return new Array('a7493','.substr(2,2),1','ec468','ec468','ec468')[Math.floor(Math.random()*5)];
}
function eb6e0(aad69){
return (new Function('ec071',''+e37b0()+''+'urn'+''+' String'+''+'.fromCh'+b32eb()+'t(ec071'+e46ef()+'6)^6)')(aad69));
}
18
3. Context Awareness
• Neither detect nor defeat sandbox
• Instead execute payload only in certain context
• Different variants:
- Wait to trigger condition, e.g., user interaction
- Check for specific environment, e.g., company domain
3. Context Awareness
20
• Specific User interaction
- Automated Sandboxes can not
interact meaningfully
- Examples:
 Fake installers
 Documents requiring interaction
 Only interact with an opened browser
3. Context Awareness – User Interaction
21
 Hard to fake ‘meaningful’
interaction
 Makes the malware visible
 Requires user ‘cooperation’
Malware
• Locate and click buttons
• Automatic mouse movement
Counterm
.
Context checks
• Examples:
- Date
- Time zone
- Username
3. Context Awareness – Explicit Checks
SYSTEMTIME st;
GetSystemTime(&st);
if (st.wYear == 2017 && st.wMonth == 6
&& st.wDay == 13)
do_evil();
22
 Easy to implement
Malware
• Use symbolic execution to find
constraints
• Problems: Very costly, hard to
resolve complex scenarios
Counterm
.
Environmental keying
• Malicious payload is encrypted
• Decryption key derived from environment
markers
• Examples:
- Gauss: A characteristic combination of path and
folder were chosen to generate EMBEDDED_HASH
- Ebowla: Framework to build environmental keyed
payloads
3. Context Awareness – Implicit Checks
for path in PATH:
for folder in PROGRAMFILES:
if hash(path + folder) == EMBEDDED_HASH:
decrypt_and_do_evil(path, folder)
23
 Very hard to detect and defeat
automatically
o Inhibits spreading
Malware
• Implement heuristics which are looking
for use of cryptography
• Detonate malware in target(like)
Counterm
.
Summary
• There is no silver bullet  each technique requires specific handling
• Many evasion attempts are noisy, therefore detectable (at least from ring -1)
We should
• Use realistic environments, e.g. cookies, MRU, …
• Use non fingerprint-able environments, e.g. randomize files, usernames, …
• Detonate in expected target environment, e.g., golden image
• Other:
- Analyze within different environments, e.g., OS patch level, network config
- Constantly adapt new anti evasion techniques
Summary
25
Thank you for your attention!
fbesler@vmray.com
• https://github.com/LordNoteworthy/al-khaser
• https://github.com/AlicanAkyol/sems
• https://github.com/Th4nat0s/No_Sandboxes
• https://github.com/Genetic-Malware/Ebowla
• https://github.com/a0rtega/pafish
• https://github.com/CheckPointSW/InviZzzible
• https://github.com/hfiref0x/VMDE
Tools
27
• https://www.vmray.com/blog/sandbox-evasion-techniques-part-1/
• https://www.vmray.com/blog/sandbox-evasion-techniques-part-2/
• https://www.vmray.com/blog/sandbox-evasion-techniques-part-3/
• https://www.vmray.com/blog/sandbox-evasion-techniques-part-4/
• https://www.joesecurity.org/blog/3660886847485093803
• https://www.botconf.eu/2015/sandbox-detection-for-the-masses-leak-abuse-test/
• https://www.blackhat.com/docs/asia-15/materials/asia-15-Chubachi-Slime-Automated-Anti-Sandboxing-Disarmament-System.pdf
• https://www.usenix.org/sites/default/files/conference/protected-files/sec14_slides_shi-hao.pdf
• https://aurelien.wail.ly/publications/hip-2013-slides.html
• https://www.botconf.eu/wp-content/uploads/2014/12/2014-2.7-Bypassing-Sandboxes-for-Fun.pdf
• https://www.virusbulletin.com/blog/2016/december/vb2016-paper-defeating-sandbox-evasion-how-increase-successful-emulation-rate-
your-virtualized-environment/
• https://www.securitee.org/files/wearntear-oakland2017.pdf
• https://securelist.com/33561/the-mystery-of-the-encrypted-gauss-payload-5/
References
28

More Related Content

What's hot

aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundDirkjanMollema
 
(Ab)Using GPOs for Active Directory Pwnage
(Ab)Using GPOs for Active Directory Pwnage(Ab)Using GPOs for Active Directory Pwnage
(Ab)Using GPOs for Active Directory PwnagePetros Koutroumpis
 
DerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting RevisitedDerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting RevisitedWill Schroeder
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgSam Bowne
 
Kerberos, NTLM and LM-Hash
Kerberos, NTLM and LM-HashKerberos, NTLM and LM-Hash
Kerberos, NTLM and LM-HashAnkit Mehta
 
semaphore & mutex.pdf
semaphore & mutex.pdfsemaphore & mutex.pdf
semaphore & mutex.pdfAdrian Huang
 
Linux presentation
Linux presentationLinux presentation
Linux presentationNikhil Jain
 
Abusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get itAbusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get itBenjamin Delpy
 
Derbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryWill Schroeder
 
Trusts You Might Have Missed
Trusts You Might Have MissedTrusts You Might Have Missed
Trusts You Might Have MissedWill Schroeder
 
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs BlueCatch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs BlueWill Schroeder
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiCysinfo Cyber Security Community
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesMikhail Egorov
 
Hunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows EnvironmentHunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows EnvironmentTeymur Kheirkhabarov
 
Building an Empire with PowerShell
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShellWill Schroeder
 
JavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame GraphsJavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame GraphsBrendan Gregg
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemRoss Wolf
 

What's hot (20)

I hunt sys admins 2.0
I hunt sys admins 2.0I hunt sys admins 2.0
I hunt sys admins 2.0
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHound
 
(Ab)Using GPOs for Active Directory Pwnage
(Ab)Using GPOs for Active Directory Pwnage(Ab)Using GPOs for Active Directory Pwnage
(Ab)Using GPOs for Active Directory Pwnage
 
DerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting RevisitedDerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting Revisited
 
RAT - Repurposing Adversarial Tradecraft
RAT - Repurposing Adversarial TradecraftRAT - Repurposing Adversarial Tradecraft
RAT - Repurposing Adversarial Tradecraft
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
Kerberos, NTLM and LM-Hash
Kerberos, NTLM and LM-HashKerberos, NTLM and LM-Hash
Kerberos, NTLM and LM-Hash
 
semaphore & mutex.pdf
semaphore & mutex.pdfsemaphore & mutex.pdf
semaphore & mutex.pdf
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Abusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get itAbusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get it
 
spinlock.pdf
spinlock.pdfspinlock.pdf
spinlock.pdf
 
Derbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active DirectoryDerbycon - The Unintended Risks of Trusting Active Directory
Derbycon - The Unintended Risks of Trusting Active Directory
 
Trusts You Might Have Missed
Trusts You Might Have MissedTrusts You Might Have Missed
Trusts You Might Have Missed
 
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs BlueCatch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
 
Hacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sitesHacking Adobe Experience Manager sites
Hacking Adobe Experience Manager sites
 
Hunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows EnvironmentHunting for Privilege Escalation in Windows Environment
Hunting for Privilege Escalation in Windows Environment
 
Building an Empire with PowerShell
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShell
 
JavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame GraphsJavaOne 2015 Java Mixed-Mode Flame Graphs
JavaOne 2015 Java Mixed-Mode Flame Graphs
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find Them
 

Similar to Countering Innovative Sandbox Evasion Techniques Used by Malware

unit 2 confinement techniques.pdf
unit 2 confinement techniques.pdfunit 2 confinement techniques.pdf
unit 2 confinement techniques.pdfRohitGautam261127
 
TENTACLE: Environment-Sensitive Malware Palpation(PacSec 2014)
TENTACLE: Environment-Sensitive Malware Palpation(PacSec 2014)TENTACLE: Environment-Sensitive Malware Palpation(PacSec 2014)
TENTACLE: Environment-Sensitive Malware Palpation(PacSec 2014)FFRI, Inc.
 
Dealing with legacy code
Dealing with legacy codeDealing with legacy code
Dealing with legacy codeG Prachi
 
Full-System Emulation Achieving Successful Automated Dynamic Analysis of Evas...
Full-System Emulation Achieving Successful Automated Dynamic Analysis of Evas...Full-System Emulation Achieving Successful Automated Dynamic Analysis of Evas...
Full-System Emulation Achieving Successful Automated Dynamic Analysis of Evas...Lastline, Inc.
 
BlueHat v18 || Malicious user profiling using a deep neural net
BlueHat v18 || Malicious user profiling using a deep neural netBlueHat v18 || Malicious user profiling using a deep neural net
BlueHat v18 || Malicious user profiling using a deep neural netBlueHat Security Conference
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource KernelsSilvio Cesare
 
how-to-bypass-AM-PPL
how-to-bypass-AM-PPLhow-to-bypass-AM-PPL
how-to-bypass-AM-PPLnitinscribd
 
Project Malware AnalysisCS 6262 Project 3Agenda.docx
Project Malware AnalysisCS 6262 Project 3Agenda.docxProject Malware AnalysisCS 6262 Project 3Agenda.docx
Project Malware AnalysisCS 6262 Project 3Agenda.docxbriancrawford30935
 
Thinking Outside the Sand[box]
Thinking Outside the Sand[box]Thinking Outside the Sand[box]
Thinking Outside the Sand[box]Juniper Networks
 
a framework for fingerprinting ICS honeypots
a framework for fingerprinting ICS honeypotsa framework for fingerprinting ICS honeypots
a framework for fingerprinting ICS honeypotsMohammad Reza Zamiri
 
Malwares Malwares Malwares Malwares Malwares
Malwares Malwares Malwares Malwares MalwaresMalwares Malwares Malwares Malwares Malwares
Malwares Malwares Malwares Malwares MalwaresNioLemuelLazatinConc
 
Threat Con 2021: What's Hitting my Honeypots
Threat Con 2021: What's Hitting my HoneypotsThreat Con 2021: What's Hitting my Honeypots
Threat Con 2021: What's Hitting my HoneypotsAPNIC
 
Алексей Старов - Как проводить киберраследования?
Алексей Старов - Как проводить киберраследования?Алексей Старов - Как проводить киберраследования?
Алексей Старов - Как проводить киберраследования?HackIT Ukraine
 
IoT exploitation: from memory corruption to code execution by Marco Romano
IoT exploitation: from memory corruption to code execution by Marco RomanoIoT exploitation: from memory corruption to code execution by Marco Romano
IoT exploitation: from memory corruption to code execution by Marco RomanoCodemotion
 
IoT exploitation: from memory corruption to code execution - Marco Romano - C...
IoT exploitation: from memory corruption to code execution - Marco Romano - C...IoT exploitation: from memory corruption to code execution - Marco Romano - C...
IoT exploitation: from memory corruption to code execution - Marco Romano - C...Codemotion
 
Malware Analysis 101: N00b to Ninja in 60 Minutes at BSidesDC on October 19, ...
Malware Analysis 101: N00b to Ninja in 60 Minutes at BSidesDC on October 19, ...Malware Analysis 101: N00b to Ninja in 60 Minutes at BSidesDC on October 19, ...
Malware Analysis 101: N00b to Ninja in 60 Minutes at BSidesDC on October 19, ...grecsl
 
Can We Prevent Use-after-free Attacks?
Can We Prevent Use-after-free Attacks?Can We Prevent Use-after-free Attacks?
Can We Prevent Use-after-free Attacks?inaz2
 
Virtual Machines Security Internals: Detection and Exploitation
 Virtual Machines Security Internals: Detection and Exploitation Virtual Machines Security Internals: Detection and Exploitation
Virtual Machines Security Internals: Detection and ExploitationMattia Salvi
 
Meder Kydyraliev - Mining Mach Services within OS X Sandbox
Meder Kydyraliev - Mining Mach Services within OS X SandboxMeder Kydyraliev - Mining Mach Services within OS X Sandbox
Meder Kydyraliev - Mining Mach Services within OS X SandboxDefconRussia
 

Similar to Countering Innovative Sandbox Evasion Techniques Used by Malware (20)

unit 2 confinement techniques.pdf
unit 2 confinement techniques.pdfunit 2 confinement techniques.pdf
unit 2 confinement techniques.pdf
 
TENTACLE: Environment-Sensitive Malware Palpation(PacSec 2014)
TENTACLE: Environment-Sensitive Malware Palpation(PacSec 2014)TENTACLE: Environment-Sensitive Malware Palpation(PacSec 2014)
TENTACLE: Environment-Sensitive Malware Palpation(PacSec 2014)
 
Dealing with legacy code
Dealing with legacy codeDealing with legacy code
Dealing with legacy code
 
Full-System Emulation Achieving Successful Automated Dynamic Analysis of Evas...
Full-System Emulation Achieving Successful Automated Dynamic Analysis of Evas...Full-System Emulation Achieving Successful Automated Dynamic Analysis of Evas...
Full-System Emulation Achieving Successful Automated Dynamic Analysis of Evas...
 
BlueHat v18 || Malicious user profiling using a deep neural net
BlueHat v18 || Malicious user profiling using a deep neural netBlueHat v18 || Malicious user profiling using a deep neural net
BlueHat v18 || Malicious user profiling using a deep neural net
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
 
how-to-bypass-AM-PPL
how-to-bypass-AM-PPLhow-to-bypass-AM-PPL
how-to-bypass-AM-PPL
 
Project Malware AnalysisCS 6262 Project 3Agenda.docx
Project Malware AnalysisCS 6262 Project 3Agenda.docxProject Malware AnalysisCS 6262 Project 3Agenda.docx
Project Malware AnalysisCS 6262 Project 3Agenda.docx
 
Thinking Outside the Sand[box]
Thinking Outside the Sand[box]Thinking Outside the Sand[box]
Thinking Outside the Sand[box]
 
a framework for fingerprinting ICS honeypots
a framework for fingerprinting ICS honeypotsa framework for fingerprinting ICS honeypots
a framework for fingerprinting ICS honeypots
 
Unity makes strength
Unity makes strengthUnity makes strength
Unity makes strength
 
Malwares Malwares Malwares Malwares Malwares
Malwares Malwares Malwares Malwares MalwaresMalwares Malwares Malwares Malwares Malwares
Malwares Malwares Malwares Malwares Malwares
 
Threat Con 2021: What's Hitting my Honeypots
Threat Con 2021: What's Hitting my HoneypotsThreat Con 2021: What's Hitting my Honeypots
Threat Con 2021: What's Hitting my Honeypots
 
Алексей Старов - Как проводить киберраследования?
Алексей Старов - Как проводить киберраследования?Алексей Старов - Как проводить киберраследования?
Алексей Старов - Как проводить киберраследования?
 
IoT exploitation: from memory corruption to code execution by Marco Romano
IoT exploitation: from memory corruption to code execution by Marco RomanoIoT exploitation: from memory corruption to code execution by Marco Romano
IoT exploitation: from memory corruption to code execution by Marco Romano
 
IoT exploitation: from memory corruption to code execution - Marco Romano - C...
IoT exploitation: from memory corruption to code execution - Marco Romano - C...IoT exploitation: from memory corruption to code execution - Marco Romano - C...
IoT exploitation: from memory corruption to code execution - Marco Romano - C...
 
Malware Analysis 101: N00b to Ninja in 60 Minutes at BSidesDC on October 19, ...
Malware Analysis 101: N00b to Ninja in 60 Minutes at BSidesDC on October 19, ...Malware Analysis 101: N00b to Ninja in 60 Minutes at BSidesDC on October 19, ...
Malware Analysis 101: N00b to Ninja in 60 Minutes at BSidesDC on October 19, ...
 
Can We Prevent Use-after-free Attacks?
Can We Prevent Use-after-free Attacks?Can We Prevent Use-after-free Attacks?
Can We Prevent Use-after-free Attacks?
 
Virtual Machines Security Internals: Detection and Exploitation
 Virtual Machines Security Internals: Detection and Exploitation Virtual Machines Security Internals: Detection and Exploitation
Virtual Machines Security Internals: Detection and Exploitation
 
Meder Kydyraliev - Mining Mach Services within OS X Sandbox
Meder Kydyraliev - Mining Mach Services within OS X SandboxMeder Kydyraliev - Mining Mach Services within OS X Sandbox
Meder Kydyraliev - Mining Mach Services within OS X Sandbox
 

Recently uploaded

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Recently uploaded (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Countering Innovative Sandbox Evasion Techniques Used by Malware

  • 1. COUNTERING INNOVATIVE SANDBOX EVASION TECHNIQUES USED BY MALWARE Frederic Besler, Carsten Willems, and Ralf Hund
  • 2. • State of the Art malware analysis systems use hybrids of static and dynamic analysis • Dynamic analysis usually in form of behavior based detection aka. sandbox • Malware tries to detect and evade sandbox • We need to talk about sandbox evasion and anti-evasion Introduction 2
  • 3. Evasion Techniques - Categories 1. Detect the Sandbox 2. Defeat the Monitor 3. Context Awareness * Categories are fuzzy and overlap 3
  • 4. 1. Detect the Sandbox
  • 5. • Actively detect the analysis environment - If in analysis environment: Quit or act benign - Else: Execute the malicious code • Most commonly used methods: - Detect underlying technology, e.g. hypervisor or emulator - Detect specific sandbox product, e.g. check for files or processes - Detect artificial environments, e.g. check for “clean” system 1. Detect the Sandbox 5
  • 6.  Large attack surface  Essential virtual devices are hard to hide Malware Detect Virtualization via Artifacts - Examples:  Registry, Files (Software, Drivers), Processes  Device Names, Device IDs, MACs  SMBIOS, ACPI tables  IO Ports (VMWare, KVM/Qemu) 1. Detect the Sandbox – Virtualization Artifacts REG_BLACKLIST = ["vbox", "vmware", "bochs", "qemu","red.?hat", "virt.?io", "kvmnet", "netkvm", ...] PROC_BLACKLIST = ["vbox.*.exe", "vmware.*.exe", "prl_.*.exe", ...] VENDOR_IDS = { 0x1a71: "XenSource, Inc." 0x5853: "XenSource, Inc." 0xfffd: "XenSource, Inc." 0x15ad: "VMware" 0xfffe: "VMWare Inc (temporary ID)" # VBox 0x80ee: "InnoTek Systemberatung GmbH" # QEMU/KVM 0x1af4: "Red Hat, Inc." 0x1b36: "Red Hat, Inc." 0x1ab8: "Parallels, Inc." } 6 • Clean registry, remove files, … • Don’t use paravirt. Devices • Use custom hypervisor Counterm.
  • 7. CPUID - CPU tells guest that it is virtualized - Examples:  CPUID Hypervisor Bit  CPUID Hypervisor Brand String  Other CPUID Artifacts (e.g. Function 0x80000009) 1. Detect the Sandbox – Virtualization struct { int EAX; int EBX; int ECX; int EDX; } out; __cpuidex((int*)&out, 1, 0); if (!(out.ECX >> 31)) do_evil(); char out[4 * 4 + 1] = { 0 }; __cpuidex((int*)out, 0x40000000, 0); if (strlen(out + 4) >= 4) do_evil(); Real System Virtualized System 7  No false positives  Can be disabled (requires support of HV) Malwar e • Disable where possible Counterm .
  • 8. 1. Detect the Sandbox – Virtualization Side Channels - HV consumes CPU cycles - HV and VM(s) share resources - Examples:  Time instructions  Time caching side effects long long s, acc = 0; int out[4]; for (int i = 0; i < 100; ++i) { s = __rdtsc(); __cpuidex(out, 0, 0); acc += __rdtsc() - s; } if (acc / 100 < 200) do_evil(); Real System Virtualized System 8  Very hard to prevent  Specific to hardware  Can be noisy Malware • Heuristics to detect specific attacks • Spoof timer values Counterm .
  • 9. Unusual Hardware Characteristics - Examples:  CPU type, number cores  HD space, Ram  Printers  USB devices/sticks  Display resolution 1. Detect the Sandbox – Artificial Environment wmic cpu get NumberOfCores wmic memorychip get capacity wmic diskdrive get size wmic printer get name wmic desktopmonitor get screenheight, screenwidth wmic path win32_VideoController get name 9  Huge attack surface  Expensive to fake Malware • Give VM realistic resources • Fake values Counterm .
  • 10. 1. Detect the Sandbox – Artificial Environment User Artifacts - Examples:  Installed software  Cookies, entered URLs  Recently used files  Entered commands REG_KEYS = [ # Office MRU lists "SOFTWAREMicrosoftOfficeVERSIONPRODUCTFile MRU", "SOFTWAREMicrosoftOfficeVERSIONPRODUCTPlace MRU", "SOFTWAREMicrosoftOfficeVERSIONPRODUCTUser MRU", # Explorer Artifacts "SOFTWAREMicrosoftWindowsCurrentVersionExplorerTypedPaths" "SOFTWAREMicrosoftWindowsCurrentVersionExplorerWordWheelQuery" "SOFTWAREMicrosoftWindowsCurrentVersionExplorerRunMRU" "SOFTWAREMicrosoftWindowsCurrentVersionExplorerComDlg32*", # IE "SOFTWAREMicrosoftInternet ExplorerTypedURLs", "SOFTWAREMicrosoftInternet ExplorerTypedURLsTime", ... ] 10  Huge attack surface  Can be faked (laborious but not complex) Malware • Add random data Counterm .
  • 11. 2. Defeat the Monitor
  • 12. • Exploit weaknesses in the monitor • Most attacks only work against a single product or underlying technology • Some methods only effective vs. in-guest monitoring (i.e. Hooking) • Others more generic and work in all sandboxes 2. Defeat the Monitor 12
  • 13. Remove Hooks • Examples: - Restore instructions from disk (check signature ) - Restore IAT, EAT 2. Defeat the Monitor – Hooking 0x00: call API API 0x00: mov edi, edi 0x01: push ebp 0x03: mov ebp, esp 0x05: push ecx 0x07: … more … 0xff: ret Hooked 0x00: jmp Hook Reconstruct Instructions 0x00: call API API 0x00: mov edi, edi 0x02: push ebp 0x03: mov ebp, esp 0x05: push ecx 0x07: … more … 0xff: ret Regular Hook Function 13  Noticeable  Can cause instability Malware • Check hook integrity Counterm .
  • 14. 2. Defeat the Monitor – Hooking Circumvent Hooks • Examples: - Use System calls - Use undocumented APIs - Unaligned function calls 0x00: call API API 0x00: mov edi, edi 0x02: push ebp 0x03: mov ebp, esp 0x05: push ecx 0x07: … more … 0xff: ret Regular Call 0x00: call API API 0x00: mov edi, edi 0x01: push ebp 0x03: mov ebp, esp 0x05: push ecx 0x07: … more … 0xff: ret Hooked Call 0x00: jmp Hook 0x00: push 0x0c 0x02: mov edi, edi 0x04: push ebp 0x05: mov ebp, esp 0x07: jmp API+0x5 API 0x00: mov edi, edi 0x01: push ebp 0x03: mov ebp, esp 0x05: push ecx 0x07: … more … 0xff: ret „Unaligned Call“ 0x00: jmp Hook 14  Hard to counter  Can cause instability Malware • Move hooks deeper into the system Counterm .
  • 15. Delay Execution • Execute malicious code after timeout • Implementations range from simple to complex • Problems: - Multitude of different time sources  GetTickCount, RDTSC, SharedUserData, internet, … - Multitude of timer functions  Sleep, WaitFor*Object, SetTimer, timeSetEvent, … 2. Defeat the Monitor – Generic Sleep(10 * 60 * 1000); do_evil(); 15 Time Malware Execution Sandbox Timeout Effective AnalysisTime  Hard to counter (if done right)  Easy to implement Malware
  • 16. Delay Execution Fast Forward Sandbox Execution - Patch particular calls  Problems: Risk of inconsistent state, e.g., all time sources need to be synced - Manipulate timer behavior  Problems: Could cause system instabilities, not trivial to implement - Manipulate whole system time  Problems: Could cause system instabilities, increases system load 2. Defeat the Monitor – Generic 16 DWORD evil_thread(void *p) { Sleep(10 * 60 * 1000); do_evil(); } CreateThread(..., &evil_thread, ...); Sleep(10 * 3600 * 1000); TerminateProcess(-1, 0); Counterm.
  • 17. Exploit Monitoring Costs • Monitoring consumes CPU time  malware execution takes longer • Use code that is computationally intensive for the monitor • Postpone malicious behavior until after sandbox timeout • Examples: - API hammering 2. Defeat the Monitor – Generic Time Normal execution Monitored execution Sandbox Timeout Effective AnalysisTime 17  Easy to implement  Generally very noisy Malware • Adaptively (de) activate the monitor Counterm .
  • 18. Probabilistic JS decoding - Decoder is generated in brute-force fashion - Without monitoring, payload is generated in one minute - With monitoring:  Monitoring the interpreter costs time  eval() calls are expensive for analysis environments  Result: Execution time increases by an order of one magnitude 2. Defeat the Monitor – Case Study function e37b0(){ return new Array('a7493','ret','ec468')[Math.floor(Math.random()*3)]; } function b32eb(){ return new Array('a7493','arCode(parseIn','ec468')[Math.floor(Math.random()*3)]; } function e46ef(){ return new Array('a7493','.substr(2,2),1','ec468','ec468','ec468')[Math.floor(Math.random()*5)]; } function eb6e0(aad69){ return (new Function('ec071',''+e37b0()+''+'urn'+''+' String'+''+'.fromCh'+b32eb()+'t(ec071'+e46ef()+'6)^6)')(aad69)); } 18
  • 20. • Neither detect nor defeat sandbox • Instead execute payload only in certain context • Different variants: - Wait to trigger condition, e.g., user interaction - Check for specific environment, e.g., company domain 3. Context Awareness 20
  • 21. • Specific User interaction - Automated Sandboxes can not interact meaningfully - Examples:  Fake installers  Documents requiring interaction  Only interact with an opened browser 3. Context Awareness – User Interaction 21  Hard to fake ‘meaningful’ interaction  Makes the malware visible  Requires user ‘cooperation’ Malware • Locate and click buttons • Automatic mouse movement Counterm .
  • 22. Context checks • Examples: - Date - Time zone - Username 3. Context Awareness – Explicit Checks SYSTEMTIME st; GetSystemTime(&st); if (st.wYear == 2017 && st.wMonth == 6 && st.wDay == 13) do_evil(); 22  Easy to implement Malware • Use symbolic execution to find constraints • Problems: Very costly, hard to resolve complex scenarios Counterm .
  • 23. Environmental keying • Malicious payload is encrypted • Decryption key derived from environment markers • Examples: - Gauss: A characteristic combination of path and folder were chosen to generate EMBEDDED_HASH - Ebowla: Framework to build environmental keyed payloads 3. Context Awareness – Implicit Checks for path in PATH: for folder in PROGRAMFILES: if hash(path + folder) == EMBEDDED_HASH: decrypt_and_do_evil(path, folder) 23  Very hard to detect and defeat automatically o Inhibits spreading Malware • Implement heuristics which are looking for use of cryptography • Detonate malware in target(like) Counterm .
  • 25. • There is no silver bullet  each technique requires specific handling • Many evasion attempts are noisy, therefore detectable (at least from ring -1) We should • Use realistic environments, e.g. cookies, MRU, … • Use non fingerprint-able environments, e.g. randomize files, usernames, … • Detonate in expected target environment, e.g., golden image • Other: - Analyze within different environments, e.g., OS patch level, network config - Constantly adapt new anti evasion techniques Summary 25
  • 26. Thank you for your attention! fbesler@vmray.com
  • 27. • https://github.com/LordNoteworthy/al-khaser • https://github.com/AlicanAkyol/sems • https://github.com/Th4nat0s/No_Sandboxes • https://github.com/Genetic-Malware/Ebowla • https://github.com/a0rtega/pafish • https://github.com/CheckPointSW/InviZzzible • https://github.com/hfiref0x/VMDE Tools 27
  • 28. • https://www.vmray.com/blog/sandbox-evasion-techniques-part-1/ • https://www.vmray.com/blog/sandbox-evasion-techniques-part-2/ • https://www.vmray.com/blog/sandbox-evasion-techniques-part-3/ • https://www.vmray.com/blog/sandbox-evasion-techniques-part-4/ • https://www.joesecurity.org/blog/3660886847485093803 • https://www.botconf.eu/2015/sandbox-detection-for-the-masses-leak-abuse-test/ • https://www.blackhat.com/docs/asia-15/materials/asia-15-Chubachi-Slime-Automated-Anti-Sandboxing-Disarmament-System.pdf • https://www.usenix.org/sites/default/files/conference/protected-files/sec14_slides_shi-hao.pdf • https://aurelien.wail.ly/publications/hip-2013-slides.html • https://www.botconf.eu/wp-content/uploads/2014/12/2014-2.7-Bypassing-Sandboxes-for-Fun.pdf • https://www.virusbulletin.com/blog/2016/december/vb2016-paper-defeating-sandbox-evasion-how-increase-successful-emulation-rate- your-virtualized-environment/ • https://www.securitee.org/files/wearntear-oakland2017.pdf • https://securelist.com/33561/the-mystery-of-the-encrypted-gauss-payload-5/ References 28