×

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.

Here at LinusAPT, as part of our Server Management Services, we regularly help our Customers to perform such Ubuntu queries.

In this context, we shall look into how to hide files inside images in Ubuntu using Steganography. 


Methods of using Steganography to hide files inside images in Ubuntu / Debian ?

You can use the following methods:

i. Via the Steghide utility (Command Line)

ii. Via the Outguess utility (Command Line)

iii. Via the Cat utility (Command Line)

iv. Via the Stegosuite utility (GUI)



1. Via 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 test.jpg image file:

$ steghide embed -ef testfile.txt -cf test.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


How to Access the Hidden Files via Steghide utility ?

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 test.jpg.

$ steghide extract -sf test.jpg

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


2. Via 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 test.jpg with password abc123 and store the results in test-out.jpg:

$ outguess -k "abc123" -d testfile.txt test.jpg test-out.jpg

Now you can remove the original text file:

$ sudo rm testfile.txt


How to Access the Hidden Files via Outguess Utility ?

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 test-out.jpg.

$ outguess -k "abc123" -r test-out.jpg testfile.txt


3. Via 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.

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 > test.jpg

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

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


How to 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 test.jpg


4. Via 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 test.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 test.jpg, then the new output file will be created with the name test_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 (test_embed.jpg).


How to Access the Hidden Files (Graphical) ?

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 test_embed.jpg.

3. 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.


How to Uninstall Steganography utilities from Ubuntu / Debian ?

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


[Need urgent assistance in fixing Debian packages? We are available to help you. ]


Conclusion

More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com