More Memory Fun

Using memory analysis to pull Dyre Trojan config

Jeremy Scott

July 09, 2015 - Posted by Jeremy Scott to Security Insight

A couple of years ago, I published a blog on Hunting Malware with Memory Analysis. Well, it is past time to dive back in to some memory analysis fun. This time, however, we will use memory analysis techniques to retrieve the Dyre Trojan configuration.

Dyre is a well-known banking Trojan that harvests credentials, primarily targeting online banking. It does this by using man-in-the-browser functionality and dynamic web injects to manipulate content on a financial institution's website and intercept credentials and sensitive information of the victim. This is where the configuration file comes in. The configuration file contains the proxy server(s) controlled by the attackers and the target bank URLs that trigger the man-in-the-browser to redirect the connection to the designated proxy server. Dyre’s configuration file looks like the following:

Figure 1

Because the plain text configuration file is held in memory, this is the easiest approach to retrieving it. There are two different approaches you can take here. The first is that you can do a full memory dump of the system or you take the second approach, and dump only the process memory of the injected process. If you take the full memory dump approach, you can use the volatility plugin dyrescan. I’ve had issues with the plugin actually dumping the configuration file contents at times, but it will help identify the injected process, which is typically the top most svchost process. In this example it is injected into the explorer.exe process.

Figure 2
 
For the first approach, you can dump the explorer.exe (2180) process using volatility to start the extraction process.

Figure 3
 
However, if you want to start with the second approach and just dump the injected process memory of an infected host, you can use Windows Sysinternals Process Explorer. After using it, right-click the injected process, then select Create Dump/Create Full Dump.

Figure 4

Now that we have a memory dump to work with, we can get the contents of the configuration file. The configuration file typically starts with the string “<serverlist>” and ends with “</localitems>”. Using the strings command and sed stream editor, we are able to retrieve the configuration. From here you can copy and paste or redirect the output to a text file.

Figure 5
 
Now let’s look at what else can we get from memory related to Dyre. For many researchers, tracking the Dyre Trojan is done with the “botid” or campaign. The botid is typically contained in the command-and-control (C2) uniform resource identifier (URI) structure immediately following the domain or IP address. The configuration file is retrieved as part of the initial communication performed by Dyre, so the URI structure is contained in memory. The string typically starts with “tps:”. Using this knowledge we can extract those strings, like so:

Figure 6
 
By using awk and sed, we can pull just the botid for the strings above.

Figure 7

If you are interested in getting a list of the bank URLs that are targeted by Dyre to perform victim redirection you can dump them all as shown below.

Figure 8

The following is an example of putting all of this together to make life a little easier. It’s not perfect and could probably use some additional work, but it does the job.
Figure 9
There may be other ways to figure out the exact impact that Dyre is having on your environment. But, checking what Dyre says it is doing may be the most effective way. And, I thinking dumping Dyre's configuration file from memory is a pretty good way to see what Dyre is actually doing. Keep in mind though that Dyre continues to evolve and any techniques to retrieve the configuration file and additional memory contents might need to change with the evolution.

Be calm and memory on.

REFERENCE LINKS:  
https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
http://www.volatilityfoundation.org/
https://github.com/volatilityfoundation/volatility
https://github.com/kudelskisecurity/Volatility-plugins/blob/master/dyrescan.py
https://www.solutionary.com/resource-center/blog/2012/12/hunting-malware-with-memory-analysis/

Read more on Solutionary Minds about:

Voted one of the Best Computer Security Blogs 2016
NTT Security (US), Inc. (formerly Solutionary) is a security consulting and managed security services provider. The NTT Security blog is a place for IT professionals to both learn and talk about the latest in IT security and compliance.

Get the NTT Security Blog delivered to your inbox!

Enter your Email:

(We will not share your email or use it for anything else.)

LATEST TWEETS