New tricks ship with Zeus packer

2012-12-03

Jie Zhang

Fortinet, China
Editor: Helen Martin

Abstract

Recently, the Pony trojan (a.k.a. FareIt) has been observed installing a new Zeus sample on users’ machines. Jie Zhang takes a look at the new packer tricks that are used by this latest Zeus sample.


Zeus (a.k.a. ZBot) is a famous banking trojan which steals bank information and performs form grabbing. It was first identified in July 2007. A fully functioning Zeus bot could be sold for hundreds of dollars on the underground market. The bot’s development was very rapid, and it soon became one of the most widespread trojans in the world. In late 2010, the creator of Zeus, ‘Slavik’, announced his retirement and claimed that he had given the Zeus source code and the rights to sell the bot to his biggest competitor, the author of the SpyEye trojan. However, despite the retirement of its creator the total number of Zeus bots didn’t decrease. There are still many living Zeus bots in the wild. In particular, many new Zeus bots were discovered after its source code was leaked [1]. Some of them shipped with P2P capability [2], others could even infect Symbian, Windows Mobile, BlackBerry or Android phones [3].

Pony!Pony!

Zeus spreads mainly via drive-by download or phishing schemes. Recently, we found that the Pony trojan (a.k.a. FareIt) had started to install a new Zeus sample on users’ machines. The Pony trojan (version 1.0) steals account information or credentials from compromised machines and sends them back to its remote server. At the same time, it downloads three pieces of malware and launches them automatically. The Pony trojan also attempts to brute force the current user’s password with a built-in password dictionary (see Listing 1) using the LoginUserA API.

.data:00414000    db ‘123456’,0
.data:00414007    db ‘password’,0
.data:00414010    db ‘phpbb’,0
.data:00414016    db ‘qwerty’,0
.data:0041401D    db ‘12345’,0
.data:00414023    db ‘jesus’,0
<removed>
.data:0041472C    db ‘gates’,0
.data:00414732    db ‘billgates’,0
.data:0041473C    db ‘ghbdtn’,0
.data:00414743    db ‘gfhjkm’,0
.data:0041474A    db ‘1234567890’,0

Listing 1: Pony’s built-in password dictionary.

Back to Zeus

In this article, we will focus on the new packer tricks that are used by this new Zeus sample.

Dynamic code decryption/encryption

Nowadays, most malware encrypts and/or compresses its core data to evade anti-virus detection. To make life harder for malware researchers and/or memory dump forensic tools (such as Volatility [4]), some malware families have evolved dynamic data encryption and decryption mechanisms. This kind of virus will only decrypt the important data when it plans to use it, and then re-encrypts the data afterwards. In this way, malware researchers can only see a little data when they perform dynamic analysis on such a sample.

The Zeus sample takes advantage of a trick which I call ‘binary code dynamic decryption and encryption’. The virus encrypts almost all important function calls. When one function is invoked, it will call a routine to decrypt part of the binary code (Figure 1). Before leaving this function, another routine will be called to re-encrypt the function code (Figure 2). Thus researchers will only see a few parts of code at a time when they examine the sample. As I recall, this trick can be traced back to the DOS era.

Decryption on entering function.

Figure 1. Decryption on entering function.

Encryption on leaving function.

Figure 2. Encryption on leaving function.

Dynamic TLS callback

Thread Local Storage (TLS) callback [5] has existed for many years, but until now, not many viruses have used the technology. However, ZeroAccess introduced this mechanism into its latest version and Zeus has followed suit. This version of Zeus uses a method which I call ‘dynamic TLS callback’.

When we researched this sample with static analysis, we didn’t find any malicious code in its entry point. But when we loaded it with a debugger, we found that the virus was already running when the debugger placed a break in its entry point (Figure 3).

Break in virus entry point.

Figure 3. Break in virus entry point.

We concluded that the virus uses TLS callback technology. Checking the file with PEiD confirmed our suspicions (Figure 4).

TLS table in PEiD.

Figure 4. TLS table in PEiD.

We also checked the file with IDA, which showed that there is only one TLS callback routine, TlsCallback_0, in the TLS callback table (Figure 5).

TLS callback table.

Figure 5. TLS callback table.

If the TLS callback routine of this virus were used for self-protection or to execute the virus code directly, our story would end. However, this is not the case.

The first (and, until now, only) TLS callback routine is very simple. But there is a point that has grabbed our attention:

