GetApiModule function retrieves the address of kernel32.dll by iterating through the PEB module list and hashing module names.
API hashing is used to avoid detection by hiding imported functions.
Unhook function removes EDR hooks from loaded DLLs by mapping the file from disk, comparing with the in-memory version, and restoring the original code.
Unhooking iterates through the export address table (EAT) of a given DLL, checking for and removing any jump instructions (E9 for relative jump and FF 25 for an absolute jump) that are indicative of API hooks.
The Unhook function gets the module file name, creates a file mapping, parses the PE headers, iterates through exported functions, and restores the original code if a hook is detected.
For virtual machine disk files (VMDK, VHD, etc.), the ransomware encrypts only a portion (e.g., 20%) to save time while still rendering the VM unusable.
For other files, it employs different strategies based on file size: full encryption for files smaller than 1MB, header-only encryption for files between 1MB and 5MB, and 50% encryption for files larger than 5MB.
The analysis provides valuable insights into the inner workings of ransomware.
The importance of using established cryptographic libraries instead of implementing custom crypto is emphasized.
The use of compile-time string obfuscation as an anti-analysis technique is discussed.
The efficiency of unhooking individual functions versus replacing entire memory sections (e.g., the .text section) to remove hooks is debated.
The use of a thread pool to manage concurrent file encryption tasks is highlighted.
The strategy of encrypting only portions of large files (like virtual machine disks) to save time while still achieving the goal of data denial is noted.
The potential use of the USN journal for detecting ransomware activity by monitoring file access patterns is mentioned.
The importance of proper error handling and the use of GetFileSizeEx instead of GetFileSize to avoid issues with large files is pointed out.
The irony of using copy-pasted, poorly documented code snippets (like the COM initialization for WMI access) in a complex piece of malware is highlighted.
The discussion touches upon the ethics and motivations behind analyzing leaked ransomware source code.
The session concludes with an invitation for further discussion and analysis of other malware samples.