Skip to content
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

Add low stub offset kernel detection #1566

Merged
merged 3 commits into from
Jan 25, 2025

Conversation

Danking555
Copy link
Contributor

@Danking555 Danking555 commented Jan 22, 2025

Summary

This PR introduces a Low-Stub based method as an additional approach to kernel offset discovery in Volatility.
When available, this method resolves the kernel offset in ~3 seconds, a significant improvement compared to the ~90 seconds required by the current KDBG scan for large memory dumps (e.g., 32GB).
If the Low Stub method fails (e.g., for Hyper-V .vmem files), Volatility gracefully falls back to the existing KDBG scan.

Motivation

The KDBG scan is computationally intensive, particularly for large memory dumps, and can delay forensic investigations and incident response.
By leveraging the Low Stub, which contains the DTB and kernel base address hint, the kernel offset can be determined far more efficiently, improving overall runtime for all plugins dependent on this step.

Testing

This hybrid approach was tested on:

  • Physical memory dumps from Windows 11
  • Edge cases where the Low Stub is unavailable, with successful fallback to the KDBG scan (e.g., VMs memory)

References

Special thanks to Ulf Frisk and Alex Ionescu for their pioneering research, which informed and inspired this contribution.

Acknowledgment

Thank you for maintaining Volatility as an indispensable tool in the forensic community. I hope this contribution enhances its usability and performance. I welcome any feedback or suggestions for further improvement.

Copy link
Member

@ikelos ikelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much, this looks really interesting! Have you managed to test it against older systems (x86, PAE, etc)? My concern is that it has a lot of hard coded hex bytes which may not be applicable to all x86-based architectures or memory layouts so I'd want to be careful about that. It would also be good to get a few more comments (although I appreciate the continue comments explaining which bit the guard statements were looking for)...

Could you please also apply ruff (which just wants the unnecessary struct import removing) and black to format the file appropriately please? Having it pass all the tests will give us a bit of confidence that it's working as intended...

volatility3/framework/automagic/pdbscan.py Outdated Show resolved Hide resolved
volatility3/framework/automagic/pdbscan.py Outdated Show resolved Hide resolved
@Danking555
Copy link
Contributor Author

Thanks for your feedback! I'm checking and working on everything you mentioned.

* Eliminate unnecessary scanning for 32 bit processors where the structure PROCESSOR_START_BLOCK doesn't exist
* Put offsets as values of constants in a class - LowStubLayout.
* Add documentation in the class and in the function method_low_stub_offset
* Run "ruff check --fix" and "black ."
* Checked the method works on 3 physical machines
@Danking555
Copy link
Contributor Author

Hi @ikelos, I've addressed your feedback and made the following updates:

  • Removed unnecessary struct import.
  • Added the LowStubLayout class to centralize all relevant constants of the _PROCESSOR_START_BLOCK structure for better organization and maintainability.
  • Added documentation for the LowStubLayout class and method_low_stub_offset.
  • Updated the guard statement to address the concern about reservation bits.
  • Added a new guard check statement that compares the previously detected page table offset stored in vlayer._initial_entry with the value of cr3 which can be deferred from the structure for additional validation. Let me know if you'd prefer it removed or adjusted.
  • Confirmed the method works on three physical machines.
  • After verifying functionality, applied ruff and black for code cleanup and formatting.

Please let me know if there's anything else you'd like me to refine or modify!

@ikelos
Copy link
Member

ikelos commented Jan 25, 2025

Thanks very much for clearing all those up! It's looking really good now. Rather than a separate class in the middle of the code, would it be possible to move the constants and their comments to the constants.windows module please? All of our other windows constants live there so it just keeps things in a single place to find them all. I guess move the docstring as an enlarged comment just before the section where you include those constants. Then it looks like it's good to go in! 5:D

* Moved constants out of the class and moved to constants.windows
* Applied ruff and black
@Danking555
Copy link
Contributor Author

I've moved the constants into constants.windows, added the docstring comment, and ran ruff and black again.
Let me know what you think-thanks!

Copy link
Member

@ikelos ikelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, very happy with that, thanks! 5:D I'll merge it as soon as the tests finish...

@ikelos ikelos merged commit 69fc7fe into volatilityfoundation:develop Jan 25, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants