[QuickNote] Qakbot 5.0 – Decrypt strings and configuration

Posted: April 24, 2024 in My Tutorials, [QuickNote] Qakbot 5.0 - Decrypt strings and configuration
Tags: , , , , , , , , ,

Hash: af6a9b7e7aefeb903c76417ed2b8399b73657440ad5f8b48a25cfe5e97ff868f

In this new sample, threat actor has updated Qakbot’s codebase to support 64-bit versions of Windows.

Here is the pseudocode for the string decryption functions in the 64-bit and 32-bit versions:

As the pictures show, the decryption process in the 64-bit version is similar to the previous version. However, the difference is that the xor_key_blob in this new version has been encrypted. Therefore, before performing the decryption to the original string, it will call the qbot_decrypt_xor_key_blob function (0x180011504) which I have circled in red above to decrypt the original xor_key_blob.

The qbot_decrypt_xor_key_blob function performs the following main tasks:

(1) Calculates the SHA256 hash for the blob data at addresses 0x180029700 (0x9F bytes) and 0x180028150 (0x63 bytes) and uses the calculated hash values as the AES Key.

(2) The first 16 bytes of the enc_xor_key_blob at addresses 0x18002AFE0 (0xA0 bytes) and 0x1800281C0 (0xD0 bytes) are used as the AES IV:

(3) Decrypts the encrypted blob data (except for the first 16 bytes used as AES IV) using AES in CBC mode. The result is the xor_key_blob used to decrypt the strings.

The entire decryption process is described through CyberChef as follows:

With the decrypted xor_key_blob above, we can completely write an idapython script to decrypt the strings and add comments related to the decrypted strings to facilitate the analysis of Qakbot code.

Here is my idapython script (Don’t blame my code if you don’t want your eyes to bleed :), just wanted to share it in case someone need to use it for reference.)

