thavixt / Steganografix

Digital steganography

Steganography includes the concealment of information within computer files. In digital steganography, electronic communications may include steganographic coding inside of a transport layer, such as a document file, image file, program or protocol. Media files are ideal for steganographic transmission because of their large size.

For example, a sender might start with an innocuous image file and adjust the color of every 100th pixel to correspond to a letter in the alphabet, a change so subtle that someone not specifically looking for it is unlikely to notice it.

Steganographix is a web app that utilizes the below described processes to allow anyone to create, discover, and compare steganographic media files.

Read below about this application's implementation of digital steganography.

Steganography is the practice of concealing a file, message, image, or video within another file, message, image, or video.

The advantage of steganography over cryptography alone is that the intended secret message does not attract attention to itself as an object of scrutiny. Plainly visible encrypted messages — no matter how unbreakable — arouse interest, and may in themselves be incriminating in countries where encryption is illegal. Thus, whereas cryptography is the practice of protecting the contents of a message alone, steganography is concerned with concealing the fact that a secret message is being sent at all, as well as concealing the contents of the message itself.

source: WikiPedia

How is it done?

This section covers the process of encoding and decoding text from a steganograpic image with an example.

Decoding

- Reading the hidden data

Step 1:

We draw the selected image to a canvas (sometimes in the background), then read it pixel-by-pixel. Each pixel is stored as an array of four 8bit values: red, green, blue and alpha (transparency) respectively.

[125, 48, 210, 255]

Step 2:

These values are then converted to binary.

[01111101, 00110000, 11010010, 11111111]

Step 3:

We extract the steganographic data by taking the last 2 bits of every byte of each pixel.

[01111101, 00110000, 11010010, 11111111]
[      01,       00,       10,       11]

Step 4:

The two least significant, steganographic bits are concatenated in pairs of 4 into 1 bytes each.

[...01, ...00, ...10, ...11] => 01001011

Step 5:

Finally, the bytes are cast to integers, then converted to the appropriate ASCII characters, revealing the steganographic data hidden in the image (if there is any).

01001011 => 075 => K

Encoding

- Hiding your own data

Step 1:

Each character of the message is converted to the ASCII number representation of it, then cast to a single byte.

a => 097 => 01100001

Step 2:

Each byte is cut into 4*2 bits

01100001 => 01, 10, 00, 01

Step 3:

During the decoding proccess, we stored the 8bit representation of the rgba data of each pixel in the original image to avoid parsing it twice. The bit-pairs from the last step replace the last two bits of every byte in the original image.

original: 01111101, 00110000, 11010010, 11111111
message:        01,       10,       00,       01
new:      01111101, 00110010, 11010000, 11111101
                

Step 4:

The new byte data (with the message injected) is cast to the red, green, blue and alpha channels' integer values. The resulting objects can then be drawn onto the canvas as pixels of the new, steganographic image.

[125, 50, 208, 253]

Step 5:

Comparing a pixel from the original image with the same pixel containing one character of the secret message, the change is barely (if at all) noticable by the human eye.

original:  
[125, 48, 210, 255] new:
[125, 50, 208, 253]