Today, we use personal computers as workstations and personal devices. On these devices, we keep personal information and private files not intended for public access.
Given this, even if you do not share your computer with others, it’s essential to treat your security as a high priority and secure your files with cryptography and encryption methods.
This tutorial discusses how to protect and secure your files by hiding them inside other files. For this tutorial, we will look at how to hide files in images; as a bonus, we’ll also discuss how to hide files in audio files.
NOTE: The methods discussed in this tutorial do not guarantee 100% security; a security professional or forensics analyst can crack them. That said, disguising private files you want to secure is better than leaving them exposed.
A Basic Introduction to Steganography
Steganography refers to the process of hiding a file, whether a video, image, audio, or text, inside another file. Although steganography is an old way of hiding files and messages, it can be very useful when working in an unsecured environment.
Steganography is much more advantageous compared to encryption. For example, a malicious user is likely to ignore a secret document hidden inside an image of your cat than a file encrypted with GPG.
Some of the other advantages of steganography include:
- Steganography does not attract attention compared to other methods of encryption.
- It is simple to understand and use.
- Once a file is hidden, it remains in that state until exposed.
Having looked at what steganography is and its pros, let’s get rollin’ in the deep:
How to Use the Cat Command to Hide Files in Images
The first method we can use to hide files inside an image is the cat command in Linux.
To do this, you will need to have a zip file containing all the files you wish to hide and an image.
Start by creating a directory and add all the files you wish to hide. Next, compress the directory into zip format.
Now move the compressed file and the image you wish to use to hide the files into the same directory.
Next, launch the terminal and navigate to the directory location where the zip and the image are.
All you have to do now to hide the files is concatenate the zip and the image to an appropriately named image—you can call the image anything you want.
Here’s an example:
Once you have hidden the files, remove all other raw files to ensure security. To view the files, unzip the image containing the hidden files.
How to Hide Files in Images Using Outguess
We can also use a tool to perform image steganography. The Outguess tool allows you to hide data in redundant bits of existing files. It mainly supports files such as JPEG and NETpbm formats.
Outguess is a widely used tool in BSD systems. You can read the official documentation available here:
You can also install it using your default package manager. For example, to install it on Debian, simply enter the command:
Once installed, navigate to the directory where you have your secret files and the image you want to use as your file-hiding location. Use the following command to hide your files inside an image (image.jpg) and a passphrase
The above command will output the image containing hidden files. You can extract them using the command
How to Use Steghide for Image and Audio Steganography
Another tool we can use for image and audio steganography is Steghide. Steghide is a simple command-line tool capable of hiding data in image and audio files. The tool is powerful mainly because it does not alter the colour-respective sample-frequencies, making it immune to first-order statistical checks. Steghide allows compression and encryption of the embedded data, making it a good choice for steganography.
Here’s how to use this tool for that purpose:
How to Install Steghide
Unless you are using a penetration distribution, Steghide does not come pre-installed in many Linux distributions. However, it is available in the main repositories, making it easy to install.
To install it on Debian/Ubuntu-based distributions, enter the command:
For Arch-based distributions, use the command
Once you have Steghide installed, you can hide files you want inside an image or an audio file; the examples below illustrate that.
Ensure you move the files you want to hide—and the image or audio file you want to hide them in—into the same folder.
Next, enter the following commands to hide the files
This command will prompt you to provide a passphrase. Enter your passphrase and continue.
To extract the file from the image, use the command:
Enter the passphrase you used when embedding the files.
How to Hide Files In Images Using Stegosuite
The final steganographic tool we are going to discuss is Stegosuite. Stegosuite is a simple graphical image steganography tool written in java that uses AES encryption to embed data. The tool currently supports file formats such as BMP, GIF, JPG, and PNG.
To install Stegohide on Debian/Ubuntu-based distributions, use the command:
Using Stegosuite is simple; once installed, launch the tool.
In the main menu, select the file –> Open and select the image you wish to use to embed the files. Next, right-click on the box and select add files.
Now select the files you wish to hide inside the image. Finally, provide the passphrase and click Embed.
That will create an embedded image inside the file of the original image location with the name imagename_embed.ext. For example, if the main image is image.jpng, the output file will be image_embed.png.
To extract data, open the file, enter the password, and click Extract.
This tutorial has taught you various methods you can use to hide files in images and audio files. For additional security, consider using hidden directories and encrypted zip files, and then hide them inside an image. That will give your files an extra layer of security from prying eyes.