Extracting the Qilin ransomware configuration file

The Qilin ransomware emerged in 2022 under the name “Agenda”. Multiple analyses of this artifact have already been published by security vendors. In this quick article, I will focus on extracting the configuration file of some variants. During DFIR activities related to this kind of compromise, having this information can help us determine the compromised accounts used by the malware, as well as additional features (e.g., encryption extension, target files, and exceptions).

Extracting the configuration file through dynamic analysis

The first step is to run the executable in a debugger and go to the address 0x401880 (if ASLR is enabled, replace 0x40 with the hexadecimal values in use by the program; in the example below the image is loaded at 0xDC0000, so the address becomes 0xDC1880). This is the main function.

Main function of the Qilin loader in the debugger

Scroll a bit and you will find a loop. This is the code that decrypts the embedded DLL into a buffer. When the loop ends, EIP will jump to the call to GetCommandLineW (if you ran the program without any arguments, it will stop the execution).

Loop that decrypts the embedded DLL, followed by the call to GetCommandLineW

You can set a breakpoint on the jne instruction and follow the pointer stored at ESP+54 in the memory dump. We can see the DLL being loaded in memory.

Breakpoint on the jne instruction with the MZ header appearing in the memory dump

To extract the final binary, just put a breakpoint on the call to GetCommandLineW (and remove the breakpoint on jne if you set it) and save the contents of the memory dump:

Fully decrypted DLL in the memory dump when execution reaches GetCommandLineW

Open the saved file in a hex editor and search for public_rsa_pem. The rest of the configuration comes right after the public key, starting with the private_rsa_pem field and the directory and file exclusion lists:

Qilin configuration in a hex editor, showing the private_rsa_pem field and the directory exclusion list

You can just copy and paste the text into another editor to see it in a more readable format:

Formatted Qilin configuration showing the compromised accounts and the ransom note

Conclusion

Extracting ransomware configurations is an interesting and important task. As mentioned before, this may show us the accounts (usually bought from darknet forums) used by the operators during the incident. Qilin is just one example, but similar procedures also work for other known families.