Hiding Glyph: Bytewise Image Steganography

Miscellaneous programs and scripts, opensource or not, and sometimes, random mathematical stuff.
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Hiding Glyph: Bytewise Image Steganography

Post by Gamall »

Hiding Glyph Alpha.zip
(558.99 KiB) Downloaded 7363 times
PS: Link to ImageMagick. This library adds support to compressed image formats such as PNG. See the readme.

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
Have fun extracting the files hidden in those example images (gamall.png is merely a PNG conversion of my 150*150 JPG avatar)

This is the original image, in which nothing is hidden:
gamall.png
gamall.png (59.3 KiB) Viewed 115077 times
Three files are hidden in this image:
GLYPH_gamall.png
GLYPH_gamall.png (63.48 KiB) Viewed 115083 times
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
FireStar
Episode IX: Signature du désespoir
Posts: 56
Joined: Tue Apr 03, 2007 1:19 pm

Re: Hiding Glyph: Bytewise Image Steganography

Post by FireStar »

Ca a l'air sympa la stegano , cest d'ailleurs ce qu'il me manque pour mes challenges :(
http://www.net-force.nl/members/view/12553/

Car j'ai pas du tout compris comment ca fonctionnait ni à quoi ca servait :D
Image
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Hiding Glyph: Bytewise Image Steganography

Post by Gamall »

FireStar wrote:Car j'ai pas du tout compris comment ca fonctionnait ni à quoi ca servait :D
Comment ça fonctionne... comme on veut :D On peut faire de la stéganographie avec tout et n'importe quoi... A quoi ça sert: à cacher des informations secretes pour que seuls les destinataires puissent les extraire. (et même savoir qu'il y a des infos secrètes, contrairement à la crypto)

Etymologiquement, stéganographie veut dire "manière d'écrire en cachant"... dans l'antiquité, les messages étaient tatoués sur le crâne du messager, on laissait les cheveux pousser et... ni vu ni connu... :lol Maintenant on a des méthodes plus sophistiquées tout de même :ouioui Celle implémentée par mon programme n'est qu'une approche parmi des milliers d'autres...

Si ça t'intéresse, les articles de Wikipedia ne sont pas mal : (http://en.wikipedia.org/wiki/Steganography) mais il y a aussi plein de bouquins sur le sujet.
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
zavvlon
Posts: 11
Joined: Wed May 20, 2009 11:46 am

Re: Hiding Glyph: Bytewise Image Steganography

Post by zavvlon »

hi.... Hum I just downloaded the program but there seems to be some problems, I go easily through everything but when it comes down to the last part, it crashes... when it writes "showing immage" actually I'll type what it writes.


** Hiding Glyph Alpha
** by Gamall Wdnesday Ida
** email : gamall.ida@gmail.com
** web : gamall-ida.com


Do you want to:
- <H>ide a file <or folder> in an image ?
- e<X>tract a hidden file from an image ?

Enter the desired action <H or X> : H

Hiding mode.
Path to the file <or folder> you want to hide:
"C:\Documents And Settings\Propriétaire\Bureau\45.bmp"
Path to the image in which you want to hide it:
"C\Documents and settings\Propriétaire\Bureau\avatar33433_9.bmp"

Hiding file in image... displaying image
<CImgIOException>

cimg::fopen<> : File 'C:\Documents And Settings\Propriétaire\Bureau\avatar33433_9.bmp' cannot be opened for reading.

This application has requested the runtime to terminate it in an unusual way.
Please contact the application's support team for more information.


That's what it writes... then the usual "windows crashing window" with the "send" and "don't send" choices shows up. wich ever I chose closes the program

I would normally email you but unfortunatly my hotmail seems to be unable to send emails to Gmail users.

Please answer me quickly (preferably email me, I can receive from gmail users, but for some reasons not send.)

Thank you very much


Zavv Lon
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Hiding Glyph: Bytewise Image Steganography

Post by Gamall »

zavvlon wrote:cimg::fopen<> : File 'C:\Documents And Settings\Propriétaire\Bureau\avatar33433_9.bmp' cannot be opened for reading.
It may be something else, but the problem may come from the accent in the path (in "Propriétaire").

Please try again from an "accentless" path and let me know. (edit: note that you can use relative paths to avoid that problem altogether; for instance if you start the program in X, you can just type y for the file X/y)

(edit a few hours later: I've done some tests, and that is the problem indeed ;) )

Also I don't remember the details of the program (wrote it looong ago), but I think that if avatar33433_9.bmp already exists it will not overwrite it and that may be the cause of the error. Try giving a path to a new file.

I case it's not that, are you under Vista or XP or Linux/Wine ?
zavvlon wrote:I would normally email you but unfortunatly / Please answer me quickly (preferably email me
All support of all my progs (if any is necessary) is done here, and never by mail. So by mail I'd just have told you to post here :D .
Last edited by Gamall on Wed May 20, 2009 7:20 pm, edited 2 times in total.
Reason: reproduced bug, confirmed accents caused it
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
zavvlon
Posts: 11
Joined: Wed May 20, 2009 11:46 am

Re: Hiding Glyph: Bytewise Image Steganography

Post by zavvlon »

Thanks alot for helping me out with this :) I wanted to put my computer in english but unfortunatly I'm not the only one using it (here is why I need encrypting and hiding programs)

I'm going to try out a few ideas to try not to have an acent. Thanks alot for helping me on this :) I owe you that. (Even though I can't think of a way to help you on anything hahaha!)

Bye!

Zavv Lon


P.s. I used to use the program axcrypt but unfortunatly it is obvious that the files are encrypted so I was searching for more subtil and clever ways, I saw about steganography on a show called "numbers" (awesome show) I'm glad I found one that is free. Thanks for your generousity.
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Hiding Glyph: Bytewise Image Steganography