import idautils, idc, idaapi, ida_bytes
decrypt_routine1 = 0x18000DE90
decrypt_routine2 = 0x18000DE50
enc_strings_blob1 = 0x1800297A0
xor_bytes_array = b'\xc3\x4c\x4a\xd8\x7e\x10\xf2\xe9\x05\xe6\xe2\x8e\xaf\xfb\x6b\x32\xc3\x55\xb7\xbe\x9c\x8b\xd9\xc7\xf3\xd3\xa1\x87\xf7\xa7\xb8\x76\xb4\xc8\x2c\x74\x56\xbd\x03\xbc\xa9\x71\xfb\x4b\x89\x52\x95\x2c\x76\xd4\x94\xbf\x64\x23\xfa\x0a\x26\x46\x5e\xa9\x74\xd8\x1c\x2e\x47\x40\x98\x05\x3e\xde\x71\x65\x60\x3b\x03\x0a\x37\x8a\x29\x0e\xaa\x93\xcf\xc7\x35\x3e\x08\x6a\x2c\xab\x22\x6c\xd0\xef\x19\x37\xf3\xe2\x38\xfc\x34\x1b\x84\x61\x84\x0f\xa0\x78\xd1\xdd\x19\x5b\xc0\xcd\xb1\xc0\xb5\x9f\x00\x65\x04\xfa\x89\x39\xa5\xa3\x33\x60\xbf\x75\x5f\x10\xa6'
decrypt_routine3 = 0x180002AB8
decrypt_routine4 = 0x180002A78
enc_strings_blob2 = 0x1800282A0
xor_bytes_array2 = b'\xa8\x34\xed\x43\x82\x7d\x35\x98\x52\x5b\x04\x43\x01\x49\xc8\x9e\xbb\x30\xd5\x98\x2e\xf5\x9a\x03\x7b\x02\x46\x13\x1f\x9b\x32\x9e\x1b\x77\xc3\xf9\xe0\xc8\x83\x4b\x94\xa5\x64\xa0\xf3\x04\x45\xe3\xa0\x8f\xda\xc0\x3a\xac\xb7\xa1\x7d\x0c\x2f\x45\x0d\x05\x32\x5b\xd3\x19\xb3\x62\xef\x5d\xa1\x26\x2f\xb5\xfc\x4a\xb3\xc3\xa5\x41\x93\x18\xb4\x41\xa5\xd5\x83\xa5\x7d\x26\x34\x9f\xcd\x7f\x1b\x3e\xe8\x73\x22\xeb\x1b\x3c\x27\xa2\xb3\x00\x3c\x93\xdc\xd2\xae\xf1\x02\x2e\x3e\x8b\xbe\xd1\x11\xd1\x42\x01\x39\xc0\x32\x6c\x78\x98\x9b\xf8\x2c\x81\xeb\x56\x5c\x29\xc1\x1e\x8a\xd5\xea\x8a\xcf\xb3\x4d\x01\x7a\x4e\x7b\xa1\xc9\x19\x01\x61\xef\x05\x3c\x76\x13\xc6\x93\x4a\x7e\x4e\x66\x71\xb9\xb7\xfc\x42\xb2\x36\x33\xaf\xca\xa8\x74\xd1\xeb\xf3\x90\xa5\xf8\xd3\xce\x94\x55\x4c\xe1\x96\x35\xa8\x34\xed\x43\x82\x7d\x35\x98\x52\x5b\x04\x43\x01\x49\xc8\x9e\xbb\x30\xd5\x98\x2e\xf5\x9a\x03\x7b\x02\x46\x13\x1f\x9b\x32\x9e\x1b\x77\xc3\xf9\xe0\xc8\x83\x4b\x94\xa5\x64\xa0\xf3\x04\x45\xe3\xa0\x8f\xda\xc0\x3a\xac\xb7\xa1\x7d\x0c\x2f\x45\x0d\x05\x32\x5b\xd3\x19\xb3\x62\xef\x5d\xa1\x26\x2f\xb5\xfc\x4a\xb3\xc3\xa5\x41\x93\x18\xb4\x41\xa5\xd5\x83\xa5\x7d\x26\x34\x9f\xcd\x7f\x1b\x3e\xe8\x73\x22\xeb\x1b\x3c\x27\xa2\xb3\x00\x3c\x93\xdc\xd2\xae\xf1\x02\x2e\x3e\x8b\xbe\xd1\x11\xd1\x42\x01\x39\xc0\x32\x6c\x78\x98\x9b\xf8\x2c\x81\xeb\x56\x5c\x29\xc1\x1e\x8a\xd5\xea\x8a\xcf\xb3\x4d\x01\x7a\x4e\x7b\xa1\xc9\x19\x01\x61\xef\x05\x3c\x76\x13\xc6\x93\x4a\x7e\x4e\x66\x71\xb9\xb7\xfc\x42\xb2\x36\x33\xaf\xca\xa8\x74\xd1\xeb\xf3\x90\xa5\xf8\xd3\xce\x94\x55\x4c\xe1\x96\x35'
index_bound1 = 0x1836
index_bound2 = 0x5AD
black_list_xref_addr = [0x180014173, 0x180014106]
def decrypt(idx):
""" string decoding method """
if idx >= index_bound1:
return # oob
output = ""
while True:
c = idc.get_wide_byte(enc_strings_blob1 + idx) ^ xor_bytes_array[(idx % len(xor_bytes_array))]
if c == 0: break
output += chr(c)
idx += 1
return output
def decrypt2(idx):
""" string decoding method """
if idx >= index_bound2:
return # oob
output = ""
while True:
c = idc.get_wide_byte(enc_strings_blob2 + idx) ^ xor_bytes_array2[(idx % len(xor_bytes_array2))]
if c == 0: break
output += chr(c)
idx += 1
return output
def create_str_comment(idx, ea):
""" method to create the comments at offset to string decoding method """
decStr = decrypt(idx)
idc.set_cmt(ea, decStr, 0)
return True
def create_str_comment2(idx, ea):
""" method to create the comments at offset to string decoding method """
#index_value = get_operand_value(ca, 1)
decStr = decrypt2(idx)
idc.set_cmt(ea, decStr, 0)
return True
def decrypt_strings(func_addr):
""" decode all of the strings """
for x in idautils.XrefsTo(func_addr, 0):
xref_addr = x.frm
if xref_addr in black_list_xref_addr or not ida_bytes.is_code(ida_bytes.get_full_flags(xref_addr)):
continue
str_idx_arg_ea = idaapi.get_arg_addrs(xref_addr)[0]
if idc.print_insn_mnem(str_idx_arg_ea) == "pop":
str_idx_value = idc.get_operand_value(idc.prev_head(str_idx_arg_ea), 0)
elif idc.print_insn_mnem(str_idx_arg_ea) == "push":
str_idx_value = idc.get_operand_value(str_idx_arg_ea, 0)
else:
str_idx_value = idc.get_operand_value(str_idx_arg_ea, 1)
if str_idx_value < 0xFFFF:
create_str_comment(str_idx_value, xref_addr)
def decrypt_strings2(func_addr):
""" decode all of the strings """
for x in idautils.XrefsTo(func_addr, 0):
xref_addr = x.frm
if xref_addr in black_list_xref_addr or not ida_bytes.is_code(ida_bytes.get_full_flags(xref_addr)):
continue
str_idx_arg_ea = idaapi.get_arg_addrs(xref_addr)[0]
if idc.print_insn_mnem(str_idx_arg_ea) == "pop":
str_idx_value = idc.get_operand_value(idc.prev_head(str_idx_arg_ea), 0)
elif idc.print_insn_mnem(str_idx_arg_ea) == "push":
str_idx_value = idc.get_operand_value(str_idx_arg_ea, 0)
else:
str_idx_value = idc.get_operand_value(str_idx_arg_ea, 1)
if str_idx_value < 0xFFFF:
create_str_comment2(str_idx_value, xref_addr)
def main():
decrypt_strings(decrypt_routine1)
decrypt_strings(decrypt_routine2)
decrypt_strings2(decrypt_routine3)
decrypt_strings2(decrypt_routine4)
output = open("all_decrypted_strings_with_index.txt","w")
decrypted = ""
# for decrypt all strings
print('[+] Decrypt all strings with index boundary is {}'.format(hex(index_bound1)))
decrypted += '[+] Decrypt all strings with index boundary is {}\n'.format(hex(index_bound1))
idx = 0
while idx < index_bound1:
dec_str = decrypt(idx)
print("index: %s, decrypted string: %s" % (hex(idx), dec_str))
decrypted += "index: %s, decrypted string: %s \n" % (hex(idx), dec_str)
idx += len(dec_str) + 1
print('[+] Decrypt all strings with index boundary is {}'.format(hex(index_bound2)))
decrypted += '\n[+] Decrypt all strings with index boundary is {}\n'.format(hex(index_bound2))
idx = 0
while idx < index_bound2:
dec_str = decrypt2(idx)
print("index: %s, decrypted string: %s" % (hex(idx), dec_str))
decrypted += "index: %s, decrypted string: %s\n" % (hex(idx), dec_str)
idx += len(dec_str) + 1
output.write(decrypted)
output.close()
if __name__ == '__main__':
main()

