-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dump raw guest VM memory feature #621
Conversation
Hi thanks for the PR! Code-wise it looks good, however I have some questions/ideas I'd like to discuss:
|
Hi, thanks for sharing your thoughts! I will try to address your questions : )
We've came up with two theoretical ideas how we could deal with it. We'd be glad if you could address them or maybe put forward a better solution:
What do you think?
|
We already have a (though maybe a bit under documented) feature - snapshot exporting - which I think could be adapted to enable this. You can run You can find the function here: drakvuf-sandbox/drakrun/drakrun/draksetup.py Line 1003 in 258a78a
The downside of this approach is that currently we have no link between what's currently used by drakrun and the name of exported snapshot. But after fixing, I think that it should be usable. What do you think of this approach? 🤔
That's cool, exporter also uses gzip so maybe we could reuse some parts of this code. |
Great, having such option would be cool, and we're definitely up for it : )
At this point we were thinking about having a dedicated bucket on MinIO for exported "pre-sample" (clean) memory dumps. "post-sample" images would be stored as it is now - in the analysis folder in the drakrun bucket. To resolve problems with version of used snapshot (matching corresponding pre-sample and post-sample dumps) I think the cleanest solution would be to include snapshot hash into the raw image names e.g.
Actually, during the last compression tests, we've found a solution that may suit our needs well. MinIO offers its own transparent compression. We've seen that it compresses our raw dumps to similar but slightly bigger size than gzip does:
But it comes first in terms of speed and usability. In our test process of uploading raw memory image to MinIO was as fast as running gzip for only compressing the file:
MinIO compression can be applied to any files, based on extension, not only the raw memory images. In our opinion it seems to be a convenient solution, taking into account both transparency and speed. It's easily configured, detailed guide can be found here: https://docs.min.io/docs/minio-compression-guide.html We are willing to implement this solution and would be glad to hear what you think : ) |
Yes, I'm aware that MinIO has a feature of transparent compression. However it comes with a set of some drawbacks
Storing post analysis dumps together with the rest of analysis artifacts sounds good 👍
Sounds OK, although I think we'd prefer enhancing the
Great! If you have any questions feel free to contact us! |
At this point we've added 2 features:
Currently we're working on exporting functionality. We'll be glad to hear what you think about commited changes : ) |
draksetup memdump exportI've finished demo version of the exporter code,
# draksetup memdump export --instance=1 --bucket="presample-memdumps" Following exceptions has been tested:
Whole execution chain (export presample-memdump -> download from minio -> decompress -> analyze using volatility3) was tested and seems to work properly. One issue I've stumbled upon is drakvuf-sandbox/drakrun/drakrun/draksetup.py Lines 997 to 1004 in c4d6db3
Reading access parameters from default file results in empty strings and access denied, which might be misleading given config description and behavior of drakrun (reading credentials from minio.env): drakvuf-sandbox/drakrun/drakrun/config.dist.ini Lines 14 to 23 in c4d6db3
I wasn't sure if it is intended solution, so I thought I should bring this up. I would be happy to hear your thoughts : ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small nitpicks, otherwise looks good :)
Yup, it's a bug. I've created an issue to track this - #632 . |
Thanks! |
@pavveu7 Hello, many thanks for your contribution and interest in the project! 🚀 l Please note that this approach assumes that at the end of the analysis, the VM is still alive and DRAKVUF engine has exited cleanly. This might not be true under some circumstances:
In such circumstances, the VM will be destroyed and you will not be able to make any memory dump. This behavior is controlled by Instead of I wonder how DRAKVUF engine would behave in combination with such mechanism, but it should be fine though (probably some minimal adjustments would be required). This is a completely optional remark, but I think it might be useful to you. |
@icedevml hi, thanks for the remark! I really appreciate it : ) This is a case that should be definitely taken into account. I will investigate it further, many thanks for this note! : ) |
Dump raw memory
Whilist researching the feature set of Drakvuf Sandbox at Poznan Supercomputing and Networking Center we identified that it lacked ability to postprocess raw guest memory with tools of our choice for further analysis. In order to do so, we've implemented optional functionality of fully-dumping RAM memory from guest VM. We aimed our solution for compatibility with Volatility3 framework.
Dumping process
We are using libvmi tool -
vmi-dump-memory
- which is currently shipped with drakvuf engine. The dump is performed twice:memory_dump_pre_sample.raw
- after restoring the VM, before injecting sample.memory_dump_post_sample.raw
- after finished analysis with drakvuf engine.Both images are then stored under
outdir
in order to be uploaded to minio server. The whole process is wrapped in one function_memory_dump
located indrakrun/main.py
.Volatility3 compatibility
We have encountered problems with RAM dumps made with
xl dump-memory
command line tool. Resulting memory dumps were stored in a custom Xen ELF format, which is not recognized by Volatility3 framework.vmi-dump-memory
dumps memory in raw format, which works well with Volatility3.Configuration
We've added
raw_memory_dump
boolean option, intodrakrun/config.dist.ini
, which is disabled by default. When disabled the code does not interfere into the analyzing process.Development
This feature was successfully tested with guidelines specified in Sanbox Development