The curious case of a CVE-2012-0158 exploit
CVE-2012-0158 is a buffer overflow vulnerability in the ListView / TreeView ActiveX controls in the MSCOMCTL.OCX library. The malicious code can be triggered by a specially crafted DOC or RTF file for MS Office versions 2003, 2007 and 2010. Although this vulnerability was patched by Microsoft more than a year ago, it seems that not everyone cared to install the updates. And those who didn't may be at risk of getting all their documents, pictures and databases encrypted by a new version of the Gimemo ransomware (detected by our products as Trojan-Ransom.Win32.Gimemo.beic).
As the binary is still being analyzed, in this article we will focus only on the delivery part. Even if the exploit is not a zero-day, it's pretty interesting because of the code complexity (it consists of 4 stages!) and the simple-yet-effective anti-heuristic techniques it uses.
The ransomware is dropped and executed by a malicious RTF file (“Указ Президента от 12.06.2013.doc", which translates to “Presidential Decree 12.06.2013.doc”) attached to mass-mailed messages. The outbreak seems to have taken place on 18 June 2013 when Kaspersky Security for Linux Mail Server detected hundreds of such messages as malicious (identifying them as Exploit.Generic.Dropper.a). So far, it seems that only Russian-speaking users are being targeted and most of the emails we've seen were sent from an IP address in Germany, with the header that's the same or similar to this one:
"Received: from bersar by 24-host.com with local (Exim 4.69)(envelope-from <admin@24-host.com>)id"
The RTF file contains three embedded objects. The first one is a package consisting of a 12-byte signature and the malicious binary followed by the final (4th) stage of shellcode (both “encrypted” with XOR 0x9D) .
This signature is used later by the stage 3 shellcode to find the rest of the shellcode and the binary in memory.
The second object is an OLE object - that contains a malformed DOC file, which triggers the buffer overflow and executes shellcode. Embedding this document using Object Linking and Embedding technology means that in the source of the original RTF file we will see the ASCII representation of malicious hex code, rather than the hex code itself. This is a primitive technique that may result in bypassing some simple heuristic mechanisms. Furthermore, the malware writer also took care to obfuscate all of the constant values that are used in processing the ListView ActiveX control. The idea here was to inject brackets and whitespaces into these values, making them harder to recognize, while they are fully ignored during the processing of the OLE compound document.
If we open the malicious RTF file in the hex editor, it's not so easy to spot the exploit code at first glance. But once we've figured out the location of the ListView CLSID, things become a little bit easier. But no point in looking for the most popular exploit opcodes, like 0xEB (JMP instruction) or 0xE8 (CALL instruction); this exploit aims higher. Firstly, it tries to bypass Data Execution Prevention by using a ROP chain build upon the instructions from the vulnerable version of MSCOMCTL.OCX library. Secondly, it uses FLDZ + FSTENV instructions to get the instruction pointer, which is an old but fairly uncommon technique and might overlooked, especially if surrounded by some fake, legitimate-looking mathematical operations.
ROP (Return Oriented Programming) is a method invented a couple of years ago against Data Execution Prevention. Instead of trying to directly execute code in memory that might be marked as non-executable, the exploit makes use of appropriate instruction sequences from one of shared libraries, assuming that this library was loaded in memory at some predictable address. In this case, the ROP chain is designed to allocate space on a heap, copy the second stage of shellcode from the stack to this executable memory and simply call it.
The second part of the shellcode is obfuscated with lots of junk instructions, which have no significant effect, but are here to fool the heuristics and impede analysis. When we exclude these meaningless instructions (marked with “-----” comment on the screenshot below), we can clearly see that this part is responsible for decrypting the third stage of the shellcode. Again, the decryption routine is very simple - just a XOR with 0x3D.
The next part of the code implements the technique called “egg hunting” to find and execute the final payload. What is worth noticing here, is that the exploit doesn't contain any strings, or even hashes, that might be easlily identified as suspicious. Instead, it uses the name length to find the kernel32.dll library base, and the difference between the first and the second dword of the name to find the IsBadReadPtr API.
As we already know, the stage 4 shellcode and the malicious binary are located in the first OLE object of the RTF document. By checking subsequent memory blocks with IsBadReadPtr() function, the exploit identifies all the memory areas that the current process is able to read. Then it searches through these readable blocks for a sequence of bytes which matches the signature of the beginning of the encrypted malicious package. After the decryption routine, the exploit allocates some memory on the heap then copies the stage 4 shellcode into it, saves the pointer to the decrypted MZ, and jumps to the routine that performs the actual attempt to drop and execute the binary.
The last part of the shellcode drops the binary to %TEMP%\WINWORD.EXE and deletes the registry keys that MS Word uses to store information about the files that might need recovery. Then it uses the WMI interfaces (WMI stands for Windows Management Instrumentation) to finally execute the MZ file. Why the attackers used WMI is not clear yet. We haven't seen this technique in exploits very often.
Although the shellcode contains a long list of IIDs and CLSIDs related to other WMI interfaces, it only makes use of the IWbemLocator interface. The purpose of the rest of them is unknown. It's possible that the malware writer included this list in the shellcode just to obfuscate it, or maybe they are used at some point by the malicious binary.
Summary
This particular exploit sample doesn't really invent anything new and the techniques it uses are either old or very simple. However, this amount of obfuscation and anti-heuristic tricks is somewhat impressive in a single file:
- multilayered OLE objects
- brackets + whitespaces obfuscation
- ROP chain to bypass DEP
- FSTENV instruction to get EIP
- junk instructions
- XOR obfuscation
- egg hunting technique
- unusual hashing routine for API names
- use of WMI to execute the binary
- list of unused WMI UIDs
Malware writers made a lot of effort to avoid detection, yet it seems they focused on systems with some particular configuration and/or running some particular AV software. There was a limited amount of targets, most of them based in Ukraine. Kaspersky Security for Linux Mail Server detected several hundreds of infected messages - all of them were sent during the first day of outbreak. On the other hand, our KSN data shows, that between June 18 and July 30 there were merely 55 detections of Trojan-Ransom.Win32.Gimemo.beic, exclusively in Ukraine. Starting from July 31 we've been seeing the same (or very similar) exploit, dropping the different binary (detected as Trojan-Spy.Win32.Zbot.nxdk). We will investigate this further and keep you updated. In the meanwhile, please make sure that you have installed all available security patches. Even if in this case we are dealing with a relatively small-scale targeted attack, other CVE-2012-0158 exploits are still extremely widespread and used by cybercriminals to drop hundreds of different malicious files.
НОВОЕ НА САЙТЕ
Главная
Методы обнаружения вирусов
Классификация антивирусов
Недостатки
Новости антивирусов
Антивирус Касперского
Антивирус Dr.Web
Антивирус Nod32
Антивирус Panda
Антивирус Avira
Антивирус Avast
Антивирус AVG
Вирусные новости
Горячая лента угроз и предупреждений о вирусной опасности!
Лента уязвимостей
Новости Безопастности
Вирусный Лист
Аналитические статьи
Каталог
Спам в июле 2011 года
Обзор DDoS-атак во втором квартале 2011 года
Спам во втором квартале 2011
Развитие информационных угроз во втором квартале 2011 года
Обзор вирусной активности - июль 2011
Наборы эксплойтов в первой половине 2011 года
Спам в июне 2011 года
Обзор вирусной активности - июнь 2011
Дети онлайн: техника безопасности
TDL4 - Top Bot
Спам в мае 2011 года
Землетрясение в Японии - хронология IT-угроз
Спам в первом квартале 2011
Спам в апреле 2011 года
Развитие информационных угроз в первом квартале 2011 года
Спам в марте 2011 года
«Рекламный» ботнет
Обзор вирусной активности - март 2011
Спам и закон: осеннее противостояние
Мобильная вирусология, часть 4
Планета, захваченная спамерами
MYBIOS. Возможно ли заразить BIOS?
Спам в августе 2011 года
Обзор вирусной активности - август 2011
ZeuS-in-the-Mobile - факты и догадки
Обзор вирусной активности - сентябрь 2011
Спам в сентябре 2011 года
Спам в третьем квартале 2011
Обзор вирусной активности - октябрь 2011
Развитие информационных угроз в третьем квартале 2011 года
Спам в октябре 2011 года
Головы Гидры. Вредоносное ПО для сетевых устройств
Легальные буткиты
Онлайн-платежи - удобно и безопасно
Обзор вирусной активности - ноябрь 2011
Троянцы-вымогатели
Спам в ноябре 2011 года
Stuxnet/Duqu: эволюция драйверов
Спам в декабре 2011 года
Поздравляем, вы выиграли! или Что скрывается за лотереями в интернете
Kaspersky Security Bulletin 2011. Развитие угроз в 2011 году
Kaspersky Security Bulletin. Основная статистика за 2011 год
Kaspersky Security Bulletin. Спам в 2011 году
Спам в январе 2012 года
DDoS-атаки второго полугодия 2011 года
Мобильная вирусология, часть 5
Обзор вирусной активности - февраль 2012
Спам в феврале 2012 года
Спам в марте 2012 года
Обзор вирусной активности, март 2012
Анатомия Flashfake. Часть I
Спам в первом квартале 2012
Спам в апреле 2012 года
Развитие информационных угроз в первом квартале 2012 года
Обзор вирусной активности - апрель 2012
Анатомия Flashfake. Часть II
Спам в мае 2012 года
XPAJ. Исследование буткита под Windows x64
Спам в июне 2012 года
Развитие информационных угроз во втором квартале 2012 года
Спам в июле 2012 года
Спам во втором квартале 2012
География киберпреступлений. Западная Европа и Северная Америка
Спам в августе 2012 года
«Этот сайт может причинить вред вашему компьютеру». Как распознать и предотвратить заражение веб-сайтов
Спам в сентябре 2012 года
Безопасность ключевых систем информационной инфраструктуры: точка доверия
Развитие информационных угроз в третьем квартале 2012 года
Спам в третьем квартале 2012
Спам в октябре 2012
Kaspersky Security Bulletin 2012. Кибероружие
Kaspersky Security Bulletin 2012. Основная статистика за 2012 год
Kaspersky Security Bulletin 2012. Развитие угроз в 2012 году
Спам в ноябре 2012
Информационная безопасность в 2030 году: прежними останутся только люди
Спам в 2012 году
Спам в декабре 2012
Нигерийское наследство ждет вас
Отчет «Лаборатории Касперского»: оценка уровня опасности уязвимостей в ПО
«Операция Абабиль»: итоги
«Медовые ловушки» в интернете
Контроль запуска программ как залог безопасности сети. Часть 1
Контроль запуска программ как залог безопасности сети. Часть 2
Спам в январе 2013
Мобильная вирусология, часть 6
Спам в феврале 2013
Winnti. Это вам не игрушки
Анализ Winnti 1.0
Спам в марте 2013
Spyware. HackingTeam
Спам в первом квартале 2013
Развитие информационных угроз в первом квартале 2013 года
Спам в апреле 2013
Спам в мае 2013
Перенаправления в спаме
Спам в июне 2013
Спам во втором квартале 2013
Развитие информационных угроз во втором квартале 2013 года
Anti-decompiling techniques in malicious Java Applets
The curious case of a CVE-2012-0158 exploit
Spam in Q2 2013
Spam in June 2013
Redirects in Spam
Spam in May 2013
Spam in April 2013
IT Threat Evolution: Q1 2013
Spam in Q1 2013
Spyware. HackingTeam
Spam in March 2013
Spam in February 2013
Mobile Malware Evolution: Part 6
Spam in January 2013
Application Control: the key to a secure network. Part 1
Application Control: the key to a secure network - Part 2
Honey traps on the Internet
Kaspersky Lab report: Evaluating the threat level of software vulnerabilities
Spam in December 2012
Kaspersky Security Bulletin: Spam Evolution 2012
Спам в июле 2013
Как закрыть черную дыру?
DDoS-атаки первого полугодия 2013 года
Операция «Kimsuky»: северокорейская разведдеятельность?
Защита от виртуальных грабителей
Спам в августе 2013
PAC - файл автоконфигурации проблем
Проигрыш обеспечен, или настоящее лицо фальшивой Фортуны
Спам в первом квартале 2014
Спам в марте 2014
Развитие информационных угроз в первом квартале 2014 года
Финансовые киберугрозы в 2013 году. Часть 2: вредоносное ПО
Финансовые киберугрозы в 2013 году. Часть 1: фишинг
BitGuard: система принудительного поиска
Спам в феврале 2014
Мобильные угрозы - 2013
Спам в январе 2014
Угроза из BIOS
Спам-кредиторы: кража данных, троянцы и другие особенности «дешевых» займов
Kaspersky Security Bulletin. Спам в 2013 году
Спам в декабре 2013
Спам в ноябре 2013
Kaspersky Security Bulletin 2013. Развитие угроз в 2013 году
Kaspersky Security Bulletin 2013. Корпоративные угрозы
Kaspersky Security Bulletin 2013. Основная статистика за 2013 год
Kaspersky Security Bulletin 2013. Прогнозы
Новая угроза для онлайн-банка
Спам в апреле 2014
Дети в Сети: формула безопасности
Обманщики в социальных сетях
Многофункциональный DDoS-троянец под Linux
Спам в мае 2014