Home

Awesome

hvpp

hvpp is a lightweight Intel x64/VT-x hypervisor written in C++ focused primarily on virtualization of already running operating system.

Motivation

Although several open-source research hypervisors aimed at simplicity already exist, in my opinion this field is still somewhat unexplored and needs more open-source projects. This can especially help those who have just started exploring virtualization technologies and are looking for small/reference projects. If you're one of them, my bets are that you're really disappointed right now, because all you've got are barely dozen of (great!) projects and huge pile of Intel Manual pages.

C++ has been chosen as a language for this project because of two reasons:

Even though this project is primarily developed for Windows, I've decided to not use traditional Windows Driver naming convention (aka DrvCamelCase). Instead, traditional C++ snake_case is used. The reason is that hypervisor is very "stand-alone" and doesn't depend on many OS functions. Therefore I decided to treat it as a regular C++ project.

If you want to challenge yourself in low-level programming, my advice would be to try and write a simple hypervisor. During the process you'll get invaluable knowledge and experience and you'll probably discover many new things. For instance here's a selection of some things I've learned thanks to writing this project:

Also - as obvious as it might sound - I'd like to point out that if you decide to write your own VT-x hypervisor, you'll NEED Intel® 64 and IA-32 architectures software developer’s manual combined volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4. So download the PDF - together with Adobe Acrobat Reader - because trust me, you don't want to read and navigate through 5000 pages with browser's built-in PDF reader.

Features

Code workflow

Note: hvpp is compiled as a static library, which is linked with the hvppdrv project.

Compilation

Compile hvpp using Visual Studio 2017. Solution file is included. The only required dependency is WDK.

Usage

You can run hvpp on Windows 7 or higher. Windows 10 is recommended though, because it supports TraceLogging.

Enable Test-Signing boot configuration option (note that you'll need administrative privileges to use bcdedit and sc commands):

bcdedit /set testsigning on

Register driver with Service Control Manager (yes, it's important to leave these spaces):

sc create hvpp type= kernel binPath= "C:\full\path\to\hvppdrv.sys"

Now you should restart your computer for testsigning to take effect, otherwise you'll be unable to start the driver. But before you do, you might want to prepare DebugView from SysInternals and traceview.exe tool from the WDK (note that traceview will work properly only on Windows 10).

After restart, launch DebugView and TraceView. In TraceView:

TraceView is now set-up and ready to show tracelogs from hvpp. You can launch hvpp now:

sc start hvpp

hvpp now performs various checks and enters VMX mode if they pass. In case of success you should see message hvpp started in the DebugView.

<p align="center"> <img src="img/sc-start.png" /> </p>

Run hvppctrl:

hvppctrl.exe

Description of "stealth hooking" process

<p align="center"> <img src="img/hvppctrl.png" height="600" /> </p>

At the same time you should see tracelog messages in the TraceView - they are generated on each VMCALL and on each EPT Violation.

<p align="center"> <img src="img/traceview.png" /> </p>

When you decide you want to turn off the hvpp, just execute:

sc stop hvpp

<p align="center"> <img src="img/sc-stop.png" /> </p>

Remarks

License

This software is open-source under the MIT license. See the LICENSE.txt file in this repository.

Detours is licensed under MIT license (a copy of the license is included here).

udis86 is licensed under the terms of the 2-clause "Simplified BSD License" (a copy of the license is included here).

Similar work

SimpleVisor: https://github.com/ionescu007/SimpleVisor

HyperPlatform: https://github.com/tandasat/HyperPlatform

HyperBone: https://github.com/DarthTon/HyperBone

Bareflank: https://github.com/Bareflank/hypervisor

ksm: https://github.com/asamy/ksm

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

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

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

BluePill: https://invisiblethingslab.com/resources/bh07/nbp-0.32-public.zip

Phrack #69: http://www.phrack.org/issues/69/15.html

NOVA Microhypervisor: https://github.com/udosteinberg/NOVA

Finally, I'd especially like to suggest reading interesting writings from Satoshi Tanda (github, twitter):

And notes from LordNoteworthy (github, twitter):

If you find this project interesting, you can buy me a coffee

  BTC 3GwZMNGvLCZMi7mjL8K6iyj6qGbhkVMNMF
  LTC MQn5YC7bZd4KSsaj8snSg4TetmdKDkeCYk