Ubuntu

How to Hide Files Inside Images in Ubuntu Using Steganography

Hide Files Inside Images in Linux using Steganography

Steganography is the process of hiding confidential information inside another file. Its purpose is to hide the existence of confidential information in such a way that it does not look suspicious. Also, the person looking directly at the file may not be able to see the actual information. Combining Steganography with encryption adds additional layer of protection as it not only hides the presence of data but also makes it more secure.

In this post, we will cover how to hide files inside images in Ubuntu using Steganography. We will be covering four different methods:

  • Using the Steghide utility (Command Line)
  • Using the Outguess utility (Command Line)
  • Using the Cat utility (Command Line)
  • Using the Stegosuite utility (GUI)

Note: We have explained the procedure on Ubuntu 20.04 LTS (also applies for Debian OS). You will require sudo privileges for installing the utilities on your system.

Using the Steghide Utility (Command Line)

Steghide is a command-line utility that allows you hide to files in an image or an audio file. It can hide data in JPEG, WAV, AU, and BMP formats.

You can use the following command to install the Steghide utility:

$ sudo apt install steghide

Once Steghide is installed, you are ready to hide or embed your files inside an image. You will require the file that you want to hide and an image that you want to hide it in (also known as cover file).

To hide a file inside an image file using Steghide, the syntax is as follows:

$ steghide embed -ef <file-to-hide > -cf <image.jpg>

Where -ef is used to specify the file <file-to-hide > that needs to embed and –cf is used to specify the cover file <image.jpg> that you want to hide it in.

For instance, the below command will hide the testfile.txt in a flower.jpg image file.

$ steghide embed -ef testfile.txt -cf flower.jpg

It will ask you to type a passphrase and then confirm it. This password will be later used to extract the file embedded in the image. If you don’t want to password-protect it, just hit Enter twice.

Now that our file is hidden inside the image, we can remove the original file.

$ sudo rm testfile.txt

Access the Hidden Files

To access the file hidden inside an image, you will need to extract it from the image. The syntax is as follows:

$ steghide extract -sf <image>

Where -sf is used to specify the image name which contains the embedded data.

For instance, the below command will extract the original file embedded into the image flower.jpg.

$ steghide extract -sf flower.jpg

Provide the password for the file, after which the original file will be extracted.

Using the Outguess Utility (Command Line)

Outguess is another command-line utility that is used to embed the files inside an image. It lets you hide information in redundant bits of the cover medium. It can hide data in PPM, PNM, and JPEG files.

You can use the following command to install the Steghide utility:

$ sudo apt install outguess

Once Outguess is installed, you are ready to hide or embed your files inside an image. You will require the file that you want to hide and an image that you want to hide it in (also known as a cover file).

To hide a file inside an image file using Outguess, the syntax is as follows

$ outguess -k <“password”> -d <file-to-hide> <image> <image-out>

Where “password” is the password used to encrypt and hide the <file-to-hide> inside an <image>. The <image-out> is the resultant file containing the resultant image with the embedded data.

For instance, the below command will embed the testfile.txt into flower.jpg with password abc123 and store the results in flower-out.jpg.

$ outguess -k “abc123” -d testfile.txt flower.jpg flower-out.jpg

Now you can remove the original text file:

$ sudo rm testfile.txt

Access the Hidden Files

To access the file hidden inside an image, you will need to extract it from the image. The syntax is as follows:

$ outguess -k “password” -r <image-out> <filename>

You can choose any name for the <filename>, not necessarily the original file name.

For instance, the below command will extract the original file embedded into the image flower-out.jpg.

$ outguess -k “abc123” -r flower-out.jpg testfile.txt

Using the Cat Command (Command Line)

You will be well aware of the Linux Cat command which has three major functions: create files, view contents of the file, and concatenate files. Using the Cat command concatenation function, we can achieve Steganography.

For this method, you will require a zip file (containing the files that need to hide) and an image file (in which you want to hide the files). Follow the steps by step procedure to do so:

1. Create a directory and add all the files you want to hide in an image. For instance, we want to hide a directory of files named myfiles, so we have created it using the following command:

$ sudo mkdir myfiles

Then in the newly created directory, copy the files you want to hide.

2. Now, compress this directory using the below command:

$ sudo zip -r myfiles.zip myfiles

Where myfiles.zip is the compressed file name.

C:\Users\1 EB\Desktop\Screenshot from 2021-03-01 00-29-25.png

3. Now, place your image file in the same directory where the compressed file is placed which in our case is the Home directory. Then concatenate the compressed file and the image file and save that in a new image file as follows:

$ cat myfiles.zip image.jpg > flower.jpg

Where myfiles.zip is the compressed file, image.jpg is the image file which we want to use as a cover file, and flower.jpg is the output file that will be actually hiding the files.

C:\Users\1 EB\Desktop\aa.png

4. Now that you have hidden the files in an image, you are safe to remove the files directory and the compressed file. You can do so using the rm command as follows:

$ sudo rm -r myfiles
$ sudo rm myfiles.zip

Access the Hidden Files

To access the files hidden inside an image, you will need to unzip that image file. To do so, first ensure you are in the same directory which contains the output image file flower.jpg containing the hidden data. Then run the below command to unzip the hidden file:

$ unzip flower.jpg

C:\Users\1 EB\Desktop\Screenshot from 2021-03-01 00-51-00.png

Using the Stegosuite Utility (Graphical)

Stegosuite is another graphical Steganography utility that lets you embed a file inside an image. It uses AES for encrypting the embedded data. It can hide data in BMP, GIF, JPG, and PNG formats.

You can use the following command to install the Stegosuite utility:

$ sudo apt install stegosuite

When prompts for confirmation, press y.

Once Stegosuite is installed, you are ready to hide or embed your files inside an image. You will require the file that you want to hide and an image that you want to hide it in (also known as a cover file).

To launch the Stegosuite utility, hit the super key on your keyboard and type stegosuite. From the search results, click the Stegosuite icon to launch it.

Now in order to hide your files inside an image, follow the below steps:

1. In the Stegosuite utility, go to File > Open from the top menu bar.

2. A file browser will appear. Select the cover image you want to hide your file in and click Open. In our example, it is flower.jpg

After doing so, you will see the image loaded on the right side of the Stegosuite window.

3. Now, you will need to upload the file that you want to hide in an image. To do so, right-click the area under the embedded files section and select Add file option.

Browse the desired file from the file browser and then click Open. In our example, it is testfile.txt.

4. Set a password for your file. It will be later used when you will have to extract the file from the image. Then click the Embed button to embed the file into the image.

It will create a new file named in the format imagename_embed.extension. For instance, if your image name is flower.jpg, then the new output file will be created with the name flower_embed.jpg.

Now our file has been embedded in the image, we can remove the original confidential file (testfile.txt). We only need to keep the output image file (flower_embed.jpg).

Access the Hidden Files

To access the file hidden inside an image, you will need to extract it from the embedded image. 1. Launch the Stegosuite utility and go to File > Open.

2. Then load the output image file which in our example was flower_embed.jpg.

2. Enter the password for the file and click Extract to extract the original file hidden inside the image.

Now your original file will be extracted.

Remove/Uninstall

In case, you want to remove Steganography utilities from your system; you can easily do so by using apt remove command followed by the utility name. For example, to remove Steghide utility, the command would be:

$ sudo apt remove steghide

In this post, we have covered how to hide files inside images through four different methods including both the command line and the graphical methods. All the methods are easy to use and do not need any special expertise. For more help, visit the man pages for these utilities by typing man followed by the utility name.

Similar Posts