This is a post in a series where I complete every Flare-on challenge. The landing page for all of these posts can be found here
Challenge 5 brings us a DLL file, I mainly used Ghidra to statically analyze this file.
5get_it: PE32 executable (DLL) (GUI) Intel 80386, for MS Windows
After Ghidra loaded and analyzed the file, I found this function at 0x1000a680 that does a few things, first to Reads and writes the Run key to setup persistence for this DLL file, and it also copies itself to the C:\windows\system32 directory as svchost.dll to look like a legitimate DLL file. Next, it executes a function that looks to act as a key logger.
This function sets up a buffer to store keystrokes into them write them out to a file named svchost.log. Looking at the mw_key_press_handler function we see how it handles the key presses.
This function has various handler function for each ASCII value for most upper case letters, lower case letter, number, and some other characters. However not all have handler functions, so I took a closer look at the functions.
Below are three examples of functions, some of the functions would set a global variable to 1 or 0 depending on if another variable was set, and/or call another function that sets a group of global variables to 0. Not all of the functions returned the same letter that was pressed. As shown below “`” returns the number “0”.
Taking a closer look at the global variables that are manipulated I could see a pattern of them being written or read depending on the keypress handler functions.
Went through the listing of functions and created a list of the key presses and the return values and saw what looks like the key.
|Memory Address||Input Char||Output Char|
But this table does not include the letter “m” at the end of “com” the handler for “M” has an extra function that it calls.
This function that the handler calls has a large number of local variables and makes Ghidra very sad, but its main function shows a message box with the flag: firstname.lastname@example.org