Steganography : Hide text within an Image file using steghide.
Tags: cybersecurity, devops, cloud
Published: 2022-12-09 19:05:34

**Steganography is the practice (or art) of hiding secret messages in plain view.**

**Take an image file of a flower, for example. Opening the file shows a flower. Whoopie. However, there might be a hidden message encoded inside the bits and bytes of the image data that is not visible unless certain software is used to decode it.**

**The same can apply to text files. You could write an innocent readme.txt file that looks like any other text file of instructions when opened normally. With steganography, you could encode a secret message within readme.txt that includes game cheat codes, secret contact information, a cookie recipe, ASCII art, or whatever else you wish to convey to your accomplice who receives the file.**

## What is steghide ?
**steghide is a command line utility available on *nix like platforms. It allows us to hide textual contents inside supported image file.**

## How to hide text using steghide ?
**Let us finally see how we can actually hide our super confidential text using steghide.**

**First of all Inside Kali Linux , create a text file and download an image from an internet.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4y6tims9hpd4feqfulru.png)

## Text file
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8escfwzmis59lh3kc0f7.png)

## Image
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zxx5pqd23sxy2ck3kk56.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13xxg8yflixwqiuoemjp.png)
 

**Run the command below to encrypt and append the data. You will be asked to type a password twice.**

```
steghide embed -cf <image_file> -ef <file_with_confidential_text>
```

**The -cf option is short for --coverfile which specifies the targeted image file. Whereas the -ef option is short for --embedfile which is the file which needs to be hidden.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xyqq7bst2gbgg399o98l.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tyoef3dg5c67ilqj1jq.png)

**Here we successfully hide the text file inside our image.**

## How to extract hidden text using steghide ?
**Now that we have appended our text in the file in the section above. Let us see how we can actually retrieve the file from the image.**

**Now that we have the file let us run the command below to extract the data from the image file. It will prompt for password which you have used to encrypt the text.**

**In order to extract the textfile from the image ..** 
**lets delete the original text file first**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf6wdjkmaaehcdhemzop.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/876ov21yxv2q5rrdfgaa.png)

```
steghide extract -sf <image_file>
```
**Code language: Bash (bash)**
**The option -sf is short for --stegfile which is the file which holds the appended data.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4bgkk38odv49x0huw7ym.png)

**We have successfully extracted the encrypted information from the image.**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lhhv1uqdle8k0kce2kd1.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hc6vkgyd9rqkdo2dzkkf.png)