Malops Aurat mini write-up

I've been doing a couple of challenges from malops.io ; These have been pretty fun so far, giving a good brush-up on commonly used malware techniques. I thought I'd write notes on AURAT, their difficult challenge. SHA256 for AURAT is 9d4600b440a7c730737f83de7188cc68e83124a10934c3d280610b8709084859

First, when chucking this into IDA , we're asked if we want to open it in 16/32 or 64 bit mode. That's interesting... Detect-it easy doesn't detect a valid PE File but a binary. We open it in HXD and see the MZ header is missing. We're also missing the "PE" magic value and there's a bunch of garbage added to the file. Below is a screenshot of the file

Here is what a properly formated file looks like:

I had to fix this PE manually. First adding the MZ magic bytes then using IMHex's PE parser , I compared a known good PE to this one. I mostly had to change where the coff pointer in the DOS header points to and change the file signature to PE. We end up with something that looks like this:

We can now open this up in IDA and navigate to the entrypoint.

The decompiler code shows something interesting:

sub_180001000 is passed some kind of hash and it's xrefd A LOT:

This screams API Hash resolution. sub_180001000 calls a PEB walking function that returns the base address of the second entry in the InLoadOrderModuleList:

Commented, we get:

The hashing function is pretty classic. One key giveaway is the below for loop:

This looks a lot like djb2 a pretty common string hashing algorithm. Googling djb2 hash, Gemini outputs a toy snippet:

This looks super similar! Only difference is the init 5381 value which seems to be 0 in our malware's export resolver. We can now rewrite this in python and hash all exports in kernel32.dll with this algorithm. We can then update our calls accordingly and use IDA's change callee address manually if we want these calls to look nice in IDA. Here is an example of annotation using IDA and me using the "change callee address on the call rax to "make it look nice":

On the above, we see another importhashResolver that works pretty similarly to the first. This one is for ntdll and has a hardcoded hash. We can go through the code and see a couple more import hash resolvers. I modified my ida script to bruteforce function hashes for all of these and add comments when we had a known hash:

After that, the rest of the challenge becomes pretty easy (just reading code/disassembly) and I don't want to spoil everything. Best of luck :)

Last updated