[HOWTO] Create a hidden loopback device in a .jpg file

Well, I’m sure that you are definitely curious about how do you do this. Let me tell you this, it’s really simple.
Pre-requisites:

  • Image File(any format will do or even any file will do)
  • Linux(I’ve only tested it on this platform but I guess Mac would also do)

Let’s get started, shall we?
First create a standard loopback device.

dd if=/dev/zero of=hiddenimage bs=1M count=10

Let’s see what does this do:
It creates a file called “hiddenimage”, with it’s size as 10MB.
Then, create a filesystem on it.

mkfs.ext4 hiddenimage

mke2fs 1.41.8 (11-July-2009)
hiddenimage is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
2560 inodes, 10240 blocks
512 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=10485760
2 block groups
8192 blocks per group, 8192 fragments per group
1280 inodes per group
Superblock backups stored on blocks:
	8193

Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


Find out the size of your file by

du -b Wallpapers/Stones.jpg

Then, cat this image into your image file(or whatever file).

cat hiddenimage >> Stones.jpg

Then mount it by:

sudo mount -o loop,offset=FILESIZE Stones.jpg -t ext4 /media/testfs/

as in mycase it was:

sudo mount -o loop,offset=1294792 Stones.jpg -t ext4 /media/testfs/

We have now steganographed our own little filesystem image into a file. Ofcourse, anyone would be suspicious, so do ing this with a movie file would be a bit more appropriate. Now you can read/write to this image.
Comment me if you have any problems.

This entry was posted on Friday, August 14th, 2009 at 9:39 pm and is filed under another snippet | code, gnu linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.