For the complete documentation index, see llms.txt. This page is also available as Markdown.

Remcos RAT Analysis

Overview

Remcos (acronym of Remote Control & Surveillance Software) is a commercial Remote Access Tool to remotely control computers. It is advertised as legitimate software which can be used for surveillance and penetration testing purposes, but has been used in numerous hacking campaigns. Remcos, once installed, opens a backdoor on the computer, granting full access to the remote user. It is developed by the cybersecurity company BreakingSecurity.

SAMPLE - 3def24b7506a546ad97fa0447777e57d78aaf37d9e9234240acae6fc582b7f22

Static Analysis - Stage 1

After downloading the sample I did a basic search over MalwareBazaar and virustotal to get some intel about the malware, it came out that it was marked malicious by 11 vendors in malwarebazaar and 14 by virustotal.

Figure 1: Virustotal

Figure 2: Junk strings with special characters

After extraction, got a js script which means that this malware is spreading via E-mail attachements and can be of other file formats too. When i opened it script in notepad, its highly obfuscated with junk strings and special characters and in between these strings code of malware resides. After clearing out junk strings I got the main code but its still highly obfuscated to read and still contained those junk strings, this was done change the entropy of malware and make it difficult for AV to detect. But scrolling through code some strings caught my attention like SaveToFile, Run, CreateObject, PublicLibraries.

Figure 3: Obfuscated strings

So the script starts with a IIEF after deofuscating, its understood that it performs String Array Rotation by moving first item to end, with paramters _0x4085 which might be long list of scrambled strings and 0x50ea0 as target value. Then this function WWWWWWWWW(_0x51c5bf) which is a custom encoder and decoder that maps character to custom codes back and forth like 80 <-> 00C7 and next it again has same function that does same thing but its like a different version of it.

Then there is VDJZUXZDMZHYJTWOMKOIJDVYGRIYWBWPBFAVPKJIZOSXBQMQXOCGGHJXX which is string retriever wrapper that first redefines itself so setup code don't have to be called again and again, just returns value by calculating index and fetching string at that index also it immediately calls itself so that redefined function now being utilized.

It then uses split and join technique to execute Windows script host using ActiveXObject like WScript.Shell, Scripting.FileSystemObject etc. Then there are some more custom mapped codes and after that it has a varible that store something likely a path but obfuscated between lots of 99 so now we can get what its really mean by using same techniques split and join, and i got the path C:\Users\Public\Libraries\. It then check for a filename VDJZUXZDMZHYJTWOMKOIJDVYGRIYWBWPBFAVPKJIZOSXBQMQXOCGGHJ if not exist then creates it in directory and afterwards builds certain variables like newpath, MNBYTUIOP from which MNBYTUIOP stores Scripting.FileSystemObject and creates its object which gets stored in newpath.

Now it checks existence of newly created file and also checks if BBBBBSTBBBBB is equal to YESSSSSSSS, obviously not then copies current running script into a directory and then it builds shell command cmd /c schtasks /create /sc minute /mo 10 /tn which is using schedule task for persistence and it runs this task every 10 minutes.

makeid is used to generate random strings for files and directories and also a string reversal function FDAWE that work is to reverse the string and join it together during execution. Now it creates a new object of Microsoft.XMLDOM and creates a t element with datatype of bin.base64 also applies FDAWE on a large blob and cleans out(replace all symbols to space) that blob to store it as a text. Here is the script of it:

And it then writes binary data using ADODB.Stream and save it into file VDJZUXZDMZHYJTWOMKOIJDVYGRIYWBWPBFAVPKJIZOSXBQMQXOCGGHJ and overwrites if already present. Then it does same thing again twice and stores them in .exe and .png file at same location. Now it creates WScript.Shell object and runs both exe and png binary. So this js script is just a dropper which dumps the exe and a png file also making persistence using schedule task.

Dynamic Analysis - Stage 1

I just executed the script and since we already know where its gonna be dropped and it will also schedule task So lets analyze whats happens after its being executed with system informer opened.

Figure 4: Dropping files and colorcpl.exe process

It dropped the malware in C:\Users\Public\Libraries and starts the malware with colorcpl.exe but one thing to note that it uses schedule task for persistance but i didn't saw any entry in autorun to verify it i even put all tasks in a text file and searched in that too but nothings there, its because above condition not satifies that YESSSSSSS check.

Static Analysis - Stage 2

Now lets analysze the dropped exe, implant and png file and the exe file came out to be a autoit script so we need to decompile it but the tools like myAutToExe, autoit-ripper are failing because maybe it can have different header. But I was wrong the main script code is written in that png file and the exe file somehow runs the command in the png file.

Figure 5: Flow of malware which i understood

So now, lets analyze what the script does? At first, it has a custom decryption function that takes strings data, convert it to binary and perform BitXOR operation using key 99.Here is the python equivalent script of it:

Figure 6: Reads raw blob data

Now it creates a struct using DllStructCreate and set some values to it you can also see what its doing just by putting those hex values to script, and then do some checks using Dllcall for strings like kernal32.dll, C:\Windows\Syswow64\colorcpl.exe, CreateProcessA means calls Create process of colorcpl in suspended state, if the checks passes then it opens the raw blob file VDJZUXZDMZHYJTWOMKOIJDVYGRIYWBWPBFAVPKJIZOSXBQMQXOCGGHJ reads it and sets the blob after decoding it using BitXOR with key 1185463. It utilizes same process hollowing techniques as AgentTesla using NtAllocateVirtualMemory, NtWriteVirtualMemory, NtCreateThreadEx to inject the shellcode in legitimate windows process colorcpl.exe.

Dyamic Analysis - Stage 2

Figure 7: Interesting strings

So I ran the dropped malware again and dumped all the things while the malware is running as colorcpl using procdump and saw strings like Remcos Agent initialized, details about user, OS, CPU and its architecture and some dns like mindabusiness.duckdns.org, mattersthatmatters.duckdns.org, greatmatteronly.duckdns.org also hints that it crafts http requests. Also it logs the keystrokes, credential theft.

Figure 8: HTTP request hints

Figure 9: List of different domains and subdomain

Figure 10: Trying to communicate to DNS domains

It also tweaks settings of the browser and there is a big list of different domains and subdomains which maybe used as different C2 domains so in case if one goes down it switch to other domain and RAT will still work. While malware is running i made a fakenet to see the C2 domain and got a IP 185.208.156.187 to which is flagged suspicious by a vendor.

IOC

  • DNS Domains: mindabusiness.duckdns.org, mattersthatmatters.duckdns.org, greatmatteronly.duckdns.org

  • Legitimate Process: colorcpl.exe

  • Hashes

  • C2 IP: 185.208.156.187

Last updated