Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Anti-dump: fix SizeOfImage() modifying the wrong module and field #183

Merged
merged 1 commit into from
May 19, 2019

Conversation

Mattiwatti
Copy link
Contributor

SizeOfImage() is supposed to increase the reported size of the EXE in the loader module list. However it was writing the new size value to the DllBase field instead of SizeOfImage.

Additionally, the function was using InMemoryOrderModuleList to find the EXE, but due to this list being in memory order as the name implies, it usually actually modified the wrong module. I changed this to use InLoadOrderModuleList instead, in which the EXE is always the first entry.

While this code works, it does contain some ugly pointer hackery which is needed because winternl.h is woefully inadequate and doesn't define the needed fields. I added comments for clarification of the fields, but if this is not enough I suggest replacing winternl.h with a header(s) containing the uncensored types such as the Process Hacker SDK or ntdll.h from ScyllaHide.

- Use InLoadOrderModuleList rather than InMemoryOrderModuleList to obtain the EXE's table entry
- Write the new size value to entry->SizeOfImage instead of entry->DllBase
@ayoubfaouzi
Copy link
Owner

Hey @Mattiwatti

Good catch ! Thanks for your detailed explanation !

Merged.

@ayoubfaouzi ayoubfaouzi merged commit b03df63 into ayoubfaouzi:master May 19, 2019
@Mattiwatti Mattiwatti deleted the fix-sizeofimage branch May 19, 2019 23:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants