Code: Select all
{===============================================================}
{ Hiding Glyph: Bytewise Image Steganography }
{---------------------------------------------------------------}
{ Version: Alpha }
{ Author: Gamall Wednesday Ida }
{ Web: gamall-ida.com }
{===============================================================}
{===============================================================}
{ Introduction }
{===============================================================}
'Steganography' is the art of hiding and transmitting secret
data in an inconspicuous way. It is different from cryptography
insofar as the 'enemy' is not supposed to know you are
attempting to transmit secret data even if they intercept it,
while it is painfully obvious that an encrypted message is
concealing something...
This program allows you to conceal any file (or even group of
files) in any losslessly compressed 24+ bits bitmap image.
Unless you purposefully select an utterly plain image, there is
no way to know the image contains hidden data, and there is no
way to extract said data without the original, unaltered image.
{===============================================================}
{ How does it work ? }
{===============================================================}
o==--~~ Hiding the data into an image
o--------------------------------------------------o
You select a file or folder you want to conceal, and the image
you want to conceal it into (hereafter called 'original'). The
program then compresses the data using an external compression
program (see credits). The compressed file is then stored, byte
after byte, into a copy of the image. Each pixel of the image
stores one byte of the compressed file, coding it in base 7 (the
most efficient base possible for that task) in the RGB channels.
The altered image is then written.
o==--~~ Sharing the hidden data
o--------------------------------------------------o
Your partner must have the original image. You can then blithely
publish the altered image on the Internet, and only your partner
will be able to extract the data. Others won't suspect there is
more than meets the eye in that image, and even if they do, it
is impossible to extract the data without the original image.
(impossible here meaning really impossible as opposed to
'computationally infeasible' as is the case with cryptography).
o==--~~ Extracting the hidden data
o--------------------------------------------------o
Your partner just needs to feed both the original and the
altered images to the program, which will automatically extract
the compressed file, then extract the uncompressed data.
{===============================================================}
{ Usage of the program }
{===============================================================}
There are basically three ways to operate the program: manually,
with a command-line headstart and in full command-line.
o==--~~ Manually
o--------------------------------------------------o
Just start the program and follow the instructions: you will be
first asked to select the task you wish to carry out: either 'h'
for hiding and 'x' for extraction. Then you will have to feed
two paths to the program. Under Windows XP, I recommend
drag-n-dropping the files on the console rather than typing
their names or worse, their absolute path. Drag-and-dropping the
files on the console will automatically write their absolute
path, without any risk of error.
o==--~~ Command-line headstart
o--------------------------------------------------o
If you start the program with either 'h' or 'x' as an argument
(hint: use shortcuts) you will forgo the selection of the task.
You still will need to type/drag-n-drop the two paths.
o==--~~ Full command-line
o--------------------------------------------------o
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glyph.exe x <path to image1 > <path to image2>
glyph.exe h <path to secret file> <path to image >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I recommend using shortcuts: define one for hiding and one for
extracting. Then all you have left to do if drag-and-drop the
files onto the shortcut's icon.
Note that extraction is commutative: the order in which the
images are fed is irrelevant. Hiding, however, is not. The
secret file or folder must be the first argument, else the
program will crash.
{===============================================================}
{ Notes }
{===============================================================}
o==--~~ Image formats
o--------------------------------------------------o
Out of the box, the program only supports uncompressed formats
such as BMP. However, if the ImageMagick library is installed
onto your system, it will support most other image formats. I
must put a strong emphasis, however, upon the fact that lossy
compressed image formats, such as JPEG, are absolutely NOT
suitable. My personal recommendation is PNG, which is lossless.
o==--~~ Trivia and History
o==--~~ (don't read if you're easily bored)
o--------------------------------------------------o
This is basically an improved-upon version of a program I wrote
about 6 years ago in VB6 (this one is in C++). I still don't
know how I got the idea then, since I had neither the Internet
nor any book about steganography. Probably my natural taste for
secrecy* made it seem like a natural step to take when I first
discovered the RGB encoding of bitmap images.
(*my first program ever was a Vigenere encoding utility: I
remember I filled the grid manually because I had not grasped --
or plain didn't even know about -- the concept of a 'for'
loop... That is to say I was motivated for that kind of things)
Unfortunately it seems reasonable to assume somebody thought of
it before me... Too bad :P
Anyways, the following points have been improved upon since my
first attempt:
-> The hidden bytes are encoded in base 7 on the RGB channels
instead of base 10. That way the maximal color discrepancy
becomes 6 on GB and 5 on R rather than 9 on GB and 2 on R. This
reduces the dust effect, and makes it much smoother.
-> The data is stored, for each channel, either positively if
there is room, or negatively if there isn't. The absolute value
of the difference is extracted. This suppresses the need for a
preprocessing phase darkening the bright pixels, and makes
extraction commutative.
-> The data is automatically compressed. Beyond the added
convenience and multiplied storage space for the end user, this
makes the data stream quasi-random, making the noise more
uniform and difficult to spot.
-> A pseudo-random padding is added, which makes the end of the
data stream impossible to spot on the picture, and integrates
seamlessly with the quasi-random file stream.
-> Can store complete folders instead of just a single file.
-> Instead of using key strings of bytes to separate data
streams, their length is stored in the first bytes of the
stream, which avoids the danger of cropped files.
-> The program is much faster and easier to use, but does not
have the shiny graphical user interface the first one had.\line
o==--~~ Known bugs
o--------------------------------------------------o
None if it is used correctly. It may crash if you attempt to do
something stupid though. Most of the time it will display an
error message: you can then terminate it cleanly. If you chose
to continue despite the error message, it will very likely end
up throwing an exception and crashing.
Originally, the program displayed the images and the user could
see the RGB values for each pixel, but I had to deactivate this
feature because of strange conflicts when linking with the MFC
libraries.
Advice: Be wary of the executables' working directories.
{===============================================================}
{ Support }
{===============================================================}
I always welcome questions and suggestions posted on the
relevant topic on gamall-ida.com.
{===============================================================}
{ Credits }
{===============================================================}
David Tschumperlé for the CImg library, which I use in this
program.
Igor Pavlov for the 7z compression format. I use 7za.exe
(renamed comp.exe) to compress the data which must be hidden.
The user can replace comp.exe by any other program though, as
long as the basic syntax is identical.
+-----------------------------+
| File generated with 'GaTeX',|
| an ASCII typesetting system |
| by Gamall Wednesday Ida. |
| http://gamall-ida.com |
+-----------------------------+
Build: Mon Jun 04 17:32:22 2007
File : readme_hiding_glyph.gat
This is the original image, in which nothing is hidden: Three files are hidden in this image: