How to Hide a File in JPEG under Linux Shell?


As we know, the JPEG can be appended data at its end without causing troubles in displaying its image content. Under Linux OS, we can use the following two methods to easily hide contents at the end of JPEG files.

Using Steg

The Steg is an C++ open source cross-platform tool. It can be used to hide information in JPEG, Tiff, PNG and BMP.

To download Steg. Alternatively, use the following wget command:

1
2
3
4
wget https://googledrive.com/host/0B-_yxJMDtRxyUExLZzZ3S2VDbjQ/steg-v1.0.0.2-linux64.tgz
tar -xvzf steg-v1.0.0.2-linux64.tgz
cd steg-v1.0.0.2-linux64/
./steg.sh
wget https://googledrive.com/host/0B-_yxJMDtRxyUExLZzZ3S2VDbjQ/steg-v1.0.0.2-linux64.tgz
tar -xvzf steg-v1.0.0.2-linux64.tgz
cd steg-v1.0.0.2-linux64/
./steg.sh
steg-hide-files-in-jpeg How to Hide a File in JPEG under Linux Shell? BASH Shell linux shell tools / utilities

steg-hide-files-in-jpeg

Using zip

If you do not fancy third party tools, then the zip command is suffcient. Let’s say, we have file.txt to be hidden in the test.jpg.

1
2
$ ls
test.jpg file.txt
$ ls
test.jpg file.txt

Use the following command to create a temp hide.zip for any files you want to hide, this is to make sure the extra data is properly zipped (with header information):

1
$ zip -r hide.zip file.txt
$ zip -r hide.zip file.txt

Then we can append the zip file to the end of the JPEG.

1
$ cat test.jpg hide.zip > new.jpg
$ cat test.jpg hide.zip > new.jpg

We now have the new.jpg which contains the hide.zip. To retrieve the data, we can use the following command:

1
2
3
4
5
$ unzip new.jpg
Archive: new.jpg
warning [new.jpg]: 333221 extra bytes at begining or within zipfile
  (attempting to process anyway)
  inflating: file.txt
$ unzip new.jpg
Archive: new.jpg
warning [new.jpg]: 333221 extra bytes at begining or within zipfile
  (attempting to process anyway)
  inflating: file.txt

The unzip command will detect the zipped file appended at the end of the JPEG and uncompress them, so you will be able to retrieve the hidden data.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
413 words
Last Post: The details tag in HTML5 and the jQuery Implementation
Next Post: The PHP Bing Wallpaper Bot Crawler

The Permanent URL is: How to Hide a File in JPEG under Linux Shell?

Leave a Reply