Python interface to LibVMI
Project description
Libvmi Python bindings
If you'd rather perform introspection using Python instead of C, then these bindings will help get you going.
The bindings are Python 2
compatible.
Requirements
python3-pkgconfig
python3-cffi
(> 1.6.0
)python3-future
libvmi
Setup
python setup.py build
python setup.py install
API
Constructor
The main class that you need to import is Libvmi
.
The default parameters uses VMI_CONFIG_GLOBAL_FILE_ENTRY
and calls vmi_init_complete
:
from libvmi import Libvmi
with Libvmi("Windows_7") as vmi:
os = vmi.get_ostype()
You can specify a string
(VMI_CONFIG_STRING
):
from libvmi import Libvmi, VMIConfig
config_str = '{ostype = "Windows";win_pdbase=0x28;win_pid=0x180;win_tasks=0x188;win_pname=0x2e0;}'
with Libvmi("Windows_7", mode=VMIConfig.STRING, config=config_str) as vmi:
os = vmi.get_ostype()
Or a dict
(VMI_CONFIG_GHASHTABLE
):
from libvmi import Libvmi, VMIConfig
hash = {
"ostype": "Windows",
"win_pdbase": 0x28,
"win_tasks": 0x188,
"win_pid": 0x180,
"win_pname": 0x2e0,
}
with Libvmi("Windows_7", mode=VMIConfig.DICT, config=hash) as vmi:
os = vmi.get_ostype()
You can also use a partial
initialization, which calls vmi_init
.
(It doesn't require a configuration):
from libvmi import Libvmi
with Libvmi("Windows_7", partial=True) as vmi:
Examples
from libvmi import Libvmi, AccessContext, TranslateMechanism
with Libvmi("Windows_7") as vmi:
pshead = vmi.read_addr_ksym("PsActiveProcessHead")
name = vmi.get_name()
id = vmi.get_vmid()
buffer, bytes_read = vmi.read_va(pshead, 4, 16)
vmi.write_va(pshead, 4, buffer)
ctx = AccessContext(TranslateMechanism.KERNEL_SYMBOL, ksym="PsActiveProcessHead")
buffer, bytes_read = vmi.read(ctx, 8)
Note: The implementation already checks if the return value is VMI_FAILURE
and
raises a LibvmiError
in such case.
Integration
Volatility
You can use the
volatlity
framework
directly in top of the bindings.
git clone https://github.com/volatilityfoundation/volatility /tmp
cp ./volatility/vmi.py /tmp/volatility/volatility/plugins/addrspaces/
Usage
python vol.py -l vmi://domain --profile=Win7SP0x64 pslist
Rekall
The Rekall
address space is already
integrated
upstream.
Usage
rekall -f vmi://domain pslist
Contributors
- Bryan D. Payne
- Mathieu Tarral
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file libvmi-3.7.1-cp311-cp311-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libvmi-3.7.1-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 946.9 kB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00c4341e7fea70c86524bd9947b5cf2ddd4e8c61d39459deacdef8de61279a13 |
|
MD5 | ab3485dad75ceed83b87a4885771e08a |
|
BLAKE2b-256 | d8dc718616f2a3c8a943ff1cff891fc3d4ab86c869cb6cbf0059b586aeea87fa |
File details
Details for the file libvmi-3.7.1-cp310-cp310-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libvmi-3.7.1-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 946.9 kB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d197d3f2274392614639e111cd54f56426d0c6c3653409f59725039fa6931d0 |
|
MD5 | dec2e2e35ace419c44e2f55f11823761 |
|
BLAKE2b-256 | 06fd79c953f2f05d7a8b394cae0236954568998bb1dc56f11b89059a8e69201f |
File details
Details for the file libvmi-3.7.1-cp39-cp39-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libvmi-3.7.1-cp39-cp39-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 946.9 kB
- Tags: CPython 3.9, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 604630333a21e1c5347463792a883e97ee95bf75df76459d2e360e3545af9412 |
|
MD5 | a75c42f4ed703a933da1323602b86426 |
|
BLAKE2b-256 | c986491d6a02434e5d66f4622f5a7bc189e8f41eaaaa8cc45152d9137825e3aa |
File details
Details for the file libvmi-3.7.1-cp38-cp38-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libvmi-3.7.1-cp38-cp38-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 947.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 254188a772fb57584e6bf259aa2256abfa63d0225bfc4246542489f16520d4d7 |
|
MD5 | 4ebff7cdc6d60b8b226d93392d1a4fe0 |
|
BLAKE2b-256 | 9a4b5e64dee55585a866e2d2e8d14d72c18d03cc2e7e4c7d9ee796731a2d5212 |
File details
Details for the file libvmi-3.7.1-cp37-cp37m-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: libvmi-3.7.1-cp37-cp37m-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 946.4 kB
- Tags: CPython 3.7m, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6039eb2ad65a3fb26367987f73d4f7e1fcbee61d3d99b5521ef60bbbe571ad96 |
|
MD5 | 368a813749db3b64d8d1990622b7f78d |
|
BLAKE2b-256 | 875b96ab29a5279027a7f902a9863776e46a3f3481dcde4370a54084636f36be |