25
1 Satoshi Tanda Threat Researcher Monitoring & Controlling Kernel-mode Events by HyperPlaorm

Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

1

Satoshi TandaThreat Researcher

Monitoring & Controlling Kernel-mode Events by HyperPlatform

Page 2: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

2

Page 3: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

3

● If you want to have more ability to monitor and control Windows system activities in a lightweight manner, HyperPlatfrom is for you

● HyperPlatfrom is the hypervisor designed as a VM-exit filtering platform to utilize virtualization technology (VT) and write new types of tools on Windows quicker and easier

Takeaway

Page 4: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

4

● Satoshi Tanda (@standa_t)– Reverse engineer interested in the Windows kernel

– Implemented HyperPlatform

– Threat Researcher at Sophos specializing in behaviour based detection on Windows

● Igor Korkin (@Igorkorkin)– An independent researcher focusing on cyber security science:

memory forensics, rootkit detection & spy technologies

– Co-researcher, focused on application of HyperPlatform

About Us

Page 5: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

5

● Issue: Lack of tools for kernel mode code analysis on Windows– Debugger and IDA are time consuming

– Existing tools were not efficient

● Solution: Virtualization Technology (VT) – Plenty of analysis systems, and academic papers

– VT is more than just sandbox

Background

Page 6: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

6

● No suitable hypervisor to take advantage of VT only for system monitoring on Windows

● Existing lightweight hypervisors for Windows?– lacked modern platform support

● More comprehensive hypervisors?– Too large to understand and extend

– Not straightforward to compile and run

– Very slow (i.e., Bochs)

Challenges

Page 7: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

7

● Lack of tools to monitor kernel activities

● Commercial and proprietary

● Insufficient modern platform support

● Large to use VT just for system monitoring

● Not Windows researchers friendly

● Too slow

Challenges: Summary

Page 8: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

8

● Allows you to monitor system activities incl. kernel-mode

● Open source under the relaxed license (MIT License)

● Supports Windows 7-10 on x86/x64

● Small (7KLOC)

● Can be compiled on Visual Studio w/o any 3rd party libraries, and debugged just like ordinary Windows drivers

● Fast (about 10% of overhead)

Answer: HyperPlatform

Page 9: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

9

Processors

User Mode

Kernel Mode

How It Works: Overview

Applications

Kernel Drivers HyperPlatform.sys

Enables VMX operation mode

Page 10: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

10

Processors VMX enabled

User Mode

Kernel Mode

How It Works: Overview

Applications

Kernel Drivers HyperPlatform.sys

CPUID

MOV CR3, RAX Exception VMExitHandler()

VM-exit handler is executed upon occurrence of certain events (VM-exit)

VM-exit

Page 11: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

11

void VMExitHandler( GuestRegisters* context, int exit_reason) { switch (exit_reason) { case VMEXIT_CPUID: CpuidHandler(context); break; case VMEXIT_EXCEPTION: ExceptionHandler(context); break; //... }}

How It Works: Implementation

Context of the system andVM-exit reason are given

Invoked on VM-exit

Handle an event accordingly

Page 12: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

12

HyperPlatform

Processors VMX enabled

As a VM-exit Filtering Platform

MOV CR3, RAX Exception

VM-exit

CPUID

WindowsMOV CR3, RAX

Your extended logic for“move-to-cr3” event

YourDriver.sys

Page 13: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

13

● You can do what you cannot do without VT

● VM-exit is a new class of events – access to system registers

– occurrence of exceptions and interruptions

– execution of certain instructions

– access to memory using extended page tables (EPT)

● VM-exit handler is flexible– returning different register values and/or memory contents

● None of them is easy to achieve without VT

Advantage

Page 14: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

14

● Kernel mode code analysis– Detection of dodgy instruction execution (e.g., modification of

CR0.WP)● GuardMon – PatchGuard monitor

– Detection of pool memory execution● MemoryMon – Memory execution monitor

– Invisible API hook● DdiMon – kernel-mode API monitor

Application (part 1)

driver_x.sys

driver_y.sys

driver_z.sys

Kernel space

Execution OK

ExecutionDodgyPool Memory

Page 15: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

15

● MemoryMon against Turla (Uroburos)– getting unpacked code from memory

Demo (part 1)

Page 16: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

16

● Hypervisor based protection– Instead of monitoring, terminate a process upon dodgy events

– Checking certain conditions on task switching● EopMon – elevation of privilege exploit (token stealing) monitor

Application (part 2)

Time

Running

Running

MOV CR3, RAX

Running

MOV CR3, RAX

EopMonCheck

Check

Process A

Process B

Process C

VM-exit

VM-exit

Page 17: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

17

● EopMon against Gozi (Ursnif)– Detecting and killing elevated malware (stole a system token)

Demo (part 2)

Page 18: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

18

● Cannot run inside VirtualBox by design

● No AMD processors support (#2, won't fix)

● Cannot run with other hypervisors simultaneously (#14)

Limitations

Page 19: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

19

● Looking for more ideas on what we can do– Kernel code coverage with Intel Processor Trace for effective fuzzing

– Memory access visualization and authorization

– Race condition (TOCTOU) bug discovery with memory access monitoring

Future

Page 20: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

20

● Virtualization technology (VT) is powerful but underutilized in reverse engineering

● HyperPlatfrom is the hypervisor designed as a VM-exit filtering platform to utilize VT and write new types of tools on Windows quickly and easily

● Check out GitHub pages, develop your own unique ideas and solutions– github.com/tandasat/HyperPlatform

Conclusion

Page 21: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

21

● Contacts:– Satoshi Tanda (@standa_t)

[email protected]– Igor Korkin (@Igorkorkin)

[email protected]

Thank You

Page 22: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

22

Appendix 1: Performance Metrics

PCMark8 HomeNovabench RAM Speed

Novabench CPU TestsNovabench Graphics Tests

Novabench Drive Write Speed

0%

10%

20%

30%

40%

50%

60%

70%

80%

90%

100%

Performence Comparison Base

EopMon

MemoryMon

Page 23: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

23

● VMRay

– https://www.vmray.com/features/

● McAfee Deep Defender

– http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/mcafee-deep-defender-deepsafe-rootkit-protection-paper.pdf

● SecVisor: A Tiny Hypervisor to Provide Lifetime Kernel Code Integrity for Commodity OSes

– https://www.cs.cmu.edu/~arvinds/pubs/secvisor.pdf

● SPIDER: Stealthy Binary Program Instrumentation and Debugging via Hardware Virtualization

– https://www.cerias.purdue.edu/assets/pdf/bibtex_archive/2013-5.pdf

● DRAKVUF

– http://drakvuf.com/

References 1

Page 24: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

24

● HyperDbg

– https://github.com/rmusser01/hyperdbg

● Virtdbg

– https://github.com/upring/virtdbg

● BluePill

– http://invisiblethingslab.com/resources/bh07/nbp-0.32-public.zip

● MoRE

– https://github.com/ainfosec/MoRE

References 2

Page 25: Monitoring & Controlling Kernel-mode Events by HyperPlatformtandasat.github.io/HyperPlatform/recon2016/REcon2016_presentatio… · 3 If you want to have more ability to monitor and

25

● Bochs

– https://github.com/svn2github/bochs

● Xen

– http://xenbits.xen.org/gitweb/?p=xen.git

● QEMU

– http://git.qemu.org/qemu.git

● VirtualBox

– https://www.virtualbox.org/

References 3