<?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 Mayank Raj on Medium]]></title>
        <description><![CDATA[Stories by Mayank Raj on Medium]]></description>
        <link>https://medium.com/@rajmayank432?source=rss-4abae7302c46------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ynJ8enOkEynnIL0mgri59g.jpeg</url>
            <title>Stories by Mayank Raj on Medium</title>
            <link>https://medium.com/@rajmayank432?source=rss-4abae7302c46------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 09:00:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajmayank432/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[RealZa Writeup — PascalCTF 2026]]></title>
            <link>https://medium.com/@rajmayank432/realza-writeup-pascalctf-2026-41c5152f5b94?source=rss-4abae7302c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/41c5152f5b94</guid>
            <category><![CDATA[secure-coding]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[web-application-security]]></category>
            <dc:creator><![CDATA[Mayank Raj]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 19:31:01 GMT</pubDate>
            <atom:updated>2026-02-04T19:31:01.101Z</atom:updated>
            <content:encoded><![CDATA[<h3>RealZa Writeup — PascalCTF 2026</h3><h3>The Challenge</h3><p>PascalCTF had a fun web challenge called “RealZa” — basically an online shop selling different “Za” products:</p><ul><li><strong>FakeZa</strong>: $1</li><li><strong>ElectricZa</strong>: $65</li><li><strong>CartoonZa</strong>: $35</li><li><strong>RealZa</strong>: $1,000 (has the flag we need)</li></ul><p>The catch? You start with only $100 in your account. Simple math says we’re $900 short. Time to get creative.</p><h3>What I Tried (And Failed)</h3><p>Before finding the actual vulnerability, I went down a few rabbit holes that didn’t pan out:</p><p><strong>Attempt 1: Price Manipulation.</strong> My first instinct was to intercept the add-cart request and try changing the price directly. Maybe send something like:</p><pre>{&quot;product&quot;:&quot;RealZa&quot;,&quot;quantity&quot;:1,&quot;price&quot;:1}</pre><p>Nope. The server completely ignores any price field I send — it only uses the hardcoded prices object on the backend. Fair enough.</p><p><strong>Attempt 2: Negative Quantities.</strong> What if I could add negative quantities to reduce the total?</p><pre>{&quot;product&quot;:&quot;FakeZa&quot;,&quot;quantity&quot;:-999}</pre><p>The code has a check for this:</p><pre>if (quantity &lt; 1) {<br>    return res.json({ success: false });<br>}</pre><p>Blocked. Can’t go negative.</p><p><strong>Attempt 3: Race Condition</strong> I tried sending multiple checkout requests simultaneously, hoping to exploit a race condition where my balance gets checked before it’s deducted. Maybe I could buy the RealZa multiple times before the balance updates?</p><p>Didn’t work. Session management handled this properly, and even if it worked, I’d still need to afford one purchase first.</p><p><strong>Side note:</strong> This attempt taught me something cool about race conditions though.</p><p>At this point, I was stuck. Time to actually read the code more carefully…</p><h3>Finding the Vulnerability</h3><p>I started digging through the source code (Node.js/Express app) and found something interesting in how the checkout works:</p><pre>app.post(&#39;/checkout&#39;, (req, res) =&gt; {<br>    let total = 0;<br>    for (const product in cart) {<br>        total += prices[product] * cart[product];<br>    }</pre><pre>    if (total &gt; req.session.balance) {<br>        res.json({ &quot;success&quot;: true, &quot;balance&quot;: &quot;Insufficient Balance&quot; });<br>    } else {<br>        // Process the purchase<br>        req.session.balance -= total;<br>        // Add items to inventory<br>    }<br>});</pre><p>Notice anything sketchy? The code calculates the total by looking up prices[product] - but what if we add a product that <strong>doesn&#39;t exist</strong> in the price list?</p><p>Here’s the prices object:</p><pre>const prices = { <br>    &quot;FakeZa&quot;: 1, <br>    &quot;ElectricZa&quot;: 65, <br>    &quot;CartoonZa&quot;: 35, <br>    &quot;RealZa&quot;: 1000 <br>};</pre><h3>The NaN Magic</h3><p>If I add a product called “Poison” to my cart:</p><pre>total += prices[&quot;Poison&quot;] * 1;  // prices[&quot;Poison&quot;] is undefined<br>total += undefined * 1;          // This equals NaN!</pre><p>Now here’s where JavaScript gets weird:</p><pre>if (NaN &gt; 100) {  // This is FALSE!<br>    // Reject purchase<br>} else {<br>    // Purchase goes through! <br>}</pre><p>In JavaScript, <strong>any comparison with NaN always returns false</strong>. So NaN &gt; 100 is false, and the code thinks we can afford it!</p><h3>The Exploit</h3><p>Armed with this knowledge, here’s what I did:</p><p><strong>Step 1:</strong> Login (get my $100 balance)</p><p><strong>Step 2:</strong> Add a fake product to poison the cart</p><pre>POST /add-cart<br>{&quot;product&quot;:&quot;Poison&quot;,&quot;quantity&quot;:1}</pre><p><strong>Step 3:</strong> Add the expensive RealZa</p><pre>POST /add-cart<br>{&quot;product&quot;:&quot;RealZa&quot;,&quot;quantity&quot;:1}</pre><p><strong>Step 4:</strong> Checkout</p><pre>POST /checkout<br>{}</pre><p>Behind the scenes:</p><pre>total = undefined * 1 + 1000 * 1<br>total = NaN + 1000<br>total = NaN</pre><pre>if (NaN &gt; 100) {  // false! Checkout proceeds</pre><p><strong>Step 5:</strong> Check inventory and grab the flag:</p><pre>pascalCTF{1_h4t3_j4v4scr1pt_s0o0o0o0_much}</pre><p>The flag itself is perfect — JavaScript can be frustrating!</p><h3>The Fix</h3><p>So how do we prevent this? Two simple checks:</p><p><strong>Option 1: Validate products exist</strong></p><pre>app.post(&#39;/add-cart&#39;, (req, res) =&gt; {<br>    const { product, quantity = 1 } = req.body;<br>    <br>    // Don&#39;t let invalid products in!<br>    if (!prices.hasOwnProperty(product)) {<br>        return res.json({ <br>            success: false, <br>            error: &quot;Invalid product&quot; <br>        });<br>    }<br>    <br>    // Rest of the logic...<br>});</pre><p><strong>Option 2: Check if total is actually a number</strong></p><pre>app.post(&#39;/checkout&#39;, (req, res) =&gt; {<br>    let total = 0;<br>    <br>    for (const product in cart) {<br>        total += prices[product] * cart[product];<br>    }<br>    <br>    // Make sure total is a real number!<br>    if (!Number.isFinite(total)) {<br>        return res.json({ <br>            success: false, <br>            error: &quot;Invalid calculation&quot; <br>        });<br>    }<br>    <br>    if (total &gt; req.session.balance) {<br>        return res.json({ success: false });<br>    }<br>    <br>    // Process checkout...<br>});</pre><p>The lesson? <strong>Never trust user input</strong>. Just because your frontend only shows valid products doesn’t mean someone won’t send a fake one through the API.</p><h3>Key Takeaways</h3><ul><li>JavaScript’s NaN is weird — comparisons with it always return false</li><li>Business logic bugs can be just as dangerous as SQL injection</li><li>Always validate input on the backend, not just the frontend</li><li>Use Number.isFinite() to check if calculations make sense</li><li>Understanding language quirks is crucial for both building and breaking applications</li></ul><p><strong>Final thoughts:</strong> This challenge was a great reminder that security isn’t just about preventing SQL injection or XSS. Sometimes the bug is in the logic itself — and understanding your language’s quirks can make or break your exploit.</p><p>Happy hacking! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41c5152f5b94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a DDoS Detection Tool: My Journey into Network Security]]></title>
            <link>https://medium.com/@rajmayank432/building-a-ddos-detection-tool-my-journey-into-network-security-6e515e6f4628?source=rss-4abae7302c46------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e515e6f4628</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ddos-attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[pcap-analysis]]></category>
            <category><![CDATA[network-security]]></category>
            <dc:creator><![CDATA[Mayank Raj]]></dc:creator>
            <pubDate>Tue, 03 Feb 2026 07:06:06 GMT</pubDate>
            <atom:updated>2026-02-03T07:06:06.067Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>How I created a Python-based network packet analyzer to detect and visualize DDoS attacks</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*LaqY3sizVIYGLrylc6-Wow.png" /></figure><h3>Why I Built This</h3><p>A while back, I got curious about network security. Not the theoretical stuff you read in textbooks, but the real, messy world of packet captures and attack patterns. I wanted to understand: <em>How do you actually spot a DDoS attack happening in real-time?</em></p><p>Here’s the thing — books and courses teach you <em>about</em> network layers and protocols, but they don’t teach you how to actually dissect a packet, see each layer, and analyze what’s really happening. There’s a huge gap between understanding the OSI or TCP/IP model on paper and actually parsing Ethernet frames, extracting IP headers, and reading TCP data in code.</p><p>That curiosity led me to build <a href="https://github.com/Netwok-Analyzer/DDOS-Detect"><strong>DOS-Detect</strong></a> — a Python tool that analyzes network traffic, detects DDoS attacks, and even maps attackers on Google Earth. It became my crash course in network forensics, and honestly, one of the most fun projects I’ve worked on.</p><p>The idea was simple: take PCAP files (network packet captures), parse them, and look for telltale signs of a DDoS attack. But the devil, as always, was in the details.</p><h3>How It Works: The Three Detection Methods</h3><p>DDoS attacks aren’t subtle when you know what to look for. I designed the tool around three detection pillars:</p><h3>1. LOIC Downloads</h3><p>LOIC (Low Orbit Ion Cannon) is a popular DDoS tool. Attackers often download it before launching attacks. My code scans HTTP traffic for GET requests containing both “.zip” and “loic” in the URI:</p><pre>if http.method == &quot;GET&quot;:<br>    uri = http.uri.lower()<br>    if &quot;.zip&quot; in uri and &quot;loic&quot; in uri:<br>        print(&quot;[!] &quot; + src + &quot; Downloaded LOIC&quot;)</pre><p>Simple, but effective. If someone’s downloading LOIC, they’re probably up to no good.</p><h3>2. Hivemind Commands (IRC Port 6667)</h3><p>DDoS botnets often use IRC servers to coordinate attacks. The command “!lazor” is commonly used to trigger attacks. I monitor port 6667 for this specific command:</p><pre>if dport == 6667:<br>    if &quot;!lazor&quot; in tcp.data.lower().decode(&#39;utf-8&#39;):<br>        print(&quot;[!] DDoS Hivemind issued by &quot; + src)<br>        print(&quot;Target CMD: &quot; + tcp.data.decode(&quot;utf-8&quot;))</pre><p>When this fires, you know someone just gave the order to attack.</p><h3>3. Packet Flooding</h3><p>The most obvious sign: massive packet counts. I set a threshold of 10,000 packets from a single source to a destination on port 80:</p><pre>if pktsent &gt; THRES:<br>    print(&quot;[+] &quot; + src + &quot; attacked &quot; + dst + &quot; with &quot; + str(pktsent) + &quot; packets&quot;)</pre><p>If someone’s sending over 10k packets, they’re either attacking or running the world’s worst benchmark test.</p><h3>The Cool Part: Geolocation</h3><p>Detecting attacks is one thing, but <em>seeing</em> where they come from? That’s where it gets interesting.</p><p>Using the MaxMind GeoLite2 database, I geolocate every IP address in the traffic:</p><pre>def ret_geo_ip(ip):<br>    with geoip2.database.Reader(&quot;GeoLite2-City.mmdb&quot;) as geofile:<br>        rec = geofile.city(ip)<br>        city = rec.city.name<br>        country = rec.country.name<br>        return f&quot;{city}, {country}&quot; if city else country</pre><p>But I didn’t stop there. The tool generates KML files that you can open in Google Earth. Suddenly, abstract IP addresses become pinpoints on a map — you can literally see the attack traffic flowing across the globe.</p><pre>kml = (f&#39;&lt;Placemark&gt;\n&#39;<br>       f&#39;&lt;name&gt;{ip}&lt;/name&gt;\n&#39;<br>       f&#39;&lt;Point&gt;\n&#39;<br>       f&#39;&lt;coordinates&gt;{latitude},{longitude}&lt;/coordinates&gt;\n&#39;<br>       f&#39;&lt;/Point&gt;\n&#39;<br>       f&#39;&lt;/Placemark&gt;\n&#39;)</pre><p>There’s something deeply satisfying about watching malicious traffic light up on a 3D globe.</p><h3>Key Code Highlights</h3><p>The magic happens with <strong>dpkt</strong>, a fantastic Python library for parsing PCAP files:</p><pre>eth = dpkt.ethernet.Ethernet(buf)<br>ip = eth.data<br>tcp = ip.data<br>src = socket.inet_ntoa(ip.src)<br>dest = socket.inet_ntoa(ip.dst)</pre><p>Layer by layer — Ethernet, IP, TCP — until you’re reading the actual data being transmitted.</p><p>The tool is modular by design:</p><ul><li><strong>DDOS.py</strong> handles all detection logic</li><li><strong>google_Earth.py</strong> manages KML generation</li><li><strong>Geoprint.py</strong> ties everything together with a clean CLI</li></ul><p>Run it with:</p><pre>python Geoprint.py -l capture.pcap -p -g -d</pre><p>And you get packet analysis, geolocation, Google Earth visualization, and DDoS detection — all in one go.</p><h3>Lessons Learned &amp; What’s Next</h3><p><strong>What worked:</strong></p><ul><li>Breaking detection into three independent methods made debugging so much easier</li><li>dpkt is a beast for packet parsing — lightweight and powerful</li><li>Visualizing data geographically made the whole project click</li></ul><p><strong>What I’d improve:</strong></p><p>This was a college project, so it’s far from perfect. Looking back at the code now, there’s a lot I’d do differently:</p><ul><li>The 10k packet threshold is arbitrary. A smarter statistical model would be better.</li><li>Only detects LOIC-based attacks right now. Modern DDoS uses different tools.</li><li>Real-time monitoring instead of post-capture analysis would be game-changing.</li><li>Error handling could be more robust.</li></ul><p>But hey, that’s the beauty of old projects — they show you how much you’ve grown. And despite its flaws, it actually works, which is what mattered to me back then.</p><p><strong>Future plans:</strong></p><ul><li>Add support for more attack vectors (SYN floods, UDP floods).</li><li>Machine learning for anomaly detection.</li><li>Live capture mode with alerts.</li></ul><h3>Try It Yourself</h3><p>The project is open source on <a href="https://github.com/Netwok-Analyzer/DDOS-Detect">GitHub</a>.</p><p><strong>Quick start:</strong></p><pre>git clone https://github.com/Netwok-Analyzer/DDOS-Detect.git<br>cd DDOS-Detect<br>pip3 install -r requirements.txt<br>python Geoprint.py -l test.pcap -d</pre><p>Grab a sample PCAP file (there are test files in the repo), run it, and see what you find. Fair warning: once you start seeing the patterns, it’s addictive.</p><p><strong>Final thoughts:</strong> Building this tool taught me more about network security than any course could. There’s something about getting your hands dirty with real packet data that just… sticks. If you’re curious about security, don’t just read about it — build something. Start small, break things, fix them, and before you know it, you’ll have something real.</p><p>Happy hunting! 🔍</p><p><em>Have questions or suggestions? Drop them in the comments. And if you build something cool with this, I’d love to hear about it.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e515e6f4628" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>