<?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 Rithvik on Medium]]></title>
        <description><![CDATA[Stories by Rithvik on Medium]]></description>
        <link>https://medium.com/@pvrithvik456?source=rss-1fb681e09950------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tEU48w7ZB_q0RSFRYXL8lw.jpeg</url>
            <title>Stories by Rithvik on Medium</title>
            <link>https://medium.com/@pvrithvik456?source=rss-1fb681e09950------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:23:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pvrithvik456/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[XDP: Basic Firewall]]></title>
            <link>https://medium.com/@pvrithvik456/xdp-basic-firewall-808e0cbaea2f?source=rss-1fb681e09950------2</link>
            <guid isPermaLink="false">https://medium.com/p/808e0cbaea2f</guid>
            <category><![CDATA[ebpf]]></category>
            <category><![CDATA[xdp]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[linux-kernel]]></category>
            <category><![CDATA[firewall]]></category>
            <dc:creator><![CDATA[Rithvik]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 03:49:29 GMT</pubDate>
            <atom:updated>2026-09-15T03:49:29.783Z</atom:updated>
            <content:encoded><![CDATA[<p>This was a project that added a few wrinkles to my brain, apparently things that seem tough are interesting. Who would’ve thought that!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_gNHPdWSc4pk_AbaVTvuKw.png" /><figcaption>Artistic very much</figcaption></figure><h3><strong>What’s XDP?</strong></h3><p>XDP or eXtended Data Path is a Linux Networking subsystem which allows for bare-metal packet processing in the Linux kernel. Which allows for high performance/low latency, in-kernel packet processing.</p><p>This would also mean that it is easier to break your kernel by writing unsafe code, but they already accounted for this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JSatF0NX3tDr3YmwuUn4pg.png" /><figcaption>Position of XDP relative to NIC</figcaption></figure><p>The program is run in a sandbox along with a verifier that checks whether or not the eBPF program follows specific rules such as accessing memory out-of-bounds, finite complexity etc.</p><p>Let’s implement it with a basic firewall!</p><h3><strong>Basic Firewall:</strong></h3><p>This is a lookup based blocking mechanism, our key idea is:</p><ol><li>Incoming packets trigger XDP hook</li><li>Identify the packet’s source address through the packet header</li><li>If source IP is in map → block the packet</li><li>Else →let it pass</li></ol><p>XDP has the following action flags:</p><pre>xdp_actions{<br>XDP_ABORTED #Abort the program execution in an error<br>XDP_DROP #Drop the packet<br>XDP_PASS #Let the packet into the kernel networking stack<br>XDP_TX #Transmit the packet back<br>XDP_REDIRECT #Redirect the packet from on network interface to another (wlp2s0 → eth0, or something else)<br>}</pre><p>I’ve only utilized <strong>XDP_PASS</strong> and <strong>XDP_DROP</strong> for the sake of simplicity and my sanity.</p><h3><strong>Code:</strong></h3><p><strong>Kernel-space Code:</strong></p><p>Basic idea of the kernel-space code i.e initialization of the XDP hook is:</p><ol><li>Initialize a map to store the blacklisted IP</li><li>If source address of packet is in our blacklist map, then drop the packet</li><li>Else, let it pass</li></ol><pre>SEC(&quot;xdp&quot;)<br>int  xdp_parser_func(struct xdp_md *ctx)<br>{<br>   void *data_end = (void *)(long)ctx-&gt;data_end;<br>   void *data = (void *)(long)ctx-&gt;data;<br>   struct ethhdr *eth = data;<br>   if ((void *)(eth+1)&gt;data_end){<br>       return XDP_PASS;<br>   }<br>   if (eth-&gt;h_proto!=bpf_htons(ETH_P_IP)){<br>   return XDP_PASS;<br>   }<br>   struct iphdr *iph = (struct iphdr *)(data + ETH_HLEN);<br>   if ((void *)(iph + 1) &gt; data_end)<br>       return XDP_PASS;<br>   u8 *cnt = bpf_map_lookup_elem(&amp;blocked_ips, &amp;iph-&gt;saddr);<br>   if (cnt){<br>        __u32 ip = iph-&gt;saddr;<br>       bpf_printk(&quot;BLOCKED: %d.%d.%d.%d&quot;,<br>               ip &amp; 0xff,<br>               (ip &gt;&gt; 8) &amp; 0xff,<br>               (ip &gt;&gt; 16) &amp; 0xff,<br>               (ip &gt;&gt; 24) &amp; 0xff);<br>       return XDP_DROP;<br>   }<br>   return XDP_PASS;<br>}<br>char LICENSE[] SEC(&quot;license&quot;) = &quot;GPL&quot;;</pre><p><strong>Our idea for the userspace code is:</strong></p><p><strong>1) Blacklist IP map initialization:</strong></p><ol><li><strong>Read the text file containing blacklisted IPs</strong></li><li><strong>Create a map of blacklisted IP</strong></li><li><strong>Send the values to the kernelspace map</strong></li></ol><pre>map_fd = bpf_object__find_map_fd_by_name(<br>       obj,<br>       &quot;blocked_ips&quot;<br>   );<br>for (auto ip: blocklist) {<br>       err = bpf_map_update_elem(<br>           map_fd,<br>           &amp;ip.first,<br>           &amp;ip.second,<br>           BPF_ANY<br>       );<br>       if (err) {<br>           fprintf(<br>               stderr,<br>               &quot;Failed to insert %d: %s\n&quot;,<br>               ip.first,<br>               strerror(errno)<br>           );<br>           continue;<br>       }<br>       printf(&quot;Blocked: %d\n&quot;, ip.first);<br>   }</pre><p><strong>2) Attach your program to the network interface you’re using (I’ve used wlp2s0)</strong></p><pre>link = bpf_program__attach_xdp(prog, ifindex);</pre><p><strong>3) Load your program</strong></p><pre>obj = bpf_object__open_file(&quot;../bpf/xdp_firewall.o&quot;, NULL);<br>   if (libbpf_get_error(obj)) {<br>       fprintf(stderr, &quot;Failed to open BPF object\n&quot;);<br>       return 1;<br>   }<br>   err = bpf_object__load(obj);<br>   if (err) {<br>       fprintf(stderr, &quot;Failed to load BPF object: %d\n&quot;, err);<br>       goto cleanup;<br>   }<br>   prog = bpf_object__find_program_by_name(<br>       obj,<br>       &quot;xdp_parser_func&quot;<br>   );</pre><p>The whole code is available on my <a href="https://github.com/Rithvik1124/XDPFirewall/"><strong>Github</strong></a><strong>!</strong> (shameless plug).</p><p><strong>Limitations:</strong></p><p>While XDP is a useful tool in networking and packet inspections, one of its limitations is that it can only process ingress packets, i.e. packets coming into the machine.</p><p>“How’s that a problem?” — XDP can only process the packets which are being received by your machine, when in fact the firewall is a traffic police for a 2 way street, for both incoming and outgoing traffic.</p><p>This can be overcome with using TC(Traffic Control), another Linux subsystem used for processing ingress and egress packets(requires qdisc and interface setup).</p><p>Some other limitations — the program being hard-coded to a single network interface, no dynamic change observation and no IPv6 support.</p><p><strong>Here are the guides I use and some useful links:</strong></p><p><a href="https://beej.us/guide/"><strong>Beej’s Guide</strong></a> (https://beej.us/guide)</p><p><a href="https://eunomia.dev/"><strong>Eunomia</strong></a> (<a href="https://eunomia.dev/">https://eunomia.dev/</a>)</p><p><a href="https://docs.cilium.io/"><strong>Cilium Docs</strong></a> (<a href="https://docs.cilium.io/">https://docs.cilium.io</a>)</p><p><a href="https://www.slideshare.net/slideshow/xdp-and-ebpfmaps/78001591">https://www.slideshare.net/slideshow/xdp-and-ebpfmaps/78001591</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=808e0cbaea2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kokum: The Humble Underdog]]></title>
            <link>https://medium.com/@pvrithvik456/kokum-the-humble-underdog-5491d6fd3765?source=rss-1fb681e09950------2</link>
            <guid isPermaLink="false">https://medium.com/p/5491d6fd3765</guid>
            <category><![CDATA[pune]]></category>
            <category><![CDATA[kokum]]></category>
            <category><![CDATA[food]]></category>
            <dc:creator><![CDATA[Rithvik]]></dc:creator>
            <pubDate>Wed, 01 Jul 2026 16:09:51 GMT</pubDate>
            <atom:updated>2026-07-01T16:09:51.913Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever found yourself staring at a jar of peanut butter or some food that has become a daily habit, <strong>something that goes from being completely unknown to becoming part of your everyday life?</strong></p><p>For me, it all started with a small curiosity — <strong>“What’s kokum soda? Let’s try it.”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*yYTkANTM6jo--0UkAGWQYA.png" /><figcaption>Kokum &amp; Kokum Soda — Shutterstock</figcaption></figure><p>I was in Pune for an industrial exposure event. We roamed the neighborhood in the evenings and found a food court near the Bird Valley Lake and saw a drink stall called “Bar of Soda”. The menu had a variety of different sodas, it was mostly something I either had before or something that didn’t really amuse me, one of them caught my eye <strong>“kokum soda”</strong>. I asked my friend if he knew about kokum, he didn’t either. In front of me was a pint of soda, reddish-magenta color and the taste that can’t be described to something “similar to xyz”, the first sip was enough for me to realize that it became a “core memory” for me. That first sip stayed with me long after the trip. Naturally, I became curious about what kokum actually was.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*WVBMy8SZBnf6ZJT5U1-0Eg.png" /></figure><p><strong>Kokum(Garcinia Indica) </strong>is a species from the <strong>mangosteen family</strong>(which surprised me, despite its looks being the same as a mangosteen). It’s mainly grown near the Western Ghats of India. The rind of kokum is mainly used as a souring agent in Maharashtra, Assam and Kerala, as a substitute to tamarind.</p><p>A few days back, while browsing on the internet, I found a blog on<strong> Ruth Reichl’s “La Briffe”</strong> on the first time she tried kokum at <strong>Lespinasse</strong> in New York City meticulously curated by the late <strong>Gray Kunz</strong>, who was one of the most acclaimed chefs in Manhattan and was well known for his <strong>French-Asian fusion.</strong> Since that day, Ruth Reichl admitted that she was intrigued by the flavour of kokum and has been<strong> using it ever since</strong>.</p><p>Gray Kunz is a man who created some of the best chefs the world has seen. Late <strong>Floyd Cardoz</strong>, was a student of Gray Kunz, he was one of the few who had cemented his name in the food industry as a <strong>“master of fusion”</strong>. The one dish you might remember him from was his take on upma on <strong>Top Master Chefs: Season 3</strong>. A fusion of American and Indian flavours — his winning dish was his take on <strong>upma, cooked in chicken stock with kokum and wild mushrooms.</strong></p><p>Coming back to the point on why I am writing this blog, Kokum, despite making its mark in several such occasions, didn’t get the recognition it deserved internationally. Call it being humble or still being an underdog. Despite that, hundreds and thousands of people enjoy it daily. In the times of the next big trend, where matcha is a thing you might see being held in every other hand. Kokum has still found its way into people’s hearts.</p><p>Perhaps that’s what kokum teaches us, that it’s not about becoming the next big trend, but quietly providing a major support in an award winning dish and in many people’s hearts. Sometimes that’s a greater success than becoming the next viral food.</p><p>All it takes is one moment of curiosity: “What’s kokum?”</p><p>I would love to hear your thoughts on it! Any recommendations on how I can improve my next blogs are also welcome :).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5491d6fd3765" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[picoCTF Write-Up: SUDO MAKE ME A SANDWICH]]></title>
            <link>https://medium.com/@pvrithvik456/picoctf-write-up-sudo-make-me-a-sandwich-493e5d9296b3?source=rss-1fb681e09950------2</link>
            <guid isPermaLink="false">https://medium.com/p/493e5d9296b3</guid>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[sudo]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[picoctf]]></category>
            <dc:creator><![CDATA[Rithvik]]></dc:creator>
            <pubDate>Mon, 27 Apr 2026 18:14:12 GMT</pubDate>
            <atom:updated>2026-04-27T18:14:12.601Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Challenge:</strong> SUDO MAKE ME A SANDWICH<br><strong>Author: </strong>Darkraicg492<br><strong>Category:</strong> General Skills<br><strong>Level: </strong>Easy</p><p><strong>Problem Description:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*aqrTCXiIoUKdfrQTlLMaTw.png" /><figcaption>Image Description: SUDO MAKE ME A SANDWICH</figcaption></figure><p><strong>Initial Thoughts:</strong></p><ol><li>What does making a sandwich have to do with ‘sudo’.</li><li>Description asks to read the flag.</li><li>Check out the manual page for sudo</li></ol><p><strong>Approach I took:</strong></p><ol><li>Search up “SUDO MAKE ME A SANDWICH”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*53_JWkc3zjLhxH-QtLhlPw.png" /></figure><p>Two things caught my eye, first was the “Okay” response by DuckDuckGo, which was weird(an Easter Egg). Second was the comic by <a href="https://xkcd.com/149/">xkcd</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*kCZ5a81NA7eEvorPbDQXDA.png" /><figcaption>SUDO MAKE ME A SANDWICH — by xkcd</figcaption></figure><p>The main punchline was that ‘sudo’ gives Cueball(character in the chair) the authority to make the other character(don’t know the name) make them a sandwich. Hence, the CTF delves in sudo.</p><p>2. The next inference was from the second hint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*OhRlsi_vsZjF_APr9CBReQ.png" /><figcaption>Hint 2: SUDO MAKE ME A SANDWICH</figcaption></figure><p>3. Check the manual for sudo related to “knowing user-provided permissions”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*AZR-Blco8PBSqK-daWfMnA.png" /><figcaption>man sudo</figcaption></figure><ul><li>— list flag helps list the privileges for the users on current host.</li></ul><p>4. List the files in current directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*-Xz-nHPblfbvgEdjQjQUyg.png" /></figure><p>5. Run <em>sudo -l </em>in ssh host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*vxPEcVJH7MEjngwiVmRuFg.png" /><figcaption>CTF Player Permissions</figcaption></figure><p>This shows that CTF Player has permissions to use emacs(text editor) as root, this allows us to open and read flag.txt.</p><p>6. Run <em>sudo /bin/emacs flag.txt.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*PyWqiEtcEsK-kOBRvpRanQ.png" /></figure><p>7. We’ve found the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*7nf5Xp-sVHncVhBKbQIqtA.png" /><figcaption>Hidden for non-laziness purposes.</figcaption></figure><p>That’s pretty much it! Overall a nice and easy challenge.</p><p>This was my first CTF write-up, let me know if I can improve anything regarding my writing and explanations, feedback is greatly appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=493e5d9296b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>