Malware Analysis Professional: Anti-Reversing Tricks: Part 3
Malware Analysis Professional: Anti-Reversing Tricks: Part 3
Professional
Tools:
• Olly Debugger v1.10
Target:
• RE_Lab_12.zip
Introduction
Layout:
i) Anti-RE trick Category
a) Category-related trick example
b) Another related example
c) etc.
Software Breakpoint
Detection
…a typical example
push ‘kernel32.dll’
call LoadLibrary ;get imagebase of kernel32.dll
push ‘VirtualProtect’
push eax
GetProcAddress ;get address of ‘VirtualProtect’ API inside
exported by kernel32.dll
cmp byte ptr ds:[eax], 0xCC ;check if there is a breakpoint set
there
MAPv1: Section 02, Module 12 - Caendra Inc. © 2020 | p.18
12.4
Hardware Breakpoint
Detection
Structured Exception
Handling (SEH)
_exception_handler:
xor eax,eax ; if we arrive here debugger not present.
_continue:
;more code here
Unhandled
Exception Filter
In other words, the trick relies on the fact that we can set a
custom exception handler through the
SetUnhandledExceptionFilter API. When an exception is
raised, the UnhandledExceptionFilter will be called and will
also check if the process is being debugged.
VM Detection
There are many ways to achieve this, but some of them are
well-known and are widely used.
VMware detection
mov eax, ‘VMXh’ magic number
mov ebx, 0
mov ecx, 0Ah set function number / 0Ah = get VMware
version
mov edx, 5658h port number number used to communicate
with VMware
in eax, dx read a dword from that port
cmp eax, ebx if VMware is present EAX == EBX
je __VMware_detected
MAPv1: Section 02, Module 12 - Caendra Inc. © 2020 | p.40
12.8 VM Detection
VirtualPC detection
mov ebx, 0
mov eax, 1
db 0Fh, 3Fh, 7, 0Bh // VPC Call
cmp ebx, 0
je __VPC_detected
VirtualBox detection
A very simple and easy way to detect VirtualBox is through the
window class name of a tray icon that it places in the taskbar.
push 0
push ‘VBoxTrayToolWndclass’
call FindWindowA
test eax,eax
jnz _VboxDetected ; if we managed to obtain a valid window
handle VBox was detected
MAPv1: Section 02, Module 12 - Caendra Inc. © 2020 | p.45
12.8 VM Detection
Conclusion
However, there are many other tricks in the wild that you
might have to deal with and many variations of those we
talked about.
MAPv1: Section 02, Module 12 - Caendra Inc. © 2020 | p.48
12.9 Conclusion
RE_Lab_12.zip