• This repository has been archived on 19/Nov/2021
  • Stars
    star
    216
  • Rank 183,179 (Top 4 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created about 6 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LibVMI-based debug server, implemented in Python. Building a guest aware, stealth and agentless full-system debugger

pyvmidbg

Slack Build Status Join the chat at https://gitter.im/pyvmidbg/Lobby standard-readme compliant

LibVMI-based GDB server, implemented in Python

Table of Contents

Overview

This GDB stub allows you to debug a remote process running in a VM with your favorite GDB frontend.

By leveraging virtual machine introspection, the stub remains stealth and requires no modification of the guest.

Why debugging from the hypervisor ?

Operating systems debug API's are problematic:

  1. they have never been designed to deal with malwares, and lack the stealth and robustness required when analyzing malicious code
  2. they have an observer effect, by implicitly modifying the process environment being debugged
  3. this observer effect might be intentional to protect OS features (Windows PatchGuard/Protected Media Path are disabled)
  4. modern OS have a high degree of kernel security mechanisms that narrows the debugger's view of the system (Windows 10 Virtual Secure Mode)
  5. debugging low-level processes and kernel functions interacting directly with the transport protocol used by the debug agent can turn into a infinite recursion hell (eg. debugging TCP connections and having a kernel debug stub communicating via TCP)
  6. in special cases the "Operating System" lacks debugging capabilities (unikernels)

Existing solutions like GDB stubs included in QEMU, VMware or VirtualBox can only pause the VM and debug the kernel, but lack the guest knowledge to track and follow the rest of the processes.

Project presentation at Insomni'Hack 2019:

Vision

vmidbg

Current support:

  • Stubs:
    • GDB
  • Hypervisors:
    • Xen
    • KVM

State of hypervisor's VMI support

  • Xen
    • 2011: Xen 4.1: first hypervisor to support VMI upstream
    • 2015: Xen 4.6: best hypervisor for VMI
    • libvmi: fully supported
    • pyvmidbg: supported
  • KVM
    • 2017: BitDefender published a set VMI patches on the mailing list
    • libvmi: support is ongoing, see kvm-vmi/libvmi (branch kvmi)
    • pyvmidbg: supported
  • VirtualBox
  • VMware/Hyper-V: no sign of interest as of today

Features

  • attach to existing process
    • Windows: find EPROCESS and ETHREADS state
    • Linux: pause at CR3 load
  • attach new process (entrypoint):
    • Windows: follow first thread creation and break at entrypoint
    • Linux: not implemented
  • singlestep/continue: wait for the process to be scheduled
    • process must have a single thread
  • breakin (CTRL-C)
  • software breakpoints

Requirements

Install

virtualenv -p python3 venv
source venv/bin/activate
pip install .

Note: If you don't want to install Xen, vagrant-xen-pyvmidbg provides a Vagrant environment based on KVM, with ready to use Windows and Linux VMs.

Usage

vmidbg <port> <vm> [<process>]

Demo

Debugging cmd.exe in Windows XP

Demo link

  1. starts cmd.exe in Windows XP nested VM in Xen
  2. starts pyvmidbg and target a process named cmd
  3. connects to stub with radare2
  4. set breakpoints on ntdll!NtOpenFile and ntkrnlpa!NtOpenFile
  5. avoid breakpoints from the rest of the system, only hit if cmd.exe is executing

Debugging mspaint.exe in Windows 10

Debugging mspaint.exe

Limitations

  • the VM must have 1 VCPU
  • no steath breakpoints implemented yet (int3 into memory)

References

Maintainers

@Wenzel

Contributing

PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.

License

GNU General Public License v3.0

More Repositories

1

awesome-virtualization

Collection of resources about Virtualization
1,602
star
2

checksec.py

Checksec tool in Python, Rich output. Based on LIEF
Python
303
star
3

libmicrovmi

A cross-platform unified Virtual Machine Introspection API library
Rust
164
star
4

r2vmi

Hypervisor-Level Debugger based on Radare2 / LibVMI, using VMI IO and debug plugins
C
131
star
5

osw-fs-windows

A git history of Windows filesystems
78
star
6

oswatcher

A framework to track the evolution of Operating Systems over time
Python
57
star
7

docker-kdesrc-build

Dockerfiles to compile KDE source code into Docker with kdesrc-build script
Python
47
star
8

vid-sys

Rust unsafe bindings for Vid API (Hyper-V)
C
13
star
9

libsysinfo

Extracts information about running processes and network connections from the virtual filesystem /proc
CMake
11
star
10

protonvpn-nm-import

Script to import ProtonVPN configuration files into NetworkManager automatically
Python
10
star
11

linux-sysinternals

CMake
9
star
12

packer-templates-winxp

Batchfile
7
star
13

kvm-vmi

KVM-based Virtual Machine Introspection
Jinja
6
star
14

kvmi

Rust bindings to KVM's introspection libkvmi library
Rust
5
star
15

vagrant-xen-pyvmidbg

Vagrant box to work on pyvmidbg project
HTML
5
star
16

xenctrl

Rust
4
star
17

CNAF

Source code used by the French CNAF (Caisse Nationale des Allocations Familiales)
COBOL
4
star
18

packer-templates

My packer templates
Python
3
star
19

fdp

Rust bindings on FDP (Fast Debugging Protocol) VirtualBox introspection library
Rust
3
star
20

xenstore

Rust bindings to Xenstore
Rust
3
star
21

libvmi-rs

Rust reimplementation of LibVMI
Rust
3
star
22

protonvpn-vm

Preconfigured ProtonVPN setup in a virtual machine
3
star
23

docker-gui-app

Summary of the techniques available to run gui applications inside docker
3
star
24

packer-flare

Packer templates to build your FLARE VM from scratch
PowerShell
3
star
25

windows_internals

2
star
26

kvm

Fork of KVM with Virtual Machine Introspection patch
C
2
star
27

xenevtchn

Rust bindings to xenevtchn library
Rust
2
star
28

cmake_template_cpp

A simple C++ project template based on CMake
CMake
2
star
29

nitro

KVM-based Virtual Machine Introspection
Python
2
star
30

vagrant-icebox

A vagrant environment to develop Icebox and VirtualBox VMI
Batchfile
2
star
31

unbound-formula

Install and configure the Unbound DNS server
SaltStack
2
star
32

libksysguard

Fork of libksysguard
C++
1
star
33

web_monitor

Python
1
star
34

test-formula

A docker container to quickly test a SaltStack formula
SaltStack
1
star
35

testdbus

CMake
1
star
36

kdesrc-build.py

An attempt to rewrite the KDE build system into Python
Python
1
star
37

doxify

Quick C++ source code documentation generator based on doxygen.
Shell
1
star
38

wikimedia-phabricator-tools

Fork of https://gerrit.wikimedia.org/r/phabricator/tools
Python
1
star
39

xenvmevent-sys

Rust unsafe bindings for Xen VM event definitions
Rust
1
star
40

kdesrc-build-genconf

Python
1
star
41

bug_pyfakefs

No such file or directory in the fake filesystem: b'/tmp'
Python
1
star
42

kde-build-metadata

Fork of the kde-build-metadata KDE repository
1
star
43

pandoc_template

A template to generate reports with Pandoc
Makefile
1
star
44

wenzel.github.io

https://wenzel.github.io
HTML
1
star
45

vagrant-xen-r2vmi

Vagrant box to work on r2vmi project
Ruby
1
star
46

salt-oneshot

A quick wrapper around SaltStack to quickly test and deploy a system configuration without having to set-up a Salt Master server.
Python
1
star
47

procexp_helper

C++
1
star
48

bug_pyspy

Python
1
star
49

kcm_template_qml

CMake
1
star
50

docker-owncloud

Dockerfile to configure and deploy Owncloud with a simplified configuration based on SaltStack
Shell
1
star
51

bug_report

A repo to store reproducible code for bug reports
1
star
52

vagrant-xen

A set of Vagrant boxes to install and test the Xen hypervisor
Ruby
1
star
53

fdp-sys

Rust unsafe bindings on FDP (Fast Debugging Protocol) library for VirtualBox Introspection
Rust
1
star
54

xenforeignmemory

Safe Rust bindings to xenforeignmemory
Rust
1
star
55

checksec.py-test-binaries

Test binaries for checksec.py
1
star
56

test_bug_actions

https://bugzilla.mozilla.org/show_bug.cgi?id=1622455
1
star
57

kmonitor

A new system monitor for KDE
CMake
1
star
58

xenevtchn-sys

Rust bindings for xenevtchn library
Rust
1
star
59

kvmi-sys

Rust bindings for KVM's introspection libkvmi library
Rust
1
star