cobbr / SharpSploit

SharpSploit is a .NET post-exploitation library written in C#
https://sharpsploit.cobbr.io/api/
BSD 3-Clause "New" or "Revised" License
1.75k stars 307 forks source link

Safely free modules after mapping or overloading #52

Closed TheWover closed 4 years ago

TheWover commented 4 years ago

A reminder that we should add a generic function for safely cleaning manually mapped or overloaded modules from memory after they are no longer necessary. For overloaded modules, the section should be unmapped. For manually mapped modules (in dynamic memory), they can be freed with NtFreeVirtualMemory. This will require editing the data structures to include the modules range in memory and a handle to the Section for overloaded modules.

Make sure and update the Mimikatz loader to use this, since a copy of mimikatz floating in memory is quite suspicious.