Hide any file inside an image file, geek's hack.

This a small steganography hack that is fun and sometime really useful, when you want to send some file over internet, but upload of only image file are allowed on that server.
First here is the definition of stenography from Wikipedia. 



Steganography (Listen) is the art and science of writing hidden messages in such a way that no one, apart from the sender and intended recipient, suspects the existence of the message, a form of security through obscurity. The word steganography is of Greek origin and means “concealed writing” from the Greek words steganos (στεγανός) meaning “covered or protected”, and graphei (γραφή) meaning “writing”.    

In short, when you see the file it's just a normal image, but it has some hidden message inside it, or in general it can contain anything, even a whole movie.

There are lots of tools available for this purpose, but we can do it using what we already have just the command prompt in windows.
The requirement

  • The image file
  • The file to be hidden, the zip file
  • Command prompt
The image I will be using is this



and I want to hide a Ms word file and a Pdf behind this image, Select both the file and send to a Zip file.



Steps..



    1. Place the zip file and the image in a folder , I am placing it on the desktop.


    2. Open cmd(command prompt) and then go to the directory where both the files are. Like for example, in this case, it's "desktop". So you might need to type cd desktop 

    3. Now type copy /b imagefilename + zipfilename [filename with extensions], here is the image for clarity.

    Now the size of the image will increase, what this is doing is simple, just appending the second file to the first file and that /b is to specify that it is a binary file.

      Opening The file
      After copying, the image file size will only increase, but it can be opened normally and no difference will be seen except the size. To open the Zip file, open this image with any Zip tool like 7zip, winrar, or winzip and you can find all the files there, just extract it wherever you want.

      Note: This technique is simple and quick but as you can see anyone with a prior knowledge can easily find out. Although the benefit is that it doesn't draw anyone's attention.



      Now, some of you may want to know how to reverse the whole process and get the two files from the merged one. Although this can also be done easily but requires little programming knowledge. I don't know if this can be done in cmd but python can surely do this. 

      Getting the files back.

      As we just concatenated two files we can separate the files if we know any one file's size. 

      1. Get all the files inside the zip by opening the image with 7zip/winrar and extract them, We have all the files inside zip now. Send these file to zip again.We have the original zip reconstructed again. Note down its size in bytes by seeing its properties.Suppose the size we get is 39945 bytes.
      2. Here is python script:

      
      
      
      
      
      
      import os
      s = os.path.getsize('amir.png');
      with open('amiroriginal.png', 'wb') as f:
           with open('amir.png', 'rb') as fold:
               f.write(fold.read(s - 39945))

      3. Save this file with .py extension and Run. 

       
      This code assumes that the zip file size is 39945 bytes, amir.ong is the image file which has the hidden zip file and amiroriginal will be the new image file that will be created, and the script file is in the same directory as the files.
       
      This will give the file of the picture without zip.



      Search Anything from This Blog or Web

      Web hosting