This is an old revision of the document!


Stegano Tool

WIP

Context

Steganography is practice of hiding information within another medium. If in encryption the difficulty lies in finding the secret (i.e.: the key) used to obfuscate the data, here the problem consists of detecting whether the data exists at all.

One stegano technique that is easy to understand consists of encoding messages into pixel data. As we all know, images are made out of pixels, and pixels are made out of three color channels: Red, Green, Blue. Usually, each channel is represented via an 8-bit value (0 - 255). The higher the value, the more intense the color. Thus, it follows that altering the more significant bits of any channel will produce visible alterations: in the image below, we masked (i.e.: set to 0) the most significant bit of every channel, of every pixel. But what happens if we play around with some of the less significant bits? Answer: no human will be able to tell the difference.

As a result, one way to exfiltrate data is by splitting the message into bits and encoding them into the least significant bits of the image. If only the least significant bit is used, you will need 3px in order to encode 1 byte of data (with 1 bit to spare).

The goal of this assignment is to write a Python tool that helps visualize the bit-level layers of different color channels.

Specification

Your python script should support the following three flags: -r, -g, -b. Each flag should be optional and accept a number in hex format (default value if flag is absent should be 0x00). These numbers represent a mask that is to be applied to each pixel, for its respective color channel. The way you apply the mask is by performing a bitwise AND (&) operation between the color value and the mask. For example, running the script only with -g 0x40 should completely suppress the red and blue channels, all while keeping the second most significant bit of the green channel (0x40 = 0100 0000). So the only pixels that you will see are (0, 0, 0) and (0, 64, 0), as in the following image:

Although this works reasonably well, it would be extremely difficult to visually differentiate pixels when suppressing the more significant bits. After all, 0x00 and 0x01 is ultimately still black, right? To deal with this, you will also add a --boost flag. This flag doesn't take any argument and it's presence should force the script to boost the color value to the maximum value (0xff) if the result of the bitwise AND is non-zero. The output should look something like this for --boost -r 0x04:

Finally, the script should also accept a positional (non-optional) argument representing the target image file. The pixel masking operation should not alter the image on the disk. In stead, your tool should display the RAM-based modified version (see Image.show()).

Resources

  • pillow is a image processing module that has support for many image formats and grants the developer access to the pixel data. You can install it using pip3 (see our previous lab for info regarding pip and virtual environments).
  • argparse is a command line argument parser. Use it to register flags for your tool.

Grading

The base assignment constitutes 2p out of your final grade (100p homework = 2p final grade). The 100p are split between the following tasks:

  • [20p] CLI arguments: Arguments are parsed, have a default value, etc.
  • [30p] Pixel masking: The specified masks are applied to each channel, regardless of image size.
  • [20p] Channel boost: If the argument is specified, {R,G,B} channels are set to 0xff for each pixel if their masked value is non-zero.
  • [30p] Secrets found: The test image contains 5 secrets encoded on certain channels, on single bit layers (i.e.: 0x01, 0x02, 0x04, etc.) Include the resulting images in your submission.
  • [1p] Bonus: If you know the source for each image :p

Write a README containing the description of your implementation, design choices, challenges you encountered, etc. Feel free to add your feedback here as well. All submissions that do not include a README will be ignored.


NOTE: Assistants are free do deduct points for bad / illegible code.

Test Images

This archive contains a PNG image with 5 secrets hidden at certain bit levels and at different channels.

FAQ

TODO: Collect questions from Teams / lab and add them here.

ii/assignments/s2/stegano.1678215740.txt.gz ยท Last modified: 2023/03/07 21:02 by radu.mantu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0