<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nishad Aherrao</title>
    <description>The latest articles on DEV Community by Nishad Aherrao (@nishad10).</description>
    <link>https://dev.to/nishad10</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F500789%2Fcae55718-9e1d-4203-9ea9-4529eacd8a00.jpeg</url>
      <title>DEV Community: Nishad Aherrao</title>
      <link>https://dev.to/nishad10</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nishad10"/>
    <language>en</language>
    <item>
      <title>Steganography [ folder -&gt; image ]</title>
      <dc:creator>Nishad Aherrao</dc:creator>
      <pubDate>Sat, 31 Oct 2020 05:37:30 +0000</pubDate>
      <link>https://dev.to/nishad10/steganography-folder-image-5d0m</link>
      <guid>https://dev.to/nishad10/steganography-folder-image-5d0m</guid>
      <description>&lt;p&gt;I spent the last two days reading and learning some cool things related to steganography. Due to the recent youtube-dl takedown, I saw a few tweets of images and videos of the image/video form of the source code repository which piqued my interest. In this post, I will be going over steganography in general as well as walk you through how to convert a folder to a single image file that can be distributed and then restored to the original folder.&lt;/p&gt;

&lt;p&gt;You can skip directly to the walkthrough if you want. Here is a list of things I am covering.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Steganography&lt;/li&gt;
&lt;li&gt;youtube-dl&lt;/li&gt;
&lt;li&gt;Walkthrough&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;a id="Steganography"&gt;&lt;/a&gt; Steganography
&lt;/h2&gt;

&lt;p&gt;The way I see steganography is that it deals with things related to hiding data/message in something (file) and then distributing the file in which the data is hidden. Steganography is best used when encryption isn't a viable option. Encryption is visible in the sense that you know that an encrypted file is probably hiding something. In the case of steganography, it is a much subtle way of hiding things. That's all I am going to say about it as my knowledge about it is limited. Linked some resources about steganography below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Steganography" rel="noopener noreferrer"&gt;Wiki&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.reddit.com/r/Steganography/" rel="noopener noreferrer"&gt;Subreddit&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;a id="youtube-dl"&gt;&lt;/a&gt; youtube-dl
&lt;/h2&gt;

&lt;p&gt;The only reason I started to dig deeper into steganography was because of youtube-dl. I knew about the concept of steganography and had used &lt;code&gt;steghide&lt;/code&gt; once or twice before, that's about it. This is a huge topic of discussion right now without delving deeper into it what's happening is, youtube-dl is an open-source program used by a lot of people to download videos from youtube and few other sites using the command line. The RIAA issued a &lt;a href="https://github.com/github/dmca/blob/master/2020/10/2020-10-23-RIAA.md" rel="noopener noreferrer"&gt;DMCA takedown notice&lt;/a&gt; and Github took down the repository. I stumbled upon this tweet which made me want to try and implement this method of converting files to images by myself.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1319765986791157761-618" src="https://platform.twitter.com/embed/Tweet.html?id=1319765986791157761"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1319765986791157761-618');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1319765986791157761&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;Looks interesting, what's happening here? People decided to convert the repository/folder that contains the source files of youtube-dl into images and even videos!&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/hyqLv2_zBdA"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;a href="https://twitter.com/gasmanic/status/1320107219866836994" rel="noopener noreferrer"&gt;More about the video above&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Having seen the end result with a real-life use case I really wanted to try it out. In the same thread, someone made a &lt;a href="https://github.com/rekcuFniarB/File2PNG" rel="noopener noreferrer"&gt;shell script&lt;/a&gt; that converts files to images so I &lt;a href="https://github.com/nishad10/File2PNG" rel="noopener noreferrer"&gt;forked&lt;/a&gt; that and started playing around with it.&lt;/p&gt;
&lt;h1&gt;
  
  
  &lt;a id="ftoimg"&gt;&lt;/a&gt; Converting a Folder to an Image
&lt;/h1&gt;

