{"id":5828,"date":"2017-01-18T22:26:34","date_gmt":"2017-01-18T22:26:34","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/01\/18\/news-43\/"},"modified":"2017-01-18T22:26:34","modified_gmt":"2017-01-18T22:26:34","slug":"news-43","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2017\/01\/18\/news-43\/","title":{"rendered":"Malicious Macro Bypasses UAC to Elevate Privilege for Fareit Malware"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/header.png\"\/><\/p>\n<div class=\"entry\">\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/header.png\" style=\"width: 714px; height: 393px;\" \/><\/p>\n<p>To survive, Macro downloaders have to constantly develop new techniques for evading sandbox environments and anti-virus applications. Recently, Fortinet spotted a malicious document macro designed to bypass Microsoft Windows&rsquo; UAC security and execute <a href=\"https:\/\/blog.fortinet.com\/2016\/05\/06\/new-fareit-variant-analysis\">Fareit<\/a>, an information stealing malware, with high system privilege.<\/p>\n<h3>SPAM<\/h3>\n<p>This malicious document is distributed by a SPAM email.&nbsp; As part of its social engineering strategy, it is presented in the context of someone being interested in a product.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/fig1.png\" style=\"width: 575px; height: 361px;\" \/><\/p>\n<p align=\"center\"><em>Fig.1 SPAM with the malicious document<\/em><\/p>\n<p>As usual, when the document is opened the targeted victim is instructed to enable Microsoft Word&rsquo;s macro execution. In doing so, the malicious macro executes in the background.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/fig2.png\" style=\"width: 895px; height: 328px;\" \/><\/p>\n<p align=\"center\"><em>Fig.2 Malicious document instructs user to allow macro<\/em><\/p>\n<p>The macro uses simple obfuscation by inserting garbage characters into real strings.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/fig3.png\" style=\"width: 606px; height: 194px;\" \/><\/p>\n<p align=\"center\"><em>Fig.3 Function to remove the garbage characters<\/em><\/p>\n<p>Here is an example:<\/p>\n<blockquote>\n<p align=\"center\"><em>AR<\/em><span style=\"color:#FF0000;\"><strong><em>c<\/em><\/strong><\/span><em>A<\/em><span style=\"color:#FF0000;\"><strong><em>m<\/em><\/strong><\/span><em>4Y<\/em><span style=\"color:#FF0000;\"><strong><em>d<\/em><\/strong><\/span><em>AJ<\/em><span style=\"color:#FF0000;\"><strong><em>.<\/em><\/strong><\/span><em>JZ<\/em><span style=\"color:#FF0000;\"><strong><em>e<\/em><\/strong><\/span><em>4<\/em><span style=\"color:#FF0000;\"><strong><em>x<\/em><\/strong><\/span><em>R<\/em><span style=\"color:#FF0000;\"><strong><em>e<\/em><\/strong><\/span><em>J R<\/em><span style=\"color:#FF0000;\"><strong><em>\/<\/em><\/strong><\/span><em>R<\/em><span style=\"color:#FF0000;\"><strong><em>c<\/em><\/strong><\/span><em>JY 6A<\/em><span style=\"color:#FF0000;\"><strong><em>p<\/em><\/strong><\/span><em>64<\/em><span style=\"color:#FF0000;\"><strong><em>o<\/em><\/strong><\/span><em>A6<\/em><span style=\"color:#FF0000;\"><strong><em>w<\/em><\/strong><\/span><em>Y<\/em><span style=\"color:#FF0000;\"><strong><em>e<\/em><\/strong><\/span><em>A<\/em><em>J<\/em><span style=\"color:#FF0000;\"><strong><em>r<\/em><\/strong><\/span><em>ZZ<\/em><span style=\"color:#FF0000;\"><strong><em>s<\/em><\/strong><\/span><em>YJ<\/em><span style=\"color:#FF0000;\"><strong><em>h<\/em><\/strong><\/span><em>AA<\/em><span style=\"color:#FF0000;\"><strong><em>e<\/em><\/strong><\/span><em>4<\/em><span style=\"color:#FF0000;\"><strong><em>l<\/em><\/strong><\/span><em>R<\/em><strong><em><span style=\"color:#FF0000;\">l<\/span> <\/em><\/strong><em>&hellip;<\/em><\/p>\n<\/blockquote>\n<p>Below is the full shell command executed by the macro:<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/powscript.png\" style=\"width: 789px; height: 113px;\" \/><\/p>\n<p>It&rsquo;s common behaviour for a malicious document macro to download and execute malware. However, what&rsquo;s interesting with this attack is that it executes the Fareit malware (sick.exe) with &ldquo;High&rdquo; privilege. In a default UAC setting, it should not be possible to do this without the UAC permission prompt popping up. Bypassing that setting has everything to do with the executed Windows native application, eventvwr.exe.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/fig4.png\" style=\"width: 652px; height: 76px;\" \/><\/p>\n<p align=\"center\"><em>Fig.4 Macro executes Event Viewer and Fareit (sick.exe)<\/em><\/p>\n<h3>UAC Bypass and Privilege Escalation<\/h3>\n<p>An application running with high privilege in the system means access to more resources that would otherwise be inaccessible if running with lower privilege. In terms of malware, this means more data that can be stolen and more changes that can be done to the system.<\/p>\n<p>UAC is a security feature that prevents an application from executing with higher privileges without the user&rsquo;s permission. It is also a very convenient feature that allows users to perform non-administrator and administrator tasks without switching users.<\/p>\n<p>To understand the shell command, let&rsquo;s divide it into four sections.<\/p>\n<p>The first section simply downloads the Fareit malware and drops it as <em>%TEMP%sick.exe<\/em>.<\/p>\n<p><em>Command:<\/em><\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/powscript1.png\" style=\"width: 771px; height: 51px;\" \/><\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/fig5.png\" style=\"width: 422px; height: 125px;\" \/><\/p>\n<p align=\"center\"><em>Fig.5 Network log of the malware download<\/em><\/p>\n<p>The second section is where it starts to get really interesting. The malware adds the following entry to the registry:<\/p>\n<p style=\"margin-left:.5in;\">Key: <em>HKCUSoftwareClassesmscfileshellopencommand<\/em><\/p>\n<p style=\"margin-left:.5in;\"><em>(default):<\/em> <em>%temp%sick.exe<\/em><\/p>\n<p><em>Command:<\/em><\/p>\n<p><em>reg add HKCUSoftwareClassesmscfileshellopencommand \/d %tmp%sick.exe \/f<\/em><\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/fig6.png\" style=\"width: 677px; height: 178px;\" \/><\/p>\n<p align=\"center\"><em>Fig. 6 Malware modifies the registry related to opening .msc files<\/em><\/p>\n<p><em>HKCUSoftwareClasses<\/em> contains registry entries that dictate the default software to be used when opening files based on file types. Adding the above malware registry means it will execute every time an <em>mscfile (.msc) <\/em>is opened. But there is a more important reason for changing this registry.<\/p>\n<p>Let&rsquo;s take a look at the third section of the command. After modifying the registry, it executes Microsoft&rsquo;s Event Viewer application, a tool used to view application and system logs for monitoring and troubleshooting.<\/p>\n<p><em>Command:<\/em><\/p>\n<p><em>C:Windowssystem32eventvwr.exe &amp; PING -n 15 127.0.0.1&gt;nul <\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Event Viewer needs to execute the Microsoft Management Console (mmc.exe) to work. MMC is a tool that serves as an interface for Windows administrative tools. But first, it needs to locate mmc.exe. The application does this by querying <em>HKCUSoftwareClassesmscfileshellopencommand<\/em> and <em>HKCRmscfileshellopencommand<\/em>, in that order. However, we now know that the malicious macro has already added the path of the downloaded Fareit malware to the former, which means that the malware will be executed instead of MMC.<\/p>\n<p>Now, it is very important to note that Event Viewer has an <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/2009.07.uac.aspx#id0560031\">auto-elevate<\/a> parameter. This means it does not need UAC permission to execute in a high privilege. This also means that any child process, Fareit malware in this case, executed by this application will have the same high privilege.<\/p>\n<p>The main problem is that a high-privilege Windows native application (eventvwr.exe) bases its parameters or dependency on system artifacts that can be easily modified by a process with a lower privilege.<\/p>\n<p>Discovery and detailed analysis of this recent UAC bypass technique was posted by <em>enigma0x3<\/em> <a href=\"https:\/\/enigma0x3.net\/2016\/08\/15\/fileless-uac-bypass-using-eventvwr-exe-and-registry-hijacking\/\">here<\/a> only a few months ago.<\/p>\n<p>The fourth section of the command simply executes the Fareit malware again. This may just be a fail-safe mechanism in case the attempt to execute it in high privilege does not work.<\/p>\n<p>&nbsp;<\/p>\n<p><em>Command:<\/em><\/p>\n<p>%tmp%sick.exe<\/p>\n<p>&nbsp;<\/p>\n<h3>Conclusion<\/h3>\n<p>Macro malware attacks have been around for a long time, mainly because they are very effective at social engineering schemes. Over time, they have become more aggressive and creative in evading detections for themselves and their payloads, and this current example is another advance developmentthat we will surely start to see in other variants.<\/p>\n<p>It was not long ago when security researchers presented a POC of this UAC bypass. Sharing this kind of information to the public always has its pros and cons. For the security community, it can serve as a good heads-up to plan and mitigate its bad effects. However, as the good guys become aware of it, there&rsquo;s a good chance that the bad guys are aware of it too.<\/p>\n<p>In summary, then, here are a few simple security measures that can be implemented to mitigate these sorts of attacks:<\/p>\n<ul>\n<li>Disable execution of Macros, if not in use<\/li>\n<li>Change the default setting of UAC to &ldquo;Always Notify&rdquo;<\/li>\n<li>Be vigilant on opening emails and documents from unknown sources<\/li>\n<\/ul>\n<p>-= FortiGuardLion Team =-<\/p>\n<p>&nbsp;<\/p>\n<h3>Samples (SHA256)<\/h3>\n<p>2e4a232753459ee64adfa1931d1bae5f3128e70918027c230c7da93aad69889b (sick.exe) &#8211; W32\/Fareit.CIBX!tr.pws<\/p>\n<p>6dd7f947258458646153c414e0861c7257b794af5f03d37e0e9dc38e2c7126cf (scan002939110.doc) &#8211; WM\/Fareit.UAC!tr.dldr<\/p>\n<p>d503aaa145be93e23e0e2d9a19ca89c9efd9729513d30f9be11db174c8ed6a9c(scan002939110.doc) &#8211; WM\/Fareit.UAC!tr.dldr<\/p>\n<p>&nbsp;<\/p>\n<h3>IOC<\/h3>\n<p>Added Registry:<\/p>\n<p style=\"margin-left:.5in;\">Key: <em>HKCUSoftwareClassesmscfileshellopencommand<\/em><\/p>\n<p style=\"margin-left:.5in;\"><em>(default):<\/em> <em>%temp%sick.exe<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Added File:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; %temp%sick.exe<\/p>\n<p>Network Connections:<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http[:]\/\/hawkresultbox[.]net\/logs\/sick.exe<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http[:]\/\/hawkresultbox[.]net\/code\/nam\/gate.php<\/p>\n<p>http[:]\/\/hawkresultbox[.]net\/code\/nam\/shit.exe<\/p>\n<\/div<br \/><a href=\"http:\/\/blog.fortinet.com\/2016\/12\/16\/malicious-macro-bypasses-uac-to-elevate-privilege-for-fareit-malware\" target=\"bwo\" >https:\/\/blog.fortinet.com\/feed<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/header.png\"\/><br \/>To survive, Macro downloaders have to constantly develop new techniques for evading sandbox environments and anti-virus applications. Recently, Fortinet spotted a malicious document macro designed to bypass Microsoft Windows\u2019 UAC security and execute Fareit, an information stealing malware, with high system privilege.    SPAM    This malicious document is distributed by a SPAM email.\u00a0 As part of its social engineering strategy, it is presented in the context of someone being interested in a product.        Fig.1 SPAM with the malicious&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[10424,10378],"tags":[],"class_list":["post-5828","post","type-post","status-publish","format-standard","hentry","category-fortinet","category-security"],"_links":{"self":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/5828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/comments?post=5828"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/5828\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=5828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=5828"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=5828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}