# Steganography

## Steganography

![https://commons.wikimedia.org/wiki/File:Primer\_libro\_de\_steganografia.JPG](https://2575763014-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNC3KGY9k0nvrU_5PW6%2F-MO9aLOjzJDJmVz8_fge%2F-MO9d_L8vBusS7wYqwJb%2Fimage.png?alt=media\&token=ab4f609b-b636-433b-9b13-252c8e4086ae)

In this mini lab we will see how we can hide information inside other files and we will see the process of extracting this hidden information. With the use of steganography, we can hide information inside another file that can then be distributed regardless of being seen by third parties. Its hidden content is visible only to those who are aware it exists and know how to extract it. Generally this hidden content is also encrypted so that a passphrase is required to extract it.

{% hint style="info" %}
**Image by Cornell University** Indicates the use of Eksblowfish. **steganography** (from [Greek](https://es.wikipedia.org/wiki/Griego_antiguo) στεγανος steganos, "covered" or "hidden", and γραφος graphos, "writing") deals with the study and application of techniques that allow hiding messages or objects inside others, called carriers, so that their existence is not perceived. That is, it seeks to hide messages inside other objects and thereby establish a [covert channel](https://es.wikipedia.org/wiki/Canal_encubierto) of communication, so that the very act of communication goes unnoticed by observers who have access to that channel.

&#x20;**Read more in the following** :point\_right: [**link**](https://es.wikipedia.org/wiki/Esteganograf%C3%ADa).
{% endhint %}

There are various tools that allow us to see this process in action; in this particular exercise we will use Steghide.&#x20;

## Basic steganography with **`Steghide`**

![Harris Brisbane Dick Fund, 1924](https://2575763014-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNC3KGY9k0nvrU_5PW6%2F-MOOng_Oj60FlXIYMPw_%2F-MOP1XwzzmACn5Ilodmv%2FRAVEN.jpg?alt=media\&token=fa792545-07b7-45c2-932e-b3077818d46a)

The illustration above may seem like a common image, however **`contains hidden inside it the complete poem`** To Domains \[Sharing this NS] **`The Raven`** version of **`Edgar Allan Poe`**. At first glance the image shows no signs of being more than what can be perceived, and with that we can get an idea of the potential of steganography to hide information and transport it even in front of third parties' eyes without the hidden message being detectable at a glance.

### Hiding information with **`Steghide`**

Let's look at the basic commands of **`steghide`** that we must use to achieve replicating that result and carry out our basic steganography exercise. The first thing we must have is the basic files:

* [x] An Image.
* [x] The Message we want to hide.
* [x] Steghide.

the basic use of steghide is super simple, just use the following options:

{% hint style="success" %}
**steghide embed -cf {cover\_file} -ef {embed\_image}**
{% endhint %}

* **`embed`**: tells steghide the mode we want to use. In this case embed inserts content into the target file.
* **`-cf FILE`**: Indicates to steghide the file that will act as the cover, in this case the image that will contain the hidden information. For our example this file is **`RAVEN.jpg`**.
* **`-ef FILE`**: Indicates the path to the file that will be hidden in the cover file. For our example this file is **`MESSAGE`** which contains the complete poem **`The Raven`**.
* **`passphrase`**: the key needed to extract the hidden content. For this example the key is **`POE`**.

![](https://2575763014-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNC3KGY9k0nvrU_5PW6%2F-MOOng_Oj60FlXIYMPw_%2F-MOP1InK0fMeDYYR9OiU%2Fimage.png?alt=media\&token=df8e0210-bc0f-465a-8511-b21fbef65679)

As we can see the size of the file **`RAVEN.jpg`** undergoes a change in weight after the process. It is important to keep this in mind since if the message we try to hide is too large, we must resort to a larger image that has sufficient capacity to store our message. This happens because steganography uses the least significant bits of the image to replace them with the bits that make up our hidden message.

We can see this exemplified in the following image where the least significant bits of the image are altered to store the bits that make up the word cat.

![esgeeks.com: This diagram shows two 4-pixel images both in color and in binary values. Each binary block represents the value of the corresponding pixel.](https://2575763014-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNC3KGY9k0nvrU_5PW6%2F-MOP2gPq17vnJTB_ykO-%2F-MOP3i2JfQMWJx1gzJbS%2Fimage.png?alt=media\&token=a6ec1653-c54a-4cd2-b20e-c906ffe44ca2)

### Viewing **`Embedded information`** with **`Steghide`**

Now let's see how we can use steghide to check if our image contains embedded hidden information. For this we use the following options:

{% hint style="success" %}
**steghide info {Cover\_File}**
{% endhint %}

* **`info FILE`**: the operation mode that tells steghide we want to see information about the file. Among the returned results you can obtain: **`Encryption`** algorithm used, **`file`** size, **`name`** of the embedded file and **`format`** of the cover file used.

![](https://2575763014-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNC3KGY9k0nvrU_5PW6%2F-MOPBBwgPhhUZp99brTT%2F-MOPCZZB84xfgqcira4y%2Fimage.png?alt=media\&token=861b4721-797a-4f86-9f42-5583c0aa925b)

As we can see to perform this operation we need the passphrase (key) that was used at the time of hiding the information. In this case we know the **`key`**, in many cases this information is unknown and we will have to resort to **`social engineering`**, or to **`brute-forcing`** with tools like **`stegcrack`** to obtain the key and be able to use this command. The same also applies to the process of extracting the embedded information.

### Extracting **`embedded information`** with **`Steghide`**

When the time comes we will need to extract the hidden information from the image; for this we will use the following options of **`steghide`**:

{% hint style="success" %}
**steghide extract -sf {COVER\_FILE}**
{% endhint %}

* **`extract`**: Tells steghide that we want to perform the extraction of embedded data from a cover file.
* **`-sf FILE`**: Tells steghide the cover image from which we want to extract the embedded information.
* **`passphrase`**: The key to be able to extract the hidden content.

![](https://2575763014-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNC3KGY9k0nvrU_5PW6%2F-MOPBBwgPhhUZp99brTT%2F-MOPEyqR-xk4DlXJQns1%2Fimage.png?alt=media\&token=8ac47118-cbd4-4857-ab05-644459f64039)

If we check the contents of the extracted file, we can see that it indeed contains the poem we had hidden before:

![](https://2575763014-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MNC3KGY9k0nvrU_5PW6%2F-MOPBBwgPhhUZp99brTT%2F-MOPFBCXZ57DudFuDHvg%2Fimage.png?alt=media\&token=f3e91f23-ddae-44d0-b45f-8017368f5674)

In this way we saw how we can use steganography to hide information inside other files, which on the surface appear normal to anyone who sees them.

It should be clarified that steganography is not limited to image and text files and can also, for example, embed source code inside audio and video using other tools. In the case of Steghide in particular it allows us to hide information inside files with the following formats: **`WAV`**, **`JPEG`**, **`AU`** and **`BMP`**.

Steghide has numerous options to refine as desired how the process of embedding content inside other files is carried out. It is not within the scope of this exercise to see the entire operation of steghide and it is important to be clear that there are different alternative tools with which we can achieve the same result.

{% hint style="info" %}
These labs are subject to modifications and corrections; the most up-to-date version is available online at [the following link](https://tzero86.gitbook.io/tzero86/).
{% endhint %}