Post by Gamall »

For accents, just use relative paths as I suggested, problem solved.

PS: even on windows, on can create several user accounts on the computer.
zavvlon wrote:Thanks (x3)
You're very welcome :D (x3)
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
zavvlon
Posts: 11
Joined: Wed May 20, 2009 11:46 am

Re: Hiding Glyph: Bytewise Image Steganography

Post by zavvlon »

I already have a few accounts, and it would look weird if I created one for no apparent reason. IN any case I found another way, Using my USB key instead of directly onto the computer. Works perfectly. I hope you don't mind me asking but, what's your main language? I mean, You talk with me in english but I saw some french on this site. Lol. Bye!









Zavv Lon
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Hiding Glyph: Bytewise Image Steganography

Post by Gamall »

zavvlon wrote:I hope you don't mind me asking but, what's your main language? I mean, You talk with me in english but I saw some french on this site
I am French, and French is, of course, my native language. Nevertheless, I use English to document and support my programs simply because there are many more people capable of reading English than French --- or any other language for that matter. And those who read French should read English as well anyway, so...

I gather you are Canadian, so you could probably have asked your initial question in French; however I am glad that you did it in English, so the answer may be useful to other people who don't read French.
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
zavvlon
Posts: 11
Joined: Wed May 20, 2009 11:46 am

Re: Hiding Glyph: Bytewise Image Steganography

Post by zavvlon »

I personnaly am of french origins I live in the province of quebec, most here barely understand english. I learned mine watching anime on tv :D But I find english much easier to spell, and conjugate. French is just way too hard. Only thing I have real trouble in english is my vocabulary (not as developped as french) and rhyming into my poems (Yes I am one of the rare guys that loves to write poems :)) I use english for the same reason you do, most understand it and therefor my message is easier to understand (also less spelling mistakes, my french's spelling is awefull :S) Haha!

Zavv Lon
User avatar
zavvlon
Posts: 11
Joined: Wed May 20, 2009 11:46 am

Re: Hiding Glyph: Bytewise Image Steganography

Post by zavvlon »

Good day, It's been quite a while since last time I posted here and in fact for a while I even forgot I had hyding glyph on my computer '-.- But now I am trying again to use it but it's problematic because it works in Bytes and my computer works in Octets, I heard somewhere that it's a 8to1 ratio but I want to make sure first.

Could you please tell me how to go from octet to bytes?

thank you

Zavv Lon
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Hiding Glyph: Bytewise Image Steganography

Post by Gamall »

zavvlon wrote:because it works in Bytes and my computer works in Octets, I heard somewhere that it's a 8to1 ratio but I want to make sure first.
1 byte = 1 octet = 8 bits.

They are two names for the same thing. (historically because old computers had bytes of different sizes; the term "octet" was coined to avoid ambiguities)

There are plenty of things which can make a given program work differently on different computers, but bytes and octets are quite innocent in this respect, I assure you :lol
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
User avatar
zavvlon
Posts: 11
Joined: Wed May 20, 2009 11:46 am

Re: Hiding Glyph: Bytewise Image Steganography

Post by zavvlon »

Sorry but I'm not so sure because I have written down the available amount of space of my picture (through the usage of the program) and yet I'm unable to fit file of equal the number of bytes in Octet... I'll try again but I'm sure It didn't work, or maybe the fault is mine...

Thanks anyways :)
User avatar
zavvlon
Posts: 11
Joined: Wed May 20, 2009 11:46 am

Re: Hiding Glyph: Bytewise Image Steganography

Post by zavvlon »

OH MY GOD!!! I'M SO STUPID!!! I just realised that I forgot to consider that the files I attempted to hide within the picture were actualy in Kilo octets not Octets... Geez this was a stupid mistake on my part..

Thanks anyways, and thanks for clarifying the ratio.

Is there a way to Guess the amount of free space in a picture before activating the program?

Also I juste realised something, I have just installed Imagemagik on my computer and the program won't accept pictures of another format. Why?
Gamall
Hic sunt dracones
Posts: 4174
Joined: Fri May 26, 2006 11:09 pm
Contact:

Re: Hiding Glyph: Bytewise Image Steganography

Post by Gamall »

zavvlon wrote: were actualy in Kilo octets not Octets
1 Ko = 10^3 octets = 1000 octets.
zavvlon wrote:Is there a way to Guess the amount of free space in a picture before activating the program?
To guess ? No. But to compute ? Yes.

Exach pixel codes one byte therefore size_h = Width \times Height where size_h is the number of octets (or bytes) an image can hide and Width and Length are those properties of the picture, in pixels. Actually the images holds a little less than that since extra storage space is used for the file's name.

For the BMP format (24bits), then the rule of thumbs is size_h= {size_{file}}/3.

edit: I forgot, the program automatically compresses the data to hide, so size_h is in fact the compressed size; so an image can in fact hold much more than that. How much depends on how well the file you are trying to hide will compress. A ZIP archive will not compress much, if at all. A Word file will compress a lot. Etc.
zavvlon wrote:Also I juste realised something, I have just installed Imagemagik on my computer and the program won't accept pictures of another format. Why?
It should; are you sure it is properly installed, and that you are using a lossless compression format (not JPEG, for instance) ?

If you are sure, please quote the error message (screenshot if it's long or technical) and the procedure you follow to reproduce it.
Last edited by Gamall on Tue Apr 13, 2010 2:21 am, edited 2 times in total.
Reason: forgot
{<§ Gamall Wednesday Ida §>}
{ Mods and Programs - Mods TES-IV Oblivion }
Post Reply

Who is online

Users browsing this forum: Google Adsense [Bot] and 69 guests