{"id":7077,"date":"2017-03-22T10:41:06","date_gmt":"2017-03-22T18:41:06","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/03\/22\/news-868\/"},"modified":"2017-03-22T10:41:06","modified_gmt":"2017-03-22T18:41:06","slug":"news-868","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2017\/03\/22\/news-868\/","title":{"rendered":"Microsoft Word File Spreads Malware Targeting Both Apple Mac OS X and Microsoft Windows"},"content":{"rendered":"<p><strong>Credit to Author: Xiaopeng Zhang &amp; Chris Navarrete| Date: Wed, 22 Mar 2017 10:43:43 -0700<\/strong><\/p>\n<div class=\"entry\">\n<p>On March 16, FortiGuard Labs captured a new Word file that spreads malware by executing malicious VBA (Visual Basic for Applications) code. The sample targeted both Apple Mac OS X and Microsoft Windows systems. We then analyzed the sample, and in this blog we are going to explain how it works, step by step.<\/p>\n<p>When the Word file is opened, it shows notifies victims to enable the Macro security option, which allows the malicious VBA code to be executed.<\/p>\n<h2>Malicious Word File is Opened<\/h2>\n<p align=\"center\"><img decoding=\"async\" alt=\"Figure 1. Asks victim to enable Macro security option\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev(1).jpeg\" style=\"width: 576px; height: 305px;\" \/><\/p>\n<p align=\"center\">Figure 1. Asks victim to enable Macro security option<\/p>\n<p>Once the&nbsp;malicious VBA code is executed, the AutoOpen() function is automatically called. The first thing it does is read the data from the &ldquo;Comments&rdquo; property of the Word file.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"Figure 2. The property \u201cComment\u201d of the Word file\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev%20(1).jpeg\" style=\"width: 474px; height: 278px;\" \/><\/p>\n<p align=\"center\">Figure 2. The property &ldquo;Comment&rdquo; of the Word file<\/p>\n<p>The value of the &ldquo;Comments&rdquo; is base64 encoded, which can be read out and decoded by the VBA code below:<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/wordcode1.jpeg\" \/><\/p>\n<p>After it&rsquo;s base64-decoded, we can capture the code in plaintext, which is python script, as shown below.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/wordcode2.jpeg\" style=\"width: 1140px; height: 126px;\" \/>Next, it takes a different&nbsp;route depending on the OS type, Apple Mac OS X or Microsoft Windows, that it is running on. You can see this in the the flow chart in Figure 3.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"Figure 3. Calling different route according to OS type\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev%20(2).jpeg\" style=\"width: 581px; height: 368px;\" \/><\/p>\n<p align=\"center\">Figure 3. Calling different route according to OS type<\/p>\n<p>We have found that this malicious VBA code uses slightly modified code taken from a metasploit framework which you can find at&nbsp;hxxps:\/\/github.com\/rapid7\/metasploit-framework\/blob\/master\/external\/source\/exploits\/office_word_macro\/macro.vba<\/p>\n<h2>How it Works for Apple Mac OS X<\/h2>\n<p>As you probably know, Mac OS X comes with Python pre-installed by Apple. This allows it to execute python scripts by default. As you can see above, the base64-decoded python script is passed to&nbsp;the ExecuteForOSX function that is going to execute it at the bottom of the function (see Figure 3).&nbsp;<\/p>\n<p>The python script is easy to understand. It extracts the code from a base64-encoded string, and then executes it.&nbsp; It is decoded below, and as you can see, it is a very&nbsp;clear python script.<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/wordcode3.jpeg\" style=\"width: 937px; height: 261px;\" \/><\/p>\n<p>When the python script is executed, it downloads a file from &ldquo;hxxps:\/\/sushi.vvlxpress.com:443\/HA1QE&rdquo;, and executes it.&nbsp; The downloaded python script is a&nbsp;<a name=\"OLE_LINK16\"><\/a>slightly modified version of the Python meterpreter file, which is also part of the Metasploit framework. The source code of the project can be downloaded from the following URL:&nbsp;hxxps:\/\/github.com\/rapid7\/metasploit-payloads\/blob\/master\/python\/meterpreter\/meterpreter.py.<\/p>\n<p>The major changes between the downloaded file (HA1QE) and the original file are the following:<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"Figure 4. Differences between HA1QE and meterpreter.py\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev%20(3).jpeg\" style=\"width: 576px; height: 104px;\" \/><\/p>\n<p align=\"center\">Figure 4. Differences between HA1QE and meterpreter.py<\/p>\n<p>The HTTP_CONNECTION_URL constant (hxxps:\/\/sushi.vvlxpress.com:443\/TtxCTzF1Q2gqND8gcvg-cwGEk5tPhorXkzS0gXv9-zFqsvVHxi-1804lm2zGUE31cs\/) is set to the Metasploit end-point that the script will be connecting to.<\/p>\n<p>The PAYLOAD_UUID constant is used as an identifier for the client, which we believe is also being used by the attackers for campaign-tracking purposes.<\/p>\n<p>Once the script is executed, it attempts to connect to the host &ldquo;sushi.vvlxpress.com&rdquo; on port 443. But at the time the request was made during our analysis, the listener (server) was not answering client requests.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"Figure 5. Wireshark showing TCP retransmission error while connecting to the server\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev%20(4).jpeg\" style=\"width: 576px; height: 169px;\" \/><\/p>\n<p align=\"center\">Figure 5. Wireshark showing TCP retransmission error while connecting to the server<\/p>\n<p>The python process remains active on the system while trying to connect to a reachable server.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"Figure 6. Python script attempting connection to listener\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev%20(5).jpeg\" style=\"width: 576px; height: 76px;\" \/><\/p>\n<p align=\"center\">Figure 6. Python script attempting connection to listener<\/p>\n<h2>How it Works for Microsoft Windows<\/h2>\n<p>Although the argument of the ExecuteForWindows function is as same as the ExecuteForOSX function, it does not use it. What it does instead is making a DOS-style command string starting with cmd.exe. When it is executed, powershell.exe is started without window&nbsp;(-w hidden),&nbsp;and it executes the base64-encoded code (-e base64-encoded code.) For more details, see the following screenshot.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"Figure 7. Dos-style command\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev%20(6).jpeg\" style=\"width: 576px; height: 317px;\" \/><\/p>\n<p align=\"center\">Figure 7. Dos-style command<\/p>\n<p>It&rsquo;s base64 again. This malware&rsquo;s author likes using base64 to encode the sensitive code. We will see more base64 encoded data in the rest of the analysis.<\/p>\n<p>Decoding the base64-encoded data, we get the following powershell script:<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/wordcode4.jpeg\" style=\"width: 653px; height: 722px;\" \/><\/p>\n<p>The main job of the above powershell script is to decompress a piece of gzip data, which is in base64-encoded code, to get another powershell script (<i>by calling FromBase64String() and GzipStream()<\/i>) and execute it (<i>by calling Start($s)<\/i>).<\/p>\n<p>Next, let&rsquo;s move on to see the decompressed powershell code. To improve understanding, I modified some of the function and variable names.<\/p>\n<p>Here is the code snippet:<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/wordcode5.jpeg\" style=\"width: 651px; height: 278px;\" \/><\/p>\n<p>From the above powershell code we can see that it first decodes the base64-encoded data. In fact, it is&nbsp;64-bit binary code that is going to be executed later. Then, it allocates a buffer in the current process (powershell.exe) and copies the 64-bit code into the buffer by calling the VirtualAlloc and Copy functions. Finally, it calls the CreateThread function, whose thread function points to the new buffer. That means that the 64 bit code is the thread function and is executed. Based on our analysis, this malware only affects 64-bit Windows.<\/p>\n<p align=\"center\"><img decoding=\"async\" alt=\"Figure 8. 64-bit ASM code\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev%20(7).jpeg\" style=\"width: 576px; height: 279px;\" \/><\/p>\n<p align=\"center\">Figure 8. 64-bit ASM code<\/p>\n<p>We analyzed the 64-bit code in IDA Pro, as shown in the above screenshot. Once it starts, it downloads a file from &ldquo;hxxps:\/\/pizza.vvlxpress.com:443\/kH-G5&rdquo; into a newly allocated buffer. The downloaded file is actually a 64-bit DLL file. Before the thread function finishes, its stack return address is set to the newly allocated buffer that holds the downloaded 64-bit DLL. That means that the 64-bit DLL gets executed when the thread function is returned.<\/p>\n<p>Next, we see that the DLL can communicate with its server, such as &ldquo;hxxps:\/\/ pizza.vvlxpress.com:443\/5MTb8oL0ZTfWeNd6jrRhOA1uf-yhSGVG-wS4aJuLawN7dWsXayutfdgjFmFG9zbExdluaHaLvLjjeB02jkts1pq2bR\/&rdquo;. We can see it in the debugger, as shown below.<\/p>\n<p align=\"center          \"><img decoding=\"async\" alt=\"Figure 9. Communication with its server\" src=\"https:\/\/d3gpjj9d20n0p3.cloudfront.net\/ngblog\/uploads\/files\/ev%20(8).jpeg\" style=\"width: 576px; height: 226px;\" \/><\/p>\n<p align=\"center          \">Figure 9. Communication with its server<\/p>\n<p>At this point, we are still working on analyzing the downloaded DLL and trying to gather more information from it. We&rsquo;ll share more details about this malware later as we uncover more interesting details.<\/p>\n<h2>Mitigation<\/h2>\n<p>The original Word sample file has been detected as &ldquo;WM\/Agent.7F67!tr&rdquo; by FortiGuard AntiVirus service.<\/p>\n<h2>IoCs<\/h2>\n<p>URL:<\/p>\n<p>hxxps:\/\/sushi.vvlxpress.com:443\/HA1QE<\/p>\n<p>hxxps:\/\/pizza.vvlxpress.com:443\/kH-G5<\/p>\n<p>hxxps:\/\/pizza.vvlxpress.com:443\/5MTb8oL0ZTfWeNd6jrRhOA1uf-yhSGVG-wS4aJuLawN7dWsXayutfdgjFmFG9zbExdluaHaLvLjjeB02jkts1pq2bR\/<\/p>\n<p>hxxps:\/\/sushi.vvlxpress.com:443\/TtxCTzF1Q2gqND8gcvg-cwGEk5tPhorXkzS0gXv9-zFqsvVHxi-1804lm2zGUE31cs\/<\/p>\n<p>&nbsp;<\/p>\n<p>Sample SHA256:<\/p>\n<p>Sample.doc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 06A134A63CCAE0F5654C15601D818EF44FBA578D0FDF325CADFA9B089CF48A74<\/p>\n<p>HA1QE.py&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3A0924D55FB3BF3C5F40ADCE0BD281D75E62D0A52D8ADFA05F2084BA37D212C8<\/p>\n<p>kH-G5.dll&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C36021A2D80077C2118628ED6DB330FEF57D76810FF447EF80D2AB35B95099BC<\/p>\n<p>&nbsp;<\/p>\n<p><em><a href=\"http:\/\/demand.fortinet.com\/FortiGuard?elq_source=socialmedia&amp;utm_source=TWITTER&amp;utm_id=70186&amp;linkId=33611369\">Sign up<\/a>&nbsp;for weekly Fortinet FortiGuard Labs Threat Intelligence Briefs and stay on top of the newest emerging threats.<\/em><\/p>\n<p>&nbsp;<\/p>\n<\/div<br \/><a href=\"http:\/\/blog.fortinet.com\/2017\/03\/22\/microsoft-word-file-spreads-malware-targeting-both-apple-mac-os-x-and-microsoft-windows\" 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\/ev(1).jpeg\"\/><\/p>\n<p><strong>Credit to Author: Xiaopeng Zhang &amp; Chris Navarrete| Date: Wed, 22 Mar 2017 10:43:43 -0700<\/strong><\/p>\n<p>On March 16, FortiGuard Labs captured a new Word file that spreads malware by executing malicious VBA (Visual Basic for Applications) code. The sample targeted both Apple Mac OS X and Microsoft Windows systems. We then analyzed the sample, and in this blog we are going to explain how it works, step by step.    When the Word file is opened, it shows notifies victims to enable the Macro security option, which allows the malicious VBA code to be executed.    Malicious Word File is Opened        Figure 1. Asks victim to enable Macro security option    Once&#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-7077","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\/7077","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=7077"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/7077\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=7077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=7077"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=7077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}