&lt;p&gt;Alright so let's say we want to do the same as above, there are a lot of tools available to convert files to other formats including images. Some tools are better suited to us as they focus on steganography in general. &lt;code&gt;steghide&lt;/code&gt; is a commonly used tool but in this case, we will be using &lt;code&gt;imagemagick&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://imagemagick.org/script/download.php" rel="noopener noreferrer"&gt;Download and install&lt;/a&gt; if you haven't already. Once you are done you can take a look at the &lt;a href="https://imagemagick.org/script/convert.php" rel="noopener noreferrer"&gt;convert&lt;/a&gt; script This is what we will be using as the core. You can follow an example or two from the above link to make sure everything is working. Now let's see how the script is supposed to work in our case. We want to do something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;convert -size $heightx$width -depth $depthValue RGB:"$INFILE" PNG00:"$OUTFILE"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Flags and their meanings -
&lt;/h3&gt;

&lt;p&gt;convert =&amp;gt; The script we want to run&lt;br&gt;
&lt;a href="https://imagemagick.org/script/command-line-options.php#size" rel="noopener noreferrer"&gt;-size&lt;/a&gt; =&amp;gt; The size of our output image. [Height x Width] pixels&lt;br&gt;
&lt;a href="https://imagemagick.org/script/command-line-options.php#depth" rel="noopener noreferrer"&gt;-depth&lt;/a&gt; =&amp;gt; The number of bits in a color sample within a pixel &lt;br&gt;
&lt;a href="https://imagemagick.org/script/formats.php" rel="noopener noreferrer"&gt;RGB/PNG00&lt;/a&gt; =&amp;gt; These are just the formats of the files we are transforming from &amp;gt; to respectively where INFILE and OUTFILE filenames of our file that we want to convert and name of the file to convert to respectively.&lt;/p&gt;

&lt;p&gt;Now you may notice that there are some variables in the above command that are unknown. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;$height $width $depthValue&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Let's start with &lt;strong&gt;depthValue&lt;/strong&gt;, you can read more about it in the link above but the depths we usually will work with are 8 or 16. Some websites hate 16 bit in a pixel and may modify the image which would destroy our data. I am using 8 in my shell script but this can be changed as you wish. However, that would dictate our height and width.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Height&lt;/strong&gt; and &lt;strong&gt;Width&lt;/strong&gt; are basically the lengths in pixel terms. So how big should the image be so that the file can fit in it? To find that out we can do some simple math. This is what I do in my shell script. To do this we need the total number of pixels required, which is the size. think of it as the area(pixels) of a square/rectangle(image). &lt;/p&gt;
&lt;h3&gt;
  
  
  Total number of pixels
&lt;/h3&gt;

&lt;p&gt;As this is basically the result of our height x width. Once we have the total amount of pixels needed we can just get its square root and have a nice square, where height = width and height x width = total pixels.&lt;/p&gt;

&lt;p&gt;Alright, how do you get the total pixels needed?&lt;br&gt;
So we use the equation below to get the pixels. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Size of file (bytes) * PixelsPerByte(pixels/byte)&lt;/em&gt;&lt;br&gt;
&lt;em&gt;bytes * pixels/byte = pixels&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  File Size (byte)
&lt;/h4&gt;

&lt;p&gt;In the shell script, we use some cmd line tools to get the byte size of our file to convert. &lt;/p&gt;
&lt;h4&gt;
  
  
  Pixel per byte (pixel/byte)
&lt;/h4&gt;

&lt;p&gt;This is where we use the depth we defined before. We are using RGB for our file to convert. So we need 3 pixels for (R, G, B) and then we multiply that with the depth(bits per pixel) to get the total number of bits necessary. Now to convert bits to bytes just divide by 8. This will look something like this. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;PIXBYTE= ( $depthValue * 3 / 8 )&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We are almost done! So now we have everything we need to use the convert script. You can see how it all comes together in my &lt;a href="https://github.com/nishad10/File2PNG/blob/master/file2png" rel="noopener noreferrer"&gt;shell script&lt;/a&gt;. This will work on most files however I had issues converting .tar.gz and .zip files to images. Convert from ImageMagick was complaining about the file formats and throwing error while reading the file in the RGBread file. &lt;/p&gt;

&lt;p&gt;I fixed that by using the cmd line &lt;code&gt;cat&lt;/code&gt; operation to feed the file to our convert program. So we use &lt;code&gt;cat&lt;/code&gt; to output our .tar.gz file or any other file and then use that output as an input for our convert script using the command line &lt;a href="https://www.geeksforgeeks.org/piping-in-unix-or-linux/#:~:text=Pipe%20is%20used%20to%20combine,more%20commands%2F%20programs%2F%20processes" rel="noopener noreferrer"&gt;pipeline operators&lt;/a&gt;. We use the &lt;code&gt;|&lt;/code&gt; operator that takes the output of things on the left and feeds it as an input to the things on its right. &lt;/p&gt;

