Jump to content

Hide text in bitmap


monoceres
 Share

Recommended Posts

Hi!

I found this interesting article on codeproject so I decided to use the idea in an autoit script since it didn't seem to hard :)

It's basically a way to hide a string inside the bitmap data in a .bmp file. The basic idea is to use just 1 bit of each byte in the bitmap data to save the message, this means that each pixel that is modified inside the bitmap is just modified by one single little color shade (thus making it impossible for a human to notice the difference), so for example 0x000000 becomes 0x000001.

To be able to extract the string you need to know what offset the string is saved into in the bitmap, thus making it smewhat secure for peeping eyes :o

A big thanks to james3mg for his Number base conversion UDF.

The syntax is easy:

HideMessageInBitmap("file.bmp","My message",SECRET OFFSET HERE)

GetMessageInBitmap("file.bmp",SECRET OFFSET HERE)

Here's a bitmap I have encoded a message at offset 234 for example:

test.bmp

UDF ( With Number base conversion UDF):

Bitmap_Message_Hider.zip

Ps. Since png doesn't destroy any image data, a encoded message will survive a png conversion :D

:D

Edited by monoceres

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

I have a question.

Is there any limit to the text to hide it in the picture?

Yes and it depends of the size of the bitmap. But it's quite easy to calculate.

If you for example have a bitmap that is 262144 bytes large (256 kB) you have 262090 bytes for text storage (since the bitmap header is 54 bytes).

Then we have to subtract 32 bytes to save the information that contains how many chars there are in the bitmap. That leaves us with 262058 bytes. Now usually one char takes up 1 byte of storage, but since we're only using the last bit in every byte in the bitmap we need 8 bytes to store one char. Therefore we need to devide the available space with 8. Which leaves us with 262058/8=32757,25= 32757 chars available for storage :) Of course this assumes that the offset is 0.

Here's a quick formula:

MsgBox(0,"",CalculateLimit(256*1024))

Func CalculateLimit($BitmapSize,$Offset=0)
    Local $BitmapHeaderSize=54
    Local $TextHeaderSize=32
    Local $OneCharSize=8
    Return Floor(($BitmapSize-$BitmapHeaderSize-$TextHeaderSize-$Offset)/$OneCharSize)
EndFunc

:o

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

This is awesome !!

Btw, how can I put different message at a different offset?

I'd try it, but the message is corrupted (sometimes return blank)

You just have to make sure there is enough room between the offsets. If you for example have the text "Hi!" at offset 100 the next offset can be earliest at offset 155 (32 bytes for length of string and 8*3 for the chars).

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

  • 6 months later...
Link to comment
Share on other sites

  • 2 weeks later...

No, that's not possible. This code merely changes the color data inside the bitmap. Even if someone did encode a virus into a bitmap it would only show up as an image. The image viewer would have no reason to execute to last bit of every RGB value.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...