Here is my results:

This is the full list of all decrypted strings:

[+] Decrypt all strings with index boundary is 0x1836
index: 0x0, decrypted string: %SystemRoot%\SysWOW64\xwizard.exe 
index: 0x22, decrypted string: .dat 
index: 0x27, decrypted string: kernelbase.dll 
index: 0x36, decrypted string: WBJ_IGNORE 
index: 0x41, decrypted string: mpr.dll 
index: 0x49, decrypted string: %SystemRoot%\explorer.exe 
index: 0x63, decrypted string: %SystemRoot%\System32\CertEnrollCtrl.exe 
index: 0x8c, decrypted string: https 
index: 0x92, decrypted string: SentinelServiceHost.exe;SentinelStaticEngine.exe;SentinelAgent.exe;SentinelStaticEngineScanner.exe;SentinelUI.exe 
index: 0x104, decrypted string: open 
index: 0x109, decrypted string: root\SecurityCenter2 
index: 0x11e, decrypted string: %SystemRoot%\SysWOW64\SndVol.exe 
index: 0x13f, decrypted string: %u.%u.%u.%u.%u.%u.%04x 
index: 0x156, decrypted string: 1234567890 
index: 0x161, decrypted string: %SystemRoot%\System32\Utilman.exe 
index: 0x183, decrypted string: snxhk_border_mywnd 
index: 0x196, decrypted string: %SystemRoot%\SysWOW64\wextract.exe 
index: 0x1b9, decrypted string: avgcsrvx.exe;avgsvcx.exe;avgcsrva.exe 
index: 0x1df, decrypted string: Win32_PhysicalMemory 
index: 0x1f4, decrypted string: Caption 
index: 0x1fc, decrypted string: ByteFence.exe 
index: 0x20a, decrypted string: aswhooka.dll 
index: 0x217, decrypted string: dwengine.exe;dwarkdaemon.exe;dwwatcher.exe 
index: 0x242, decrypted string: %SystemRoot%\SysWOW64\grpconv.exe 
index: 0x264, decrypted string: VRTUAL;VMware;VMW;Xen 
index: 0x27a, decrypted string: SELECT * FROM AntiVirusProduct 
index: 0x299, decrypted string: %s\%08X.dll 
index: 0x2a5, decrypted string: wininet.dll 
index: 0x2b1, decrypted string: avp.exe;kavtray.exe 
index: 0x2c5, decrypted string: rundll32.exe  
index: 0x2d3, decrypted string: Create 
index: 0x2da, decrypted string: WQL 
index: 0x2de, decrypted string: %SystemRoot%\System32\sethc.exe 
index: 0x2fe, decrypted string: AvastSvc.exe;aswEngSrv.exe;aswToolsSvc.exe;afwServ.exe;aswidsagent.exe;AvastUI.exe 
index: 0x351, decrypted string: Software\Classes 
index: 0x362, decrypted string: vkise.exe;isesrv.exe;cmdagent.exe 
index: 0x384, decrypted string: LastBootUpTime 
index: 0x393, decrypted string: MS_VM_CERT;VMware;Virtual Machine 
index: 0x3b5, decrypted string: Winsta0 
index: 0x3bd, decrypted string: .dll 
index: 0x3c2, decrypted string: Caption,Description,DeviceID,Manufacturer,Name,PNPDeviceID,Service,Status 
index: 0x40c, decrypted string: SonicWallClientProtectionService.exe;SWDash.exe 
index: 0x43c, decrypted string: t=%s time=[%02d:%02d:%02d-%02d/%02d/%d] 
index: 0x464, decrypted string: SystemRoot 
index: 0x46f, decrypted string: CommandLine 
index: 0x47b, decrypted string: %SystemRoot%\SysWOW64\explorer.exe 
index: 0x49e, decrypted string: SOFTWARE\Wow6432Node\Microsoft AntiMalware\SpyNet 
index: 0x4d0, decrypted string: %s\system32\ 
index: 0x4dd, decrypted string: SELECT * FROM Win32_OperatingSystem 
index: 0x501, decrypted string: wbj.go 
index: 0x508, decrypted string: System32 
index: 0x511, decrypted string: CynetEPS.exe;CynetMS.exe;CynetConsole.exe 
index: 0x53b, decrypted string: C:\INTERNAL\__empty 
index: 0x54f, decrypted string: cmd.exe 
index: 0x557, decrypted string: SOFTWARE\Microsoft\Windows\CurrentVersion\Run 
index: 0x585, decrypted string: */* 
index: 0x589, decrypted string: MsMpEng.exe 
index: 0x595, decrypted string: image/pjpeg 
index: 0x5a1, decrypted string: {%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X} 
index: 0x5e8, decrypted string: urlmon.dll 
index: 0x5f3, decrypted string: type=0x%04X 
index: 0x5ff, decrypted string: TRUE 
index: 0x604, decrypted string: Win32_ComputerSystem 
index: 0x619, decrypted string: %SystemRoot%\System32\backgroundTaskHost.exe 
index: 0x646, decrypted string: ALLUSERSPROFILE 
index: 0x656, decrypted string: .exe 
index: 0x65b, decrypted string: \\.\pipe\ 
index: 0x665, decrypted string: advapi32.dll 
index: 0x672, decrypted string: application/x-shockwave-flash 
index: 0x690, decrypted string: %ProgramFiles%\Windows Media Player\wmplayer.exe 
index: 0x6c1, decrypted string: ntdll.dll 
index: 0x6cb, decrypted string: %SystemRoot%\SysWOW64\Utilman.exe 
index: 0x6ed, decrypted string: CfGetPlatformInfo 
index: 0x6ff, decrypted string: userenv.dll 
index: 0x70b, decrypted string: LocalLow 
index: 0x714, decrypted string: FALSE 
index: 0x71a, decrypted string: coreServiceShell.exe;PccNTMon.exe;NTRTScan.exe 
index: 0x749, decrypted string: Sophos UI.exe;SophosUI.exe;SAVAdminService.exe;SavService.exe 
index: 0x787, decrypted string: image/jpeg 
index: 0x792, decrypted string: image/gif 
index: 0x79c, decrypted string: displayName 
index: 0x7a8, decrypted string: Name 
index: 0x7ad, decrypted string: Win32_PnPEntity 
index: 0x7bd, decrypted string: .cfg 
index: 0x7c2, decrypted string: APPDATA 
index: 0x7ca, decrypted string: winsta0\default 
index: 0x7da, decrypted string: %SystemRoot%\SysWOW64\CertEnrollCtrl.exe 
index: 0x803, decrypted string: %SystemRoot%\SysWOW64\backgroundTaskHost.exe 
index: 0x830, decrypted string: pstorec.dll 
index: 0x83c, decrypted string: RepUx.exe 
index: 0x846, decrypted string: aaebcdeeifghiiojklmnooupqrstuuyvwxyyaz 
index: 0x86d, decrypted string: \sf2.dll 
index: 0x876, decrypted string: %SystemRoot%\System32\dxdiag.exe 
index: 0x897, decrypted string: CSFalconService.exe;CSFalconContainer.exe 
index: 0x8c1, decrypted string: vbs 
index: 0x8c5, decrypted string: WRSA.exe 
index: 0x8ce, decrypted string: crypt32.dll 
index: 0x8da, decrypted string: setupapi.dll 
index: 0x8e7, decrypted string: c:\saurufdifsdudqat.sys 
index: 0x8ff, decrypted string: %ProgramFiles(x86)%\Windows Media Player\wmplayer.exe 
index: 0x935, decrypted string: netapi32.dll 
index: 0x942, decrypted string: SOFTWARE\Microsoft\Microsoft Antimalware\Exclusions\Paths 
index: 0x97c, decrypted string: VMware;PROD_VIRTUAL_DISK;VIRTUAL-DISK;XENSRC;20202020 
index: 0x9b2, decrypted string: %SystemRoot%\System32\grpconv.exe 
index: 0x9d4, decrypted string: SpyNetReporting 
index: 0x9e4, decrypted string: wtsapi32.dll 
index: 0x9f1, decrypted string: wpcap.dll 
index: 0x9fb, decrypted string: Packages 
index: 0xa04, decrypted string: %SystemRoot%\explorer.exe 
index: 0xa1e, decrypted string: regsvr32.exe  
index: 0xa2c, decrypted string: aswhookx.dll 
index: 0xa39, decrypted string: Content-Type: application/x-www-form-urlencoded 
index: 0xa69, decrypted string: %SystemRoot%\SysWOW64\SearchIndexer.exe 
index: 0xa91, decrypted string: %SystemRoot%\SysWOW64\AtBroker.exe 
index: 0xab4, decrypted string: %SystemRoot%\System32\WerFault.exe 
index: 0xad7, decrypted string: SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths 
index: 0xb0c, decrypted string: vmnat.exe 
index: 0xb16, decrypted string: SubmitSamplesConsent 
index: 0xb2b, decrypted string: SysWOW64 
index: 0xb34, decrypted string: shell32.dll 
index: 0xb40, decrypted string: wmic process call create 'expand "%S" "%S"'
 
index: 0xb6d, decrypted string: ROOT\CIMV2 
index: 0xb78, decrypted string: Win32_Product 
index: 0xb86, decrypted string: LOCALAPPDATA 
index: 0xb93, decrypted string: %SystemRoot%\SysWOW64\mobsync.exe 
index: 0xbb5, decrypted string: ws2_32.dll 
index: 0xbc0, decrypted string: WScript.Sleep %u
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\%coot\cimv2")
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create("%s", null, nul, nul)
WSCript.Sleep 2000
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile("%s") 
index: 0xd02, decrypted string: bcrypt.dll 
index: 0xd0d, decrypted string: SOFTWARE\Wow6432Node\Microsoft\Windows Defender\Spynet 
index: 0xd44, decrypted string: abcdefghijklmnopqrstuvwxyz 
index: 0xd5f, decrypted string: fshoster32.exe 
index: 0xd6e, decrypted string: %SystemRoot%\System32\SearchIndexer.exe 
index: 0xd96, decrypted string: reg.exe ADD "HKLM\%s" /f /t %s /v "%s" /d "%s" 
index: 0xdc5, decrypted string: Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\%coot\cimv2")
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create("%s", null, nul, nul) 
index: 0xe99, decrypted string: gdi32.dll 
index: 0xea3, decrypted string: Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\%coot\cimv2")
Set colFiles = objWMIService.ExecQuery("Select * From CIM_DataFile Where Name = '%s'")
For Each objFile in colFiles
objFile.Copy("%s")
Next 
index: 0xf8f, decrypted string: Win32_Process 
index: 0xf9d, decrypted string: SELECT * FROM Win32_Processor 
index: 0xfbb, decrypted string: user32.dll 
index: 0xfc6, decrypted string: Win32_Bios 
index: 0xfd1, decrypted string: %SystemRoot%\SysWOW64\explorer.exe 
index: 0xff4, decrypted string: MBAMService.exe;mbamgui.exe 
index: 0x1010, decrypted string: %SystemRoot%\SysWOW64\mspaint.exe 
index: 0x1032, decrypted string: frida-winjector-helper-32.exe;frida-winjector-helper-64.exe;tcpdump.exe;windump.exe;ethereal.exe;wireshark.exe;ettercap.exe;rtsniff.exe;packetcapture.exe;capturenet.exe;qak_proxy;dumpcap.exe;CFF Explorer.exe;not_rundll32.exe;ProcessHacker.exe;tcpview.exe;filemon.exe;procmon.exe;idaq64.exe;loaddll32.exe;PETools.exe;ImportREC.exe;LordPE.exe;SysInspector.exe;proc_analyzer.exe;sysAnalyzer.exe;sniff_hit.exe;joeboxcontrol.exe;joeboxserver.exe;ResourceHacker.exe;x64dbg.exe;Fiddler.exe;sniff_hit.exe;sysAnalyzer.exe;BehaviorDumper.exe;processdumperx64.exe;anti-virus.EXE;sysinfoX64.exe;sctoolswrapper.exe;sysinfoX64.exe;FakeExplorer.exe;apimonitor-x86.exe;idaq.exe;dumper64.exe;user_imitator.exe;Velociraptor.exe 
index: 0x12f8, decrypted string: %SystemRoot%\System32\wextract.exe 
index: 0x131b, decrypted string: egui.exe;ekrn.exe 
index: 0x132d, decrypted string: select  
index: 0x1335, decrypted string: %SystemRoot%\System32\wermgr.exe 
index: 0x1356, decrypted string: iphlpapi.dll 
index: 0x1363, decrypted string: SOFTWARE\Microsoft\Windows Defender\SpyNet 
index: 0x138e, decrypted string: %SystemRoot%\SysWOW64\dxdiag.exe 
index: 0x13af, decrypted string: %SystemRoot%\SysWOW64\WerFault.exe 
index: 0x13d2, decrypted string: %SystemRoot%\System32\AtBroker.exe 
index: 0x13f5, decrypted string: %SystemRoot%\SysWOW64\sethc.exe 
index: 0x1415, decrypted string: %S.%06d 
index: 0x141d, decrypted string: c:\\ 
index: 0x1422, decrypted string: S:(ML;;NW;;;LW) 
index: 0x1432, decrypted string: fmon.exe 
index: 0x143b, decrypted string: %SystemRoot%\System32\xwizard.exe 
index: 0x145d, decrypted string: cscript.exe 
index: 0x1469, decrypted string: Initializing database... 
index: 0x1482, decrypted string: xagtnotif.exe;AppUIMonitor.exe 
index: 0x14a1, decrypted string: %ProgramFiles%\Internet Explorer\iexplore.exe 
index: 0x14cf, decrypted string: Win32_DiskDrive 
index: 0x14df, decrypted string: aabcdeefghiijklmnoopqrstuuvwxyyz 
index: 0x1500, decrypted string: %SystemRoot%\System32\mobsync.exe 
index: 0x1522, decrypted string: %SystemRoot%\SysWOW64\wermgr.exe 
index: 0x1543, decrypted string: kernel32.dll 
index: 0x1550, decrypted string: %SystemRoot%\System32\mspaint.exe 
index: 0x1572, decrypted string: bdagent.exe;vsserv.exe;vsservppl.exe 
index: 0x1597, decrypted string: SOFTWARE\Microsoft\Microsoft AntiMalware\SpyNet 
index: 0x15c7, decrypted string: Caption,Description,Vendor,Version,InstallDate,InstallSource,PackageName 
index: 0x1610, decrypted string: NTUSER.DAT 
index: 0x161b, decrypted string: ccSvcHst.exe;NortonSecurity.exe;nsWscSvc.exe 
index: 0x1648, decrypted string:  from  
index: 0x164f, decrypted string: mcshield.exe 
index: 0x165c, decrypted string: %SystemRoot%\System32\SndVol.exe 
index: 0x167d, decrypted string: VMware;VMW;QEMU 
index: 0x168d, decrypted string: QEMU;VMware Pointing;VMware Accelerated;VMware SCSI;VMware SVGA;VMware Replay;VMware server memory;VirtualBox;CWSandbox;Virtual HD;QEMU;VirtIO;srootkit;vSockets;VBoxVideo;vmxnet;vmscsi;VMAUDIO;vmdebug;vm3dmp;vmrawdsk;vmx_svga;ansfltr;sbtisht;XENVIF;XENBUS;XENSRC;XENCLASS 
index: 0x179d, decrypted string: shlwapi.dll 
index: 0x17a9, decrypted string: csc_ui.exe 
index: 0x17b4, decrypted string: CrAmTray.exe 
index: 0x17c1, decrypted string: Mozilla/5.0 (Windows NT 6.1; rv:77.0) Gecko/20100101 Firefox/77.0 
index: 0x1803, decrypted string: %ProgramFiles(x86)%\Internet Explorer\iexplore.exe 

[+] Decrypt all strings with index boundary is 0x5ad
index: 0x0, decrypted string: SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
index: 0x39, decrypted string: ProgramData
index: 0x45, decrypted string: netstat -nao
index: 0x52, decrypted string: %s "$%s = \"%s\"; & $%s"
index: 0x6b, decrypted string: net localgroup
index: 0x7a, decrypted string: powershell.exe
index: 0x89, decrypted string: route print
index: 0x95, decrypted string: "%s\system32\schtasks.exe" /Create /ST %02u:%02u /RU "NT AUTHORITY\SYSTEM" /SC ONCE /tr "%s" /Z /ET %02u:%02u /tn %s
index: 0x10a, decrypted string: Component_08
index: 0x117, decrypted string: ERROR: GetModuleFileNameW() failed with error: ERROR_INSUFFICIENT_BUFFER
index: 0x160, decrypted string: net view
index: 0x169, decrypted string: ipconfig /all
index: 0x177, decrypted string: Self check
index: 0x182, decrypted string: T2X!wWMVH1UkMHD7SBdbgfgXrNBd(5dmRNbBI9
index: 0x1a9, decrypted string: 4Lm7DW&yMF*ELN4D8oNp0CtKUf*C2LAstORIBV
index: 0x1d0, decrypted string: Start screenshot
index: 0x1e1, decrypted string: %s.%u
index: 0x1e7, decrypted string: adrclient.dll
index: 0x1f5, decrypted string: net share
index: 0x1ff, decrypted string: qwinsta
index: 0x207, decrypted string: \System32\WindowsPowerShell\v1.0\powershell.exe
index: 0x237, decrypted string: at.exe %u:%u "%s" /I
index: 0x24c, decrypted string: Self test FAILED!!!
index: 0x260, decrypted string: Component_07
index: 0x26d, decrypted string: whoami /all
index: 0x279, decrypted string:  /c ping.exe -n 6 127.0.0.1 &  type "%s\System32\calc.exe" > "%s"
index: 0x2bb, decrypted string: error res='%s' err=%d len=%u
index: 0x2d8, decrypted string: nltest /domain_trusts /all_trusts
index: 0x2fa, decrypted string: .lnk
index: 0x2ff, decrypted string: cmd
index: 0x303, decrypted string: schtasks.exe /Create /RU "NT AUTHORITY\SYSTEM" /SC ONSTART /TN %u /TR "%s" /NP /F
index: 0x355, decrypted string: %s \"$%s = \\\"%s\\\\; & $%s\"
index: 0x374, decrypted string: ERROR: GetModuleFileNameW() failed with error: %u
index: 0x3a6, decrypted string: schtasks.exe /Delete /F /TN %u
index: 0x3c5, decrypted string: arp -a
index: 0x3cc, decrypted string: Self check ok!
index: 0x3db, decrypted string: cmd.exe /c set
index: 0x3ea, decrypted string: %s %04x.%u %04x.%u res: %s seh_test: %u consts_test: %d vmdetected: %d createprocess: %d
index: 0x443, decrypted string: Microsoft
index: 0x44d, decrypted string: powershell.exe -encodedCommand %S
index: 0x46f, decrypted string: SELF_TEST_1
index: 0x47b, decrypted string: microsoft.com,google.com,kernel.org,www.wikipedia.org,oracle.com,verisign.com,broadcom.com,yahoo.com,xfinity.com,irs.gov,linkedin.com
index: 0x501, decrypted string: c:\ProgramData
index: 0x510, decrypted string: nslookup -querytype=ALL -timeout=12 _ldap._tcp.dc._msdcs.%s
index: 0x54c, decrypted string: %u;%u;%u;
index: 0x556, decrypted string: powershell.exe -encodedCommand 
index: 0x576, decrypted string: runas
index: 0x57c, decrypted string: /teorema505
index: 0x588, decrypted string: Self test OK.
index: 0x596, decrypted string: ProfileImagePath
index: 0x5a7, decrypted string: p%08x

Based on the list of decrypted strings above, after analyzing the code and comparing it to the old idb of the 32-bit version, I found a string at offset 0x182 that is used for the decoding process of Campaign and C2 addresses of Qakbot:

0x182: “T2X!wWMVH1UkMHD7SBdbgfgXrNBd(5dmRNbBI9”

The decryption process in this new version has some changes compared to the old version that I described here:

  • Configuration data is stored in the .data section instead of the resource as in the old version.
  • AES is used for decryption instead of RC4.

Campaign decryption process as pseudo-code:

Encrypted campaign info stored at section .data:

The function qbot_aes_decrypt_and_check_sha256_wrap (0x180015D14) makes a call to the function qbot_aes_decrypt_and_check_sha256.

Based on the pseudocode above, the encrypted data is declared as a struct as follows:

The code in function qbot_aes_decrypt_and_check_sha256 (0x1800163E8) reuses the qbot_decrypt_xor_key_blob function (0x180011504) that I described above to perform data decryption. Specifically:

  • AES Key: SHA256("T2X!wWMVH1UkMHD7SBdbgfgXrNBd(5dmRNbBI9")
  • AES IV: The first 16 bytes of pbEncData

The decrypted data includes the first 32 bytes (0x20) as the sha256 checksum, which is used to verify the integrity of the decrypted configuration. The entire pseudocode for the function is shown below:

With the help of CyberChef, we can perform decryption as follows:

The method of decrypting C2 address list follows the same procedure as described above.

A Python script can be rewritten to automate the entire process of decoding Campaign and C2 addresses. The results obtained are:

# QakBot Config
----
   ID : b'tchk08'
   b'40' : b'1'
   Timestamp : 21:22:34 31-01-2024
----
# QakBot C2 address
```
31.210.173.10:443
185.156.172.62:443
185.113.8.123:443

Comments
  1. […] 0day in {REA_TEAM}[QuickNote] Qakbot 5.0 – Decrypt strings and configuration […]

  2. […] 0day in {REA_TEAM}[QuickNote] Qakbot 5.0 – Decrypt strings and configuration […]

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.