The instructions shown in the red rectangle in Figure 6 modify the TLS callback function table. When the TLS callback routine returns to the system, the system will query the next TLS callback stored in the table. If the next TLS callback routine is not ZERO, the system will invoke it and increase the counter. For now, as the next TLS callback routine has been set to ‘TlsCallback_1’, the system will call this function, as shown in Figure 7. We call this mechanism ‘dynamic TLS callback’.

Modify TLS callback table in TlsCallback_0.

Figure 6. Modify TLS callback table in TlsCallback_0.

OS calls next TLS callback routine.

Figure 7. OS calls next TLS callback routine.

We can see that the virus uses the same trick again in the TlsCallback_1 routine (Figure 8).

Modify TLS callback table in TlsCallback_1.

Figure 8. Modify TLS callback table in TlsCallback_1.

After completing the dynamic TLS callback trick twice, the virus will decrypt the real Zeus module and execute it in the TlsCallback_2 routine.

Scramble with junk instructions

The virus inserts a lot of junk instructions in order to scramble the code [6]. These instructions are very simple, so we will not elaborate on the details.

Packer payload

The virus attempts to decrypt the real Zeus module with the Blowfish algorithm, as shown in Figure 9.

Zeus packer payload.

Figure 9. Zeus packer payload.

The decryption key follows the string ‘n3s(#,pSvW?y}A%LBk<’. After decryption, the virus will create a clone process with the CREATE_SUSPENDED flag. Then it loads and maps the real Zeus to a new process. Finally, we retrieve a complete, non-encrypted version of the Zeus sample.

Conclusion

In this article, we have demonstrated some unusual tricks in Zeus’s new armour. The use of these skills is simple, but often confuses new malware researchers. With the development of the virus, these tricks are likely to become much more complex and more difficult to detect, posing some challenges for malware researchers and anti-virus engines alike.

Bibliography

[1] Kruse, P. ZeuS/Zbot source code for sale. CSIS blog. http://www.csis.dk/en/csis/blog/3176/.

[2] Zeus peer-to-peer feature. The Swiss Security Blog. http://www.abuse.ch.

[3] Apvrille, A. Zeus In The Mobile (Zitmo): Online Banking’s Two Factor Authentication Defeated. FortiBlog. http://blog.fortinet.com/zeus-in-the-mobile-zitmo-online-bankings-two-factor-authentication-defeated/.

[5] Zeltser, L. How Malware Defends Itself Using TLS Callback Functions. ISC Diary. https://isc.sans.edu/diary.html?storyid=6655.

[6] Zhang, J.; Xie, D. Scrambler, a new challenge after the warfare of unknown packers. AVAR 2009.

twitter.png
fb.png
linkedin.png
hackernews.png
reddit.png

 

Latest articles:

Nexus Android banking botnet – compromising C&C panels and dissecting mobile AppInjects

Aditya Sood & Rohit Bansal provide details of a security vulnerability in the Nexus Android botnet C&C panel that was exploited to compromise the C&C panel in order to gather threat intelligence, and present a model of mobile AppInjects.

Cryptojacking on the fly: TeamTNT using NVIDIA drivers to mine cryptocurrency

TeamTNT is known for attacking insecure and vulnerable Kubernetes deployments in order to infiltrate organizations’ dedicated environments and transform them into attack launchpads. In this article Aditya Sood presents a new module introduced by…

Collector-stealer: a Russian origin credential and information extractor

Collector-stealer, a piece of malware of Russian origin, is heavily used on the Internet to exfiltrate sensitive data from end-user systems and store it in its C&C panels. In this article, researchers Aditya K Sood and Rohit Chaturvedi present a 360…

Fighting Fire with Fire

In 1989, Joe Wells encountered his first virus: Jerusalem. He disassembled the virus, and from that moment onward, was intrigued by the properties of these small pieces of self-replicating code. Joe Wells was an expert on computer viruses, was partly…

Run your malicious VBA macros anywhere!

Kurt Natvig wanted to understand whether it’s possible to recompile VBA macros to another language, which could then easily be ‘run’ on any gateway, thus revealing a sample’s true nature in a safe manner. In this article he explains how he recompiled…


Bulletin Archive

We have placed cookies on your device in order to improve the functionality of this site, as outlined in our cookies policy. However, you may delete and block all cookies from this site and your use of the site will be unaffected. By continuing to browse this site, you are agreeing to Virus Bulletin's use of data as outlined in our privacy policy.