&lt;p&gt;Our final tweaked command would look something like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat ${INFILE} | convert -size ${HEIGHT}x${WIDTH} -depth $depthValue RGB:- "$OUTFILE"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's finish this by accomplishing our objective. Let's convert a folder to an image and then restore it. I'll be converting the youtube-dl repo to a single image.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;h3&gt;
  
  
  This is how it looked on my end -
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7f5qu0qfh7e4p8wuipyc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7f5qu0qfh7e4p8wuipyc.png" alt="TerminalOutput"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was the first time I played around with file conversions and images. Let me know if I misunderstood anything and feel free to correct me on anything above. &lt;/p&gt;

&lt;h3&gt;
  
  
  Here is the image our program created -
&lt;/h3&gt;

&lt;p&gt;Download here: &lt;a href="https://dev-to-uploads.s3.amazonaws.com/i/3vipdj6nft67kz6ur163.png" rel="noopener noreferrer"&gt;https://dev-to-uploads.s3.amazonaws.com/i/3vipdj6nft67kz6ur163.png&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3vipdj6nft67kz6ur163.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3vipdj6nft67kz6ur163.png" alt="RGBImage"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>tutorial</category>
      <category>image</category>
      <category>steganography</category>
    </item>
    <item>
      <title>intro - pilot post</title>
      <dc:creator>Nishad Aherrao</dc:creator>
      <pubDate>Wed, 28 Oct 2020 11:10:48 +0000</pubDate>
      <link>https://dev.to/nishad10/intro-pilot-post-c8h</link>
      <guid>https://dev.to/nishad10/intro-pilot-post-c8h</guid>
      <description>&lt;p&gt;Hello everyone, I am Nishad Aherrao. This is my first ever blog kind of post. I never had a blog before and never really felt like I needed one (which I was wrong about). So I just wanted to quickly go over why I finally decided to start maintaining a blog as well as give you a little introduction about myself. I also want to use this post as a way to learn and explore the website and the tools offered to write these posts, this is basically a pilot post.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why -
&lt;/h1&gt;

&lt;p&gt;Ever since the start of 2020, I have been grinding on job applications and spending a considerable amount of time on personal growth. During this time I started noticing a few things, I found myself googling for medium and dev.to posts while learning about new things, this helped me realize the &lt;em&gt;influence&lt;/em&gt; of these posts along with their &lt;em&gt;need and utility&lt;/em&gt;. As I was applying for various jobs I saw an increase in the number of people asking for links to personal websites as well as blogs. This helped me realize the value of blogs from a &lt;em&gt;career perspective&lt;/em&gt;. Considering I have been spending a lot more time learning new things and working on projects I thought it would be a fine idea to write about it as well. I think it's cool to have a &lt;em&gt;documented version of your learnings&lt;/em&gt; and if it helps someone along the way that's an added bonus. Last but not least I want to use this as a way to &lt;em&gt;improve my English&lt;/em&gt;. &lt;/p&gt;

&lt;h1&gt;
  
  
  A little about me -
&lt;/h1&gt;

&lt;p&gt;I am currently in the U.S. doing my bachelor's in Computer Science at the University of Texas at Arlington and I will be graduating in December 2020. I am originally from India, born, and brought up there. I can speak and write in Marathi my mother tongue, Hindi my national language as well as English which I learned and have been using for the past almost 18 years of my life. I have interned at two companies before this.&lt;/p&gt;

&lt;p&gt;During my recent internship, I was required to make posts about my project progress and gather feedback internally on &lt;a href="https://www.workplace.com/"&gt;workplace&lt;/a&gt; which is basically Facebook for employees to talk about work-related things. One thing I noticed during this time was I had a hard time writing these reports and making these posts. My manager had to proofread my posts as well as help me enrich them. I feel like writing these blogs will help me improve my English.&lt;/p&gt;

&lt;p&gt;Which brings me to my final point, I want to use this as a way to learn and grow. Hopefully, I can use this as a way to document my learning process as well as help people along the way. Feedback on my posts about my content and/or grammar will help me with my learning and English as well.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
