<?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 Prateek Chandra on Medium]]></title>
        <description><![CDATA[Stories by Prateek Chandra on Medium]]></description>
        <link>https://medium.com/@prateekchandra1027?source=rss-e58dcde276ad------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Jzh5hP5iDmL-4I1shOIKng.png</url>
            <title>Stories by Prateek Chandra on Medium</title>
            <link>https://medium.com/@prateekchandra1027?source=rss-e58dcde276ad------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:37:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prateekchandra1027/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[Weird File Formats-1]]></title>
            <link>https://prateekchandra1027.medium.com/weird-file-formats-1-fcef72afb449?source=rss-e58dcde276ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcef72afb449</guid>
            <dc:creator><![CDATA[Prateek Chandra]]></dc:creator>
            <pubDate>Thu, 06 May 2021 02:01:23 GMT</pubDate>
            <atom:updated>2021-05-06T02:01:23.596Z</atom:updated>
            <content:encoded><![CDATA[<p>I will here discuss a great steganographic tool and change your view to see a file.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fslimtheseafricanbushviper&amp;display_name=Gfycat&amp;url=https%3A%2F%2Fgfycat.com%2Fslimtheseafricanbushviper-john-wick-chapter-3-parabellum-let-us-begin&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FSlimTheseAfricanbushviper-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="1068" height="744" frameborder="0" scrolling="no"><a href="https://medium.com/media/bffab3cfafcfe0672dbe0784dc465fa6/href">https://medium.com/media/bffab3cfafcfe0672dbe0784dc465fa6/href</a></iframe><p>Hi, My name is Prateek and I again present with my new discussion on weird file formats. Let’s start.</p><p>I will go through two basic myth points first.</p><ol><li>It is a very dumb idea if you think that a file let say name as test.txt is a txt file. No!! How could you be sure about that?. I mean it may be an image. Think!!So what can we do to identify this before executing or opening the file. 2 ways to do it.</li></ol><p>a) File Command :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*eRua2LGK_aG2RRTQVO_npQ.png" /><figcaption>file command</figcaption></figure><p>b)Xxd command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*a7yw2mqX4GUlFwSYUW9PGA.png" /><figcaption>xxd command</figcaption></figure><p>Here in xxd we got some weird hex format. Wait that is not rubbish it is a very important thing that is used in file formatting , that is magic numbers Ya. For each file format there is a certain code and that identifies its format and it is responsible for your job like for</p><pre>%PDF (25 50 44 46 2d) for .pdf files</pre><pre>…. (ff d8 ff e0) for .jpg files</pre><pre>PK..(50 4b 03 04) for .zip files</pre><pre>.PNG(89 50 4e 47) for .png files.</pre><p>You can read more about magical numbers <a href="https://www.geeksforgeeks.org/working-with-magic-numbers-in-linux/#:~:text=Some%20files%2C%20however%2C%20do%20not,the%20case%20of%20text%20files).&amp;text=Magic%20numbers%2FFile%20signatures%20are,xxd&#39;%20command%20as%20mentioned%20below">here</a>.</p><p>2. The file is not depends on software you are opening in that but the software or command line tools is depends on the file. Ok , Think of the case if you can open an image file in a pdf software like Document viewer? No. There must be some encoding that the Document viewer can’t open for .png, .jpg ,.xliff etc…</p><p>It is not of the fault of files but the tools. But talking about browser they are ultimate god, i mean maximum of the files can open with browser easily.</p><p>Now I will talk about the very different behaviour of .zip files. My test.zip file contains a test.txt, test.jpg, test.pdf, test.sh, Lets have a hexdump of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*EZiBeZbsMZ-gP038mmYdqA.png" /><figcaption>.zip file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*Vx2w8x1evwt_1bnRsJGa-g.png" /><figcaption>hexdump</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*OKjxg2CIj824lIqDOwr4_g.png" /><figcaption>hexdump</figcaption></figure><p>See there it easily reveals what type of files are there by their complete names but we cannot find any magic number of these files.</p><p>But if you ever think that if a file can both act as an image or pdf. or anything. Yes it is true, you can easily do it by using polyglot tool <a href="https://github.com/corkami/mitra">mitra</a>.</p><p><em>(Polyglot?? A person who can speak multiple languages :).</em></p><p>consider two examples for using this tool:</p><ol><li>test.jpg and test.pdf</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*nxt6E_C8DqnoL4riFc8StA.png" /><figcaption>mitra</figcaption></figure><p>You will see a file P{….}.jpg.pdf . Actually it is based on the Parasite method that one of the file (pdf)’s hex code is commented out and it is merged but the actual file is of .jpg format. Open the file in .pdf it works!!!. but not in Image viewer. Rename it to test.jpg. Now it will be open in Image viewer, It works!!See both the formats has been parsed into 1 single file (polyglot)check it’s hexdump and exiftool it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*87ZAcmE_DbOKbpvdghLRmA.png" /><figcaption>hexdump and exiftool analysis</figcaption></figure><p>2. test.zip and test.pdf</p><p>test.pdf has test.txt in it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lWgzeMm8EuzcUJCbJOuTXg.png" /><figcaption>mitra</figcaption></figure><p>You will see a file S{….}.pdf.zip and P{……}.zip.pdf . Both the Parasite method and Stack method are used in this case. In Parasite, the file (pdf)’s hex code is commented out and it is merged but the actual file is of .zip format. Open the file in .pdf it works!!!. but not in Archive Manager. Rename it to test.zip. Now it will be open in Archive manager, It works!!. Now comes to Stack method here a stack is build up such that zip file is mounted over pdf file. Open the file in archive manager , it will open in it but not in Document or Pdf viewer. Now, rename to test1.pdf. It will open in pdf viewer but not the in archive manager .</p><p>NOTE: Try to open test.zip in pdf viewer, it works!! But why?? Will talk about it in next blog :).</p><p>So hexdump and exiftool of stack based method are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*oflYV8VoAPdQq7HJwZ0t2A.png" /><figcaption>exiftool</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*4c_QVUcVLo-vnG0OTzKuAA.png" /><figcaption>hexdump</figcaption></figure><p>This is the idea of this blog that how weird are file formats and how they can be manipulated with the whole file data.</p><p>ADVICE FOR CTF PLAYERS: Always judge a file by file command or exiftool not simply by executing it. can also use hexdump or great hexeditors software (Ghex, 010).</p><p>Thank you up for reading this blog. I will be present again with another weird file format problem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcef72afb449" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Strange Behaviour of $0]]></title>
            <link>https://prateekchandra1027.medium.com/the-strange-behaviour-of-0-f060dd35161b?source=rss-e58dcde276ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/f060dd35161b</guid>
            <dc:creator><![CDATA[Prateek Chandra]]></dc:creator>
            <pubDate>Wed, 24 Jun 2020 13:06:25 GMT</pubDate>
            <atom:updated>2020-06-25T06:51:28.003Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Strange Behavior of $0</strong></h3><p>Hello Everyone, Welcome to the blog for the action of $0 command in Terminal. While giving some CTF’s (Capture The Flag) which are a part of cybersecurity, I found this amazing thing for $0.</p><p>Let’s get started.</p><p>First, Let’s see about echo $0. Type echo $0 in our terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/0*rSYK5DoBpTXkXEl0" /></figure><p>In the meantime, we found that it just returns the name of the shell that is bash but that’s not true for the case the same command is given in a file called zero.sh and after executing it,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/0*rGWqLwprpc6UIq2v" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/0*mRm1P6W57wNpoy7Q" /></figure><p>From the above examples we conclude that echo $0 return the name for the file.</p><p>So we have seen the characteristics of echo $0. Now see something more interesting let’s type ls and $0 with an operand pipe(‘|’)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0z2wKD2wM3QLGHn0" /></figure><p>We can see some weird text “bash: line — : — — command not found” basically this is the main task of $0 it with ls it lists the directories and after that, it tries to execute it as if for example if the “Desktop” would be a command then it would execute it but it is not a command. On the other hand, we see the same about <a href="https://tools.kali.org/information-gathering/dnsrecon">dnsrecon</a> (it is a Cyberforensic tool) that required argument and just the details about it just normal as we type dnsrecon on the terminal without arguments.</p><p>Let’s see the same thing with the cat command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*CxLGnkXHAKoaNnPq" /></figure><p>We can see that it creates just a empty shell for us just like a shell as sh. Let’s type some commands on this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*tc_lGwzZbzUERdxMGkEV0w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*-_FmGIaQYcvZsKuQ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/0*iKGOlxuTw713eBEL" /></figure><p>Whoaa. It is just a NEW SHELL behaving like bash or sh, It is the main thing I found in CTF’s that we get to know more about a particular command.</p><p>Also tries same ls and $0 with an operand ‘&amp;’, you find much interesting thing in our first line (that’s our process id :))</p><p>I Hope, you like it and tried this $0 command in your terminal. Thanks</p><p>Suggestions are welcome for this blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f060dd35161b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>