DEV Community

Cover image for Steganography : Hide text within an Image file using steghide.
Surya Shankar
Surya Shankar

Posted on

Steganography : Hide text within an Image file using steghide.

Steganography is the practice (or art) of hiding secret messages in plain view.

Take an image file of a flower, for example. Opening the file shows a flower. Whoopie. However, there might be a hidden message encoded inside the bits and bytes of the image data that is not visible unless certain software is used to decode it.

The same can apply to text files. You could write an innocent readme.txt file that looks like any other text file of instructions when opened normally. With steganography, you could encode a secret message within readme.txt that includes game cheat codes, secret contact information, a cookie recipe, ASCII art, or whatever else you wish to convey to your accomplice who receives the file.

What is steghide ?

steghide is a command line utility available on *nix like platforms. It allows us to hide textual contents inside supported image file.

How to hide text using steghide ?

Let us finally see how we can actually hide our super confidential text using steghide.

First of all Inside Kali Linux , create a text file and download an image from an internet.

Image description

Text file

Image description

Image

Image description

Image description

Run the command below to encrypt and append the data. You will be asked to type a password twice.

steghide embed -cf <image_file> -ef <file_with_confidential_text>
Enter fullscreen mode Exit fullscreen mode

The -cf option is short for --coverfile which specifies the targeted image file. Whereas the -ef option is short for --embedfile which is the file which needs to be hidden.

Image description

Image description

Here we successfully hide the text file inside our image.

How to extract hidden text using steghide ?

Now that we have appended our text in the file in the section above. Let us see how we can actually retrieve the file from the image.

Now that we have the file let us run the command below to extract the data from the image file. It will prompt for password which you have used to encrypt the text.

In order to extract the textfile from the image ..
lets delete the original text file first

Image description

Image description

steghide extract -sf <image_file>
Enter fullscreen mode Exit fullscreen mode

Code language: Bash (bash)
The option -sf is short for --stegfile which is the file which holds the appended data.

Image description

We have successfully extracted the encrypted information from the image.

Image description

Image description

Top comments (0)