Skip to content

Commit 1a13abd

Browse files
committed
add a guide on forensics
1 parent f0e9ee0 commit 1a13abd

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ requests](https://github.com/Qubes-Community/Contents/pulls).
6161
- [security guidelines](security/security-guidelines.md)
6262
- [split bitcoin](security/split-bitcoin.md)
6363
- [split gpg](security/split-gpg.md)
64+
- [forensics](docs/security/forensics.md)
6465

6566
`system`
6667
- [understanding and fixing issues with time/clock](system/clock-time.md)

docs/security/forensics.md

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Forensics
2+
3+
Sometimes it may be necessary to forensically investigate a Qubes OS VM. This guide describes how this can be accomplished. It is intended for advanced users.
4+
5+
For forensics of Qubes OS `dom0` please refer to any standard Linux forensics guide.
6+
7+
## Disk Forensics
8+
9+
You can [mount disks of all VMs to another investigation VM](https://www.qubes-os.org/doc/mount-lvm-image/) in both r/w and r/o fashion and use your favorite forensic analysis tools.
10+
11+
Users of non-LVM [storage pools](https://dev.qubes-os.org/projects/core-admin-client/en/latest/manpages/qvm-pool.html) may refer to [this code](https://github.com/3hhh/blib/blob/bd993049f8ff6ba9507af06ab388c89f8fb86113/lib/os/qubes4/dom0#L1114).
12+
13+
## Memory Forensics
14+
15+
The following guide uses [volatility3](https://github.com/volatilityfoundation/volatility3) for memory forensics on a previously created memory dump.
16+
Other tools may work as well.
17+
18+
The VM under analysis is called `vm`. The VM where the memory dump is analyzed is called `analysis-vm`.
19+
20+
### (dom0) Use template VM kernels
21+
22+
Since Qubes OS currently does [not provide kernel debug symbols](https://github.com/QubesOS/qubes-issues/issues/7831) for its default kernels, you will have to switch to VM template kernels at least for the VM under analysis _and_ the analysis VM. Without this step, the analysis tool (here [volatility3](https://github.com/volatilityfoundation/volatility3)) will be unable to interpret the memory dump.
23+
24+
Please follow [the official guide on how to use a kernel installed inside a VM](https://www.qubes-os.org/doc/managing-vm-kernels/#using-kernel-installed-in-the-vm). The required package for `pvh` VMs is called `grub2-xen-pvh`.
25+
26+
### (dom0) Pause the VM under analysis
27+
28+
```
29+
qvm-pause vm
30+
```
31+
32+
You can later unpause it via `qvm-unpause vm`. Skipping this step may cause memory smear and render the memory dump useless.
33+
34+
### (dom0) Dump the memory
35+
36+
```
37+
virsh -c xen:// dump vm vm.dump --live
38+
sudo chown [user]:[user] vm.dump
39+
```
40+
41+
### (dom0) Create the analysis-vm
42+
43+
```
44+
qvm-clone --class StandaloneVM debian-11 analysis-vm
45+
qvm-prefs analysis-vm label red
46+
qvm-prefs analysis-vm netvm sys-firewall
47+
qubes-vm-settings analysis-vm (make sure you have at least 7 GB free system storage and enough private storage to fit your memory dump)
48+
qvm-copy-to-vm analysis-vm vm.dump
49+
```
50+
51+
### (analysis-vm) Install [volatility3](https://github.com/volatilityfoundation/volatility3/releases)
52+
53+
Follow the install instructions inside the `REAMDE.md`.
54+
55+
As of 2023 the volatility3 support for Xen memory dumps [is limited](https://github.com/volatilityfoundation/volatility3/issues/896). Your mileage may vary.
56+
57+
### (analysis-vm) Create a volatility binary for convenience
58+
59+
```
60+
sudo su
61+
echo '#!/bin/bash'$'\n''python3 "[path to vol.py]/vol.py" "$@"' > /usr/bin/volatility
62+
chmod +x /usr/bin/volatility
63+
exit
64+
```
65+
66+
### (analysis-vm) Build and install [dwarf2json](https://github.com/volatilityfoundation/dwarf2json)
67+
68+
You may have to install golang first (debian: `sudo apt install golang`).
69+
70+
```
71+
cd ~
72+
git clone 'https://github.com/volatilityfoundation/dwarf2json'
73+
cd dwarf2json
74+
go build
75+
```
76+
77+
### (analysis-vm) Generate the [symbol tables](https://volatility3.readthedocs.io/en/latest/symbol-tables.html) for volatility3
78+
79+
On debian use `sudo apt install linux-image-amd64-dbg` to install the version matching the kernel version of the VM under analysis.
80+
81+
Afterwards generate the symbol table lookups for volatility3 via `dwarf2json`:
82+
```
83+
./dwarf2json linux --elf /usr/lib/debug/boot/vmlinux-[kernel version]-amd64 --system-map /usr/lib/debug/boot/System.map-[kernel version]-amd64 > [volatility path]/volatility3/symbols/[kernel version]-amd64.json
84+
```
85+
86+
### (analysis-vm) Analyze the memory dump
87+
88+
```
89+
cd ~
90+
mv ~/QubesIncoming/dom0/vm.dump ~
91+
volatility isfinfo (should show the symbol file)
92+
volatility -f vm.dump banner
93+
volatility -f vm.dump linux.pslist
94+
```

0 commit comments

Comments
 (0)