詮睿科技

Talent-Jump Technologies, Inc

Technical Blog

CLAMBLING - A New Backdoor Base On Dropbox (EN)



中文版本

In July 2019, one of our customer’s company suffering the APT attack and we start the investigation immediately. During the investigation we found a brand new backdoor sample, which implements lots of features by using Dropbox API, using Dropbox like a C&C server. After the reverse engineering, we extract the Dropbox token used by the sample, dig into Dropbox folder, and reveal the whole functional structure.

The report is co-authored with Trend Micro.

Kenney Lu, Daniel Lunghi, Cedric Pernet, and Jamz Yaneza. (17 February 2020). Trend Micro. “Operation DRBControl - Uncovering A Cyberespionage Campaign Targeting Gambling Companies In Southeast Asia”

First Stage Infection

The threat actor uses Windows Defender Core Process MsMpEng.exe which has a legal digital signature to load the malicious DLL file. Load the shellcode from the payload file then release the final malicious executable to complete the first stage infection.

During the investigation, we found a total of 8 different loader’s filenames [Appendix 1] renamed from MsMpEng.exe and placed at C:\ProgramData\Microsoft in its separated folder. The loader is just called the function ServiceCrtMain imported from mpsvc.dll.

The malicious DLL file mpsvc.dll has two types [Appendix 2]. The older type will try to read shellcode from payload file English.rtf, decode and decompress the content using RtlDecompressBuffer to release the final executable (Figure 1).
Figure 1. Older type of mpsvc.dllFigure 1. Older type of mpsvc.dll

The newer one has a different way to start the infection. There is a piece of shellcode hard-coded in the mpsvc.dll, after decoding the shellcode from mpsvc.dll, it will inject and execute to load the shellcode from mpsvc.mui (Figure 2), which will release the final executable and inject into the process.

Figure 2. Newer type of mpsvc.dllFigure 2. Newer type of mpsvc.dll

Both of these two types of mpsvc.dll will release a full functional backdoor, which can connect to the C&C server. But the final executable released by a newer type of mpsvc.dll has some upgrade, including the function to interact with Dropbox API. The following article will focus on the malicious executable released by the newer type of mpsvc.dll.

The hardcoded shellcode in a newer type of mpsvc.dll will first allocate 0x80000 bytes of memory space. Getting the current module’s full path and replace the extension dll to mui and read the shellcode in this mui file, then jump to the base address of mui file plus its first byte. (Figure 3)

Figure 3. Decoded shellcode in mpsvc.dllFigure 3. Decoded shellcode in mpsvc.dll

In the end, the shellcode in mpsvc.mui has another different piece of hard-coded bytes, which will decompress by RtlDecompressBuffer to the final malicious executable (Figure 4).

Figure 4. The final malicious executable in buffer.Figure 4. The final malicious executable in buffer.

Sample Analysis

The final malicious executable sample we extracted has numerous features. Here is the analysis of some major functions.

Bypass UAC

This sample can bypass UAC via .NET. It is not a new technique which was disclosed in 2017 [1], the threat actor only changes the GUID to 9BA94120-7E02-46ee-ADC6-10640B04F93B (Figure 5) and specify the location of DLL file which will load by the .NET application in the elevated process.
Figure 5. Code snippet of bypass UAC.Figure 5. Code snippet of bypass UAC.

Persistence

There are two ways to persist. Register as a startup program in HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run if it has no privileged (Figure 6). Otherwise, it will register itself as a system service (Figure 7).

Figure 6. Register as a start program.Figure 6. Register as a start program.
Figure 7. Register as  a system service.Figure 7. Register as a system service.

Information Gathering

It will collect some basic information like IP address, hostname, username, OS version and so on. Also, it will search the registry key’s value HKEY_CURRENT_USER\\Software\\Bitcoin\\Bitcoin-Qt and try to look for the wallet address if exist (Figure 8). All of this information will upload to Dropbox as %Y-%m-%d %H-%M-%S.log, below is a file sample:

Lan IP: x.x.x.x
Computer: WIN-XXXXXX
UserName: Administrator
OS: Win10(X64)
Version: 8.0
Bit: Not Found !!!
Exist: NO

Figure 8. Code snippet of information gathering.Figure 8. Code snippet of information gathering.

Recording Features

This sample acquired three types of recording features, including key-log, clipboard log, and screen recording. The screen recording file naming format is [%y-%m-%d] %H-%M-%S.avi. The key-log and clipboard log will encode by different key and salt, then save as <hash>.pas for key-log and <hash>.log for clipboard log (Figure 9).

Figure 9. Code snippet of key log encoding.Figure 9. Code snippet of key log encoding.

Connect to C&C Server

This sample can also connect to a specific C&C server and send back data by using a fake HTTP POST request (Figure 10).

Figure 10. Code snippet of preparing for fake POST request.Figure 10. Code snippet of preparing for fake POST request.

RTTI Information

The RTTI information remaining, here is the full class name list we got:

Interact With Dropbox

During reverse engineering, we found that the Dropbox API token with 64 characters is hardcoded in stack string (Figure 11).

Figure 11. Code snippet for the first 24 characters of Dropbox API token.Figure 11. Code snippet for the first 24 characters of Dropbox API token.

Besides connecting to the C&C server, this sample can also upload & download with Dropbox API. Especially when the log file is uploaded, it will try to download bin.asc and check the file has fake GIF file header or not. If everything is correct, it will continue to the custom decoding phase, which will calculate with an array of bytes hard-coded in the sample, to release the inject payload (Figure 12).

Figure 12. Code snippet of interaction with Dropbox API.Figure 12. Code snippet of interaction with Dropbox API.

Inside of Dropbox Folder

After we got the Dropbox token, we can now dig into Dropbox by using official API, for example, list the account information which creates this token, list the full file and folder information.

In the Dropbox, the folder structure like this:

/<unique_hash>/%Y-%m-%d\ %H:%M:%S.log
/<unique_hash>/bin.asc
/codex64bin.asc
/codex86bin.asc
/x64bin.asc
/x86bin.asc

Each infected victim has its folder named by unique hash /[0-9A-z]/, this hash is generated by machine key and some other information. %Y-%m-%d\ %H:%M:%S.log is the log file upload by the victim. *.asc is the file upload by the threat actor. For example, bin.asc is the payload download by the victim when the log file is upload succeeds.

Sort out the log file on Dropbox, we can get the full list of infected computers (Figure 13).

Figure 13. The list of infected computers.Figure 13. The list of infected computers.

Second Stage Infection

After the first infection stage completed, it will persistent itself as a system service or autorun program. Collecting information and establish a connection to the C&C server. The most interesting part is each time when the log file is upload succeeds, it will try to download bin.asc from each computer’s unique folder. Most of bin.asc we captured is requesting the victim to download x64bin.asc file from Dropbox.

Further analysis of x64bin.asc, we found the second Dropbox API token, its purpose is different from the first one. Now the threat actor is ready to use Dropbox as another C&C server with the full backdoor feature.

The second infection stage’s sample has some bonus features including the ability to interact with Dropbox, the command code mapping show as below:

Command Code Action
2 ListDrives
3 ListFiles
4 ExecuteFile
5 ManageFile
6 UploadFile
7 DownloadFile
8 OpenTerminal

In these commands, there are three different files, each of these file has specific filename and purpose:

The status file eLHgZNBH contain the basic information about victim and timestamp, upload to Dropbox at regular intervals. Whenever status file upload succeeds, it will try to download the command file yasHPHFJ if it existed. Extract the command code and arguments from yasHPHFJ then execute the command and upload the execution result to Dropbox as csaujdnc (Figure 14).

Figure 14. Flow of three files interact with DropboxFigure 14. Flow of three files interact with Dropbox

By using this control flow, the threat actor can use Dropbox as a C&C server to control the victim’s computer even the fixed connection between the specific C&C server’s IP address has been found and blocked. Unless we block content.dropboxapi.com and api.dropboxapi.com, otherwise we can not isolate the infected computer.

The Dropbox API remain the detail of each file and folder, for example this is a file information return by Dropbox API:

{
    '.tag': 'file',
    'name': 'Secret_File.txt',
    'path_lower': '/secret_file.txt',
    'path_display': '/Secret_File.txt',
    'id': 'id:<UNIQUE_FILE_ID>',
    'client_modified': '2019-07-21T02:45:42Z',
    'server_modified': '2019-07-21T02:53:04Z',
    'rev': '[0-9a-f]{6,}',
    'size': 125,
    'is_downloadable': True,
    'content_hash': '<SHA256_HASH>'
}

It contains the server_modified timestamp even with history revision file id, we can use rev to list the full history of this file and download it. Sort out this information and the command code mapping, we can now list the full command executed on each computer and its arguments. Here is two computers’ execution list (Figure 15 & 16).

Figure 15. Real command execution list from one victim.Figure 15. Real command execution list from one victim.
Figure 16. Another real command execution list.Figure 16. Another real command execution list.

According to these record, the threat actor follows almost the same action on every infected computer. First, download additional attack programs from Dropbox, like mimikatz or other UAC bypass tools. Second, search the high-value file including private source code, config file, database, and the key-log / clipboard log. Upload all of these files to Dropbox for further searching. Last but not least, infiltrate the company intranet or even the cloud service.

Combining all decoded yasHPHFJ files, we can show the threat actor’s approximate working hours (Figure 17).

Figure 17. The threat actor’s approximate working hours.Figure 17. The threat actor’s approximate working hours.

Conclusion

We start to monitor the Dropbox for each token and parse the infected computer’s list, here we can see the infected computer’s number from July 2019 to September 2019 this two month (Figure 18 & 19).

Figure 18. Dropbox A (first token): infected computer’s number.Figure 18. Dropbox A (first token): infected computer’s number.
Figure 19. Dropbox B (second token): infected computer’s number.Figure 19. Dropbox B (second token): infected computer’s number.

We got nearly 200 infected computers at the highest peak from Dropbox A, alone with nearly 80 computers from Dropbox B. Both of these static has a drop at August 21, 2019, the threat actor clear the Dropbox folder for some reason. Monitoring ends on September 20, 2019, all tokens we got are revoked by the threat actor.

During these two months, we got five different Dropbox token. Each of these tokens has its purpose. The first two tokens are the major one we discuss in this article, others are more like for testing.

From the first infection stage, established the connection between the C&C server and Dropbox at the same time. If the IP address of the C&C server been blocked, it can still have limited control from Dropbox. Once it completed the second infection stage, Dropbox is turning into a second channel C&C server which has full remote control features (Figure 20). Steal the data and infiltrate the whole company. This method is not complex but very useful.

Figure 20. The whole interaction flow from infection to interact with Dropbox.Figure 20. The whole interaction flow from infection to interact with Dropbox.

Appendix

  1. Loader

    • 33bc14d231a4afaa18f06513766d5f69d8b88f1e697cd127d24fb4b72ad44c7a
      • msmpeng.exe (PE32)
    • 99042e895b6c2ea80f3ba65563a12c8eba882e3ad6a21dd8e799b0112c75ddd2
      • rsoplicy.exe (PE32+)
      • DRM.exe (PE32+)
      • Firewall.exe (PE32+)
      • Kaspe.exe (PE32+)
      • RSoPProv.exe (PE32+)
      • Video.exe (PE32+)
      • WinDRM.exe (PE32+)
  2. DLL & Payload File

    • mpsvc.dll
      • a58946c10c8325040634f7cd04429b9f1e3715767d0c8aec46b7cba8975e6a69
      • e18af309ecc3bc93351b9fa13a451e8b55b71d9edcc4232bc53eb1092bdfa859
    • English.rtf
      • 52c147c8eadb58d3580b39c023ce4a90dacce76ee5c30c56c56ea39939a56b52
      • b5546d4931a0316abd4018c982558ed808b4d0a60233ac18bee601fa09d95ee6
      • dd0399970d2dbb5ab8b5869e2fafb83194c992f27bbb244adce35e2fe6ef0d28
    • mpsvc.mui
      • 0693713f995285e8bd99ebfca2c4f0f1a8e824dafb5a99693442a9256df06e02
      • 24ebd398be23135a2d8aa7000c2b6a534448b87aa5708b8546089630a8035f7e
      • 56758c25e3b00957c6f7f76fcea5d0598eff7eda98c63f50b51d1c28f267ac8f
      • 96282a625a31b6bf646c6e01ad20de96fd63c345881a9c91190940121580059d
      • 99663b9ba27a36ff9fc64b72213e933067ee0cde38b39d20ae4326a37185811d
      • 9dd1d21e9431cfe25709a8f26ec0f605ed19cf64ca1922e97fad7b7f2d2e82ea
      • b226c8e85a7b1a6d4d29d42fc84bc7f3a32335fc7ba44b455a7716d706660873
      • e716506cf54f48d77382d8955512184b45dd7d0b58c22e32424c56d38db24360

References

  1. UAC bypass via elevated .NET applications
  2. Dropbox for HTTP Developers
  3. https://www.trendmicro.com/vinfo/us/security/news/cyber-attacks/operation-drbcontrol-uncovering-a-cyberespionage-campaign-targeting-gambling-companies-in-southeast-asia


Comments