{"id":6907,"date":"2017-03-08T23:01:16","date_gmt":"2017-03-09T07:01:16","guid":{"rendered":"http:\/\/www.palada.net\/index.php\/2017\/03\/08\/news-698\/"},"modified":"2017-03-08T23:01:16","modified_gmt":"2017-03-09T07:01:16","slug":"news-698","status":"publish","type":"post","link":"http:\/\/www.palada.net\/index.php\/2017\/03\/08\/news-698\/","title":{"rendered":"Uncovering cross-process injection with Windows Defender ATP"},"content":{"rendered":"<p><strong>Credit to Author: msft-mmpc| Date: Thu, 09 Mar 2017 06:16:01 +0000<\/strong><\/p>\n<p>Windows Defender Advanced Threat Protection (<a href=\"https:\/\/www.microsoft.com\/en-us\/WindowsForBusiness\/windows-atp\">Windows Defender ATP<\/a>) is a post-breach solution that alerts security operations (SecOps) personnel about hostile activity. As the nature of attacks evolve, Windows Defender ATP must\u00a0advance so that it continues to help SecOps personnel uncover and address the attacks.<\/p>\n<p>With\u00a0increasing security investments from Microsoft<span style=\"margin: 0px;line-height: 107%;font-family: 'Calibri',sans-serif;font-size: 11pt\"><span style=\"color: #000000\">\u2014<\/span><\/span>read how <a href=\"https:\/\/blogs.technet.microsoft.com\/mmpc\/2017\/01\/13\/hardening-windows-10-with-zero-day-exploit-mitigations\/\">Windows 10 continues to raise the bar<\/a> against a spectrum of attacks<span style=\"margin: 0px;line-height: 107%;font-family: 'Calibri',sans-serif;font-size: 11pt\"><span style=\"color: #000000\">\u2014<\/span><\/span>and other vendors, the cost and complexity of delivering successful exploits has swelled. For example, the trend towards virtualization-based security is forcing attacks to\u00a0incorporate at least two exploits: one to compromise the sandboxed application and another to break out of the sandbox.\u00a0We are now seeing\u00a0exploit developers charge as high as hundreds of thousands of dollars for remote code execution and kernel exploits, pricing out some attackers\u00a0from the market.<\/p>\n<p>Unfortunately, advanced and apex attackers (see Figure 1) can still afford to\u00a0develop or\u00a0purchase zero-day exploits. To protect their investments, these attackers put more emphasis in\u00a0evading detection.\u00a0They rely heavily on in-memory attacks and kernel privilege escalation to avoid touching the disk and remain extremely stealthy.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"450\" class=\"alignnone wp-image-11465\" alt=\"Attacker proficiency and associated techniques\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/1-Attacker-proficiency-and-associated-techniques.png\" \/><\/p>\n<p><em>Figure <\/em><em>1<\/em><em>. Attacker proficiency and associated techniques<\/em><\/p>\n<p>This blog post kicks off a three-part series showcasing the investments made by Microsoft to enhance instrumentation and detection of in-memory techniques. The series covers detection improvements for cross-process code injection, kernel escalation and tampering, and in-memory exploitation. In this first post, we focus on cross-process injection and illustrate how enhancements that will be available in the <a href=\"https:\/\/blogs.windows.com\/business\/2016\/12\/06\/windows-10-creators-update-advances-security-best-class-modern-tools\">Creators Update for Windows Defender ATP<\/a> detect a broad set of attack activity: from commodity malware that attempt to hide from plain view to sophisticated activity groups that engage in targeted attacks.<\/p>\n<h2>Cross-process injection for stealth and persistence<\/h2>\n<p>Cross-process injection can be used to provide an attacker more visibility into normal processes. For example, injected code can record keystrokes sent to an affected process. At the same time,\u00a0this method\u00a0hides malicious code and enables process migration, which can be used for organizational persistence.<\/p>\n<p>Cross-process injection is inherently stealthy because it conceals malicious code inside benign processes. Even when a process has been injected with malicious code, its loaded images (the executable and library files associated with the process) continue to point to legitimate files on disk as shown in Figure 2. This shows a clear advantage over running malicious code in its own process space, which necessitates that the code reside on disk as an image file that is subject to inspection by antimalware and is easily recovered as forensic evidence.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"471\" height=\"115\" class=\"alignnone size-full wp-image-11475\" alt=\"Loaded images of rundll32.exe appear normal even when injected with malware code\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/2-loaded-images-of-rundll.32.exe_.png\" \/><\/p>\n<p><em>Figure <\/em><em>2<\/em><em>. Loaded images of rundll32.exe appear normal even when injected with malware code<\/em><\/p>\n<p>By enabling process migration, cross-process injection allows attacks to stay active. In a drive-by-download attack, for instance, an attacker can gain control of the browser process and disable its sandbox. To execute malicious code beyond the lifecycle of the browser, which may terminate at any time, the attacker migrates the malicious code to a long-lived process, such as winlogon.exe, using cross-process injection. The risk of a user powering down the machine and erasing the malware remains, but an apex attacker overcomes this by staying active on multiple devices on the enterprise network. If one device is indeed restarted and the malicious code erased, the attacker can easily move laterally back to that device.<\/p>\n<h2>Digging deeper into cross-process injection<\/h2>\n<p>Cross-process injection is basically a two-fold process.<\/p>\n<p>First, malicious code is placed into a new or existing executable page within a remote process. Attackers typically use the Win32 APIs <em>VirtualAllocEx<\/em> and <em>CreateFileMapping\/MapViewOfSection<\/em> to allocate new executable pages. They then use <em>VirtualProtectEx<\/em> to turn existing pages into executable and writeable pages.<\/p>\n<p>Next, the injected malicious code is executed through control of the thread and execution context. In many notable cases, attackers use the API <em>CreateRemoteThread<\/em> to create a new thread in a remote process. They then use APIs <em>SetThreadContext<\/em> and <em>QueueUserAPC<\/em> to redirect the existing thread to an arbitrary address.<\/p>\n<p>While there are legitimate uses for the aforementioned APIs\u2014they are used for debugging, diagnostics, management, and security\u2014particular combinations of process names and execution behaviors often indicate malicious activity. For the technically inclined, techniques such as process hollowing (described\u00a0by Tan Chew Keong in his paper &#8220;Dynamic Forking of Win32 EXE&#8221;)\u00a0\u00a0and more obscure theoretical attacks such as <a href=\"https:\/\/breakingmalware.com\/injection-techniques\/atombombing-brand-new-code-injection-for-windows\/\">AtomBombing<\/a> are good examples of these malicious combinations.<\/p>\n<h2>Instrumentation and detection in Windows Defender ATP<\/h2>\n<p>In Creators Update for Windows Defender ATP, we have instrumented related function calls and built statistical models to detect a broad range of malicious injection techniques used in the wild. To\u00a0determine how these enhancements effectively uncover hostile activities that leverage cross-process injection, we tested the enhancements against the following real-world cases: a targeted attack, a remote access tool (RAT), and cryptocurrency mining malware.<\/p>\n<h3>Targeted attack by GOLD<\/h3>\n<p>GOLD is an activity group that primarily seeks out intellectual property and other valuable digital assets. This activity group has an interesting way of obtaining a foothold in enterprise networks. Instead of actively pursuing targets through spear-phishing, GOLD uses established distribution sites for license-key generators (keygens) to infect a wide array of victims\u2014all users who download and execute keygens from the distribution sites. The group then assesses each of the victims and aggressively pursues those in certain industries.<\/p>\n<p>As a user launches a keygen package downloaded from the website operated by GOLD, the package drops two executables: the actual keygen and the <a href=\"https:\/\/www.microsoft.com\/security\/portal\/threat\/encyclopedia\/entry.aspx?Name=Trojan%3aWin32%2fGatak\">Gatak<\/a> malware implant. Gatak proceeds to inject itself into one of the many legitimate system processes using the <em>CreateRemoteThread<\/em> API. The sample we tested launches the <em>rundll32.exe<\/em> process, allocates memory in the process, writes malicious code to that location, and executes the malicious code\u00a0using <em>CreateRemoteThread<\/em> calls. Upon successful injection, Gatak removes itself from disk. Meanwhile, code injected in the <em>rundll32.exe<\/em> process communicates with command-and-control (C&amp;C) servers, giving GOLD attackers control over the infected device.<\/p>\n<p>With Creators Update, Windows Defender ATP will uncover breaches involving Gatak by detecting its cross-process injection technique, among other detection mechanisms it can use. Figure 3 shows the alert on the Windows Defender ATP Creators Update portal.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"353\" class=\"alignnone wp-image-11545\" alt=\"Detection of Gatak malware implant injecting into rundll32.exe\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/3-Detection-of-Gatak-malware-implant-injecting-into-rundll32.exe_.png\" \/><\/p>\n<p><em>Figure <\/em><em>3<\/em><em>. Detection of Gatak malware implant injecting into rundll32.exe<\/em><\/p>\n<h3>Fynloski RAT<\/h3>\n<p>The second piece of malicious activity we used to test our new detections for cross-process injection is a variant of the <a href=\"https:\/\/www.microsoft.com\/security\/portal\/threat\/encyclopedia\/Entry.aspx?Name=Backdoor:Win32\/Fynloski.A\">Fynloski<\/a> remote access tool (RAT). This RAT was freely available until 2012 and is still in use today in multiple attack campaigns. It provides a broad set of functionality, including capturing screenshots, exfiltrating files, and recording keystrokes. It is distributed by different vectors, including spear-phishing, downloaders, and exploit kits.<\/p>\n<p>Instead of using the more common <em>CreateRemoteThread<\/em> cross-process injection technique described in preceding sections, Fynloski leverages the <em>QueueUserAPC<\/em> API to hide its presence. <em>QueueUserAPC <\/em>is a function for requesting the execution of procedures asynchronously. Attackers can use <em>QueueUserAPC<\/em> to inject arbitrary code cross-process by provisioning malicious code in the target process and pointing <em>QueueUserAPC<\/em> to execute this code.<\/p>\n<p>With Creators Updates, Windows Defender ATP will detect these API calls and display an alert with a corresponding timeline that outlines this behavior as shown in Figure 4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"500\" height=\"63\" class=\"alignnone wp-image-11495\" alt=\"Fynloski RAT injecting into notepad.exe\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/4-Fynloski-RAT-injecting-into-notepad.exe_.png\" \/><\/p>\n<p><em>Figure <\/em><em>4<\/em><em>. Fynloski RAT injecting into notepad.exe<\/em><\/p>\n<h3>Commodity malware for cryptocurrency mining<\/h3>\n<p>Commodity malware uses cross-process injection techniques for the same reason attackers use them in targeted attacks\u2014they want to remain hidden long enough to accomplish their objectives.<\/p>\n<p>In this article, we dissect the <a href=\"https:\/\/www.microsoft.com\/security\/portal\/threat\/encyclopedia\/entry.aspx?Name=Trojan%3aWin32%2fCoinMiner\">CoinMiner<\/a> malware, which steals computing resources to mine cryptographic currencies such as Bitcoins. It uses <em>SetThreadContext<\/em> API for cross-process injection, copying malicious code into allocated executable memory similar to the <em>CreateRemoteThread <\/em>technique. To execute the malicious code, it first obtains a list of existing threads from the target process using <em>CreateToolhelp32Snapshot<\/em> API. It then modifies the control registers of a thread to point to the memory address of the injected malicious code using the <em>SetThreadContext<\/em> API.<\/p>\n<p>Our sample of CoinMiner launches <em>notepad.exe<\/em> and injects its mining code into that process. Subsequently, the affected <em>notepad.exe<\/em> process connects to the Monero Mining Pool (xmr[.]crypto-pool[.]fr) to submit mined cryptocurrency. Windows Defender ATP, as shown in Figure 5, will detect the injection technique and provide important context, such as the connection to the mining pool, to help SecOps personnel understand and address the infection.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"446\" class=\"alignnone wp-image-11505\" alt=\"Event timeline view of CoinMiner infection\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/03\/5-Event-timeline-view-of-CoinMiner-infection.png\" \/><\/p>\n<p><em>Figure <\/em><em>5<\/em><em>.<\/em><em> Event timeline view of CoinMiner infection<\/em><\/p>\n<h2>Conclusion: Creators Update is ready for a mix of cross-process injection methods<\/h2>\n<p>Like other in-memory techniques, cross-process injection\u00a0can evade antimalware and other security\u00a0solutions that focus on inspecting files on disk. With Creators Update, Windows Defender ATP will provide\u00a0SecOps personnel with additional capabilities to uncover malicious activities leveraging cross-process injection.\u00a0By leveraging statistical models and\u00a0analyzing large data sets\u00a0in the cloud, these enhancements cover code injection techniques used in a variety of attacks, including commodity malware infections and sophisticated breaches.<\/p>\n<p>Windows Defender ATP also provides detailed event timelines as well as other contextual information that SecOps personnel can use to\u00a0quickly understand the nature of attacks and <a href=\"https:\/\/blogs.windows.com\/business\/2016\/12\/06\/windows-10-creators-update-advances-security-best-class-modern-tools\/\">take response actions<\/a>.<\/p>\n<p>For more information about Windows Defender ATP, check out <a href=\"https:\/\/www.microsoft.com\/en-us\/WindowsForBusiness\/Windows-ATP\">its features and capabilities<\/a> and read about why a <a href=\"http:\/\/wincom.blob.core.windows.net\/documents\/Post%20Breach%20Dealing%20with%20Advanced%20Threats%20Whitepaper.pdf\">post-breach detection approach is a key component of any enterprise security stack<\/a>. Several features planned for release with\u00a0Creators Update\u00a0are currently\u00a0available to all users as part of the <a href=\"https:\/\/technet.microsoft.com\/en-us\/itpro\/windows\/keep-secure\/preview-windows-defender-advanced-threat-protection\">public preview<\/a>.<\/p>\n<p>Windows Defender ATP is built into the core of Windows 10 Enterprise and can be <a href=\"https:\/\/www.microsoft.com\/en-us\/WindowsForBusiness\/windows-atp\">evaluated free of charge<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h4>Threat indicators<\/h4>\n<p>Hashes<\/p>\n<ul>\n<li>Gatak &#8211; 137d6fdc9ca730304a2154174058144f4e909824<\/li>\n<li>Fynloski &#8211; efb9a13ad450bb0381ee1cc3b90ac0266687928a<\/li>\n<li>CoinMiner &#8211; d36fa8de43956190d827c042614555c8b20c5402<\/li>\n<\/ul>\n<p>Infrastructure<\/p>\n<ul>\n<li>207[.]36[.]232[.]49<\/li>\n<li>212[.]129[.]44[.]157<\/li>\n<li>Xmr[.]crypto-pool[.]fr<\/li>\n<\/ul>\n<hr \/>\n<h4><\/h4>\n<h4>Christian Seifert, Genghis Karimov, Mathieu Letourneau<\/h4>\n<p><em>Windows Defender ATP Research Team<\/em><\/p>\n<p>&nbsp;<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/blogs.technet.microsoft.com\/mmpc\/2017\/03\/08\/uncovering-cross-process-injection-with-windows-defender-atp\/\" target=\"bwo\" >https:\/\/blogs.technet.microsoft.com\/mmpc\/feed\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><strong>Credit to Author: msft-mmpc| Date: Thu, 09 Mar 2017 06:16:01 +0000<\/strong><\/p>\n<p>Windows Defender Advanced Threat Protection (Windows Defender ATP) is a post-breach solution that alerts security operations (SecOps) personnel about hostile activity. As the nature of attacks evolve, Windows Defender ATP must\u00a0advance so that it continues to help SecOps personnel uncover and address the attacks. With\u00a0increasing security investments from Microsoft\u2014read how Windows 10 continues to raise&#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":[10759,10378],"tags":[10864,10760,11571,10490,11572,11137,11573,10987,11574,11575,11576,11577,11578,11579,10761,11580,10865,11581],"class_list":["post-6907","post","type-post","status-publish","format-standard","hentry","category-microsoft","category-security","tag-advanced-persistent-threats","tag-antimalware-research-for-it-pros-and-enthusiasts","tag-apts","tag-bitcoin","tag-coinminer","tag-creators-update","tag-cross-process-injection","tag-exploits","tag-fynloski-rat","tag-gatak","tag-gold-activity-group","tag-in-memory-attacks","tag-post-breach-detection","tag-public-preview","tag-windows-10","tag-windows-defender-advanced-threat-protection","tag-windows-defender-atp","tag-zero-day-exploits"],"_links":{"self":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/6907","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=6907"}],"version-history":[{"count":0,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/posts\/6907\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/media?parent=6907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/categories?post=6907"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.palada.net\/index.php\/wp-json\/wp\/v2\/tags?post=6907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}