[steganography] I tried using Steghide to hide sensitive data from images!

[steganography] I tried using Steghide to hide sensitive data from images!

Steganography is one of the techniques for hiding information.
It is possible to embed and hide information in various data such as image data and audio data.
While it is used for good things like digital watermarking, it is also often misused, such as hiding malicious scripts.

This time, I'll try using Steghide to hide sensitive data from images.

Recommended reference books
Author: IPUSIRON
¥2,090 (As of 15:33 on 2025/07/13 | Amazon research)
\Rakuten Points Sale! /
Rakuten Market
\5% points back! /
Yahoo Shopping
Author: IPUSIRON
¥3,850 (As of 21:11 on 07/08/2025 | Amazon research)
\Rakuten Points Sale! /
Rakuten Market
\5% points back! /
Yahoo Shopping
Author: Justin Seitz, Author: Tim Arnold, Supervised by: Mantani Nobutaka, Translation: Arai Yu, Translation: Kakara Hirosei, Translation: Murakami Ryo
¥3,520 (As of 12:26 on 07/09/2025 | Amazon research)
\Rakuten Points Sale! /
Rakuten Market
\5% points back! /
Yahoo Shopping
table of contents

How do steganography hide data?

There are several different ways to hide your data.
For example, the least significant bit technique known as LSB is one of the most used.

The least significant bit technique is a technique in which the last few bits of a byte are changed to encode a message.
Images are represented by 1 byte each of the red, green and blue values.
The full red is (1111111,00000000)[(255,0,0)], but if you change the lower two bits to the maximum, it becomes (11111100,00000011) (252,3,3).
This is certainly different from the data, but I think it is almost impossible to notice it with the naked eye.

This method of hiding sensitive information using the lower two bits that are almost the same with the naked eye is called the least significant bit technique.
It is also true that the least significant bit method is the easiest method to understand, so I think we will actually use a more sophisticated method.

Embedding hidden data into a file

Use Steghide to hide the text file in the image.

Install steghide

First, let's start with installing steghide.
This time, we will explain the steps that are intended for Linux.

The installation method is simple, just use apt.

sudo apt-get install steghide

Once this is done, the installation is complete.

Embedding a file in an image

Next, use the installed steghide to embed the file in the image.

First, create a sensitive file to be embedded.
This can be a script, but this time I'll leave it as a text file. Please set the contents as you like.

sudo touch secret.txt vi secret.txt sudo vi secret.txt  

I did it like this. When extracting a file from an image, it would be a success if the same content was confirmed.

cat secret.txt secret-1234567890-text

Next, prepare an image to embed the sensitive file.
Anything is fine, so prepare the images as you like. I have prepared some pictures of my family dog. (lol)

If you want to embed a file with steghide, this is the command:

steghide embed -ef [Confidential file] -cf [File to embed sensitive file] -sf [Output file] -z [Compression level] -e [Encryption type]
-ef

Specify the file you want to hide. It is possible to embed various files such as Python scripts and shell scripts.

-cf

Specify the file to be embedded with the file set with -ef.

-science fiction

Specify the output file. If omitted, the original file will be overwritten.

-z

Specify a compression level from 1 to 9. If you don't want to compress, use -Z.

-e

Specify the encryption type. If not specified, AES encryption is used. If it is not encrypted, it will be -e none.

I'll try using this command this time.

steghide embed -ef secret.txt -cf inu.png -e none -Z Enter passphrase: 1234 Re-Enter passphrase: 1234 embedding "secret.txt" in "inu.png"... done

You will be asked for a password to extract, so set any password you like (I set it to 1234 this time).
If you receive a message like the one above, the image in the folder should be updated.
The output this time is as follows: The original image is shown above, but it is hard to tell the difference with the naked eye.

Now I've managed to embed the file in the image.

Extract files from images

Next, let's check if it's really embedded.
It's also very easy to extract.

Extract files from images

The command to extract a file from an image is as follows:

sudo steghide --extract -sf inu.png -xf extractSecret.txt Enter passphrase: write extracted data to "extractSecret.txt".

You will be asked to enter the password you set when embedding.
Now you can extract the file from the image.

Let's check the contents.
I think you can safely see the same string.

sudo cat extractSecret.txt secret-1234567890-text

summary

In this article, with the aim of understanding steganography, I used Steghide to hide sensitive data from images.
I would like to eventually develop my own unique techniques and take a look.

Share if you like!

Who wrote this article

This is a blog I started to study information security. As a new employee, I would be happy if you could look with a broad heart.
There is also Teech Lab, which is an opportunity to study programming fun, so if you are interested in software development, be sure to take a look!

table of contents