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

Fix ScanForModules_MemoryWalk_Hidden and add new .NET structure scan. #238

Merged
merged 1 commit into from
Jun 13, 2021

Conversation

gsuberland
Copy link
Collaborator

The memory walk check was broken because it assumed that memory regions would be executable. It also started at the wrong address - AllocationBase is the start of the allocator region, whereas BaseAddress is the actual start of the region. This has now been fixed.

This commit also adds a new check, which scans for memory structures that the .NET runtime creates to track loaded modules. This should catch injected modules even if they're dynamically loaded from memory.

This fixes #234 and #237.

The memory walk check was broken because it assumed that memory regions would be executable. It also started at the wrong address - AllocationBase is the start of the allocator region, whereas BaseAddress is the actual start of the region. This has now been fixed.

This commit also adds a new check, which scans for memory structures that the .NET runtime creates to track loaded modules. This should catch injected modules even if they're dynamically loaded from memory.
@gsuberland gsuberland requested a review from ayoubfaouzi June 12, 2021 19:48
{
auto moduleData = static_cast<PBYTE>(region->AllocationBase);
Copy link
Owner

Choose a reason for hiding this comment

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

Nice catch !

@@ -408,6 +410,90 @@ BOOL ScanForModules_MemoryWalk_Hidden()
return anyBadLibs ? TRUE : FALSE;
}

BOOL ScanForModules_DotNetModuleStructures()
Copy link
Owner

Choose a reason for hiding this comment

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

Looks solid.

@gsuberland gsuberland merged commit 66c0a8a into master Jun 13, 2021
fengjixuchui added a commit to fengjixuchui/al-khaser that referenced this pull request Jun 16, 2021
Merge pull request ayoubfaouzi#238 from LordNoteworthy/scan_for_mo…
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.

[Improvement] ScanForModules does not support managed modules
2 participants