Hmm, so the trick of putting up a catchy seasonal title worked out, we got you here!
Folks, we will be talking about a really cool tech of steganography in this post.
Hey! WAIT don't leave the post. I'm still gonna talk about secrets and I'm still gonna talk about messages. And if you are a hacker/programmer and want to convey your hidden love interest in more hidden way this post might just help you right, in time, lol.
Otherwise, if you wanna convey your hate interests even then it will help you right.
Follow along ~
So now, while texting your image to your friend, you just don't send this:
(Imagine it's you having coffee)
(Imagine it's you having coffee)
But rather, you send this:
What is the difference between the two you'd ask.
The difference is while both are JPG files, the second one has a secret text message hidden in the image and the first one doesnot.
What's that message? How's this done?
This is done using Stegnography.
"Unlike encryption, where it's obvious that a message is being hidden, stegnography hides data in plain view, inside a file such as a picture. As far as images are concerned, to anyone who isn't aware that it contains hidden data, it looks like just a normal, innocent picture."
"Unlike encryption, where it's obvious that a message is being hidden, stegnography hides data in plain view, inside a file such as a picture. As far as images are concerned, to anyone who isn't aware that it contains hidden data, it looks like just a normal, innocent picture."
In layman's language, the fact which is taken advantage of is that our eyes cannot differentiate between minor fluctuations in color. So if there are two minorly different shades of brown (which have different corresponding hexcode) are shown to humans, our eyes will find them almost equivalent and won't be able to detect the difference. So in the second image or stegnographed image per say, codes up the secret text information by randomly picking up the pixels across the image and incrementing their hashcode values.
How Is Steganography Implemented?
(Ref: https://null-byte.wonderhowto.com/how-to/steganography-hide-secret-data-inside-image-audio-file-seconds-0180936/ )
There are several different techniques for concealing data inside of normal files. One of the most widely used and perhaps simplest to understand is the least significant bit technique, known commonly as LSB.
This technique changes the last few bits in a byte to encode a message, which is especially useful in something like an image, where the red, green, and blue values of each pixel are represented by eight bits (one byte) ranging from 0 to 255 in decimal or 00000000 to 11111111 in binary.
Changing the last two bits in a completely red pixel from 11111111 to 11111101 only changes the red value from 255 to 253, which to the naked eye creates a nearly imperceptible change in color but still allows us to encode data inside of the picture.
So, if the text is "Love", it saves the binary codes corresponding to 'L','o', 'v', 'e' by tinkering the least signuficant digit of the pixel.
A typical digital image uses 24 bits per pixel. If you want to create a 4-x-6-inch print at 300 ppi, you need at least 1200 x 1800 pixels. That gives us a lot many pixels and thus bits which we can use to hide our data.
If the image is big enough, we can not only hide the text image but also another image within it!
While encoding a passphrase is needed. The same passphrase is required to extract the message from the image.
There are very simple ways on how you can perform this. If you are on linux (preferably Kali) just do these:
1. $ apt-get install steghide
2. Suppose the image named is "hearts.jpg" and the text message is saved in file "loveLetter.txt" then use the following command to generate a stegnographed image of the same name.
$ steghide embed -ef loveLetter.txt -cf hearts.jpg -e none -Z
This will ask for a passphrase, just give some string, say, "valentine".
3. In order to extract the text out of the image, use this command:
$ steghide extract -sf hearts.jpg -xf recoveredMsg.txt
This will ask for passphrase, pass the one you used while embedding, which is "valentine" in this case. The command will generate a text file named recoveredMsg.txt with the message written in it.
For more details pls refer to: https://null-byte.wonderhowto.com/how-to/steganography-hide-secret-data-inside-image-audio-file-seconds-0180936/
What is the hidden message?
So, what's the message hidden in the second image above? It is"I miss you asshole. Take care"
How can you cross check if it's really that.? Well go ahead and find for yourself, the passphrase is "valentine" (use the third command steghide extract).
Also, note that compression algos might lead to data loss, so if you send images via WhatsApp, your message might get lost in compression :P , share it on drive instead.
I'll tinker with this cool tool for sometime now and will write another post shortly if I stumble over some interesting observations/concepts/algos.
See you in the next post soon!
Take care. Keep Hacking.
Love <3
Interesting Links:
Ref: https://www.youtube.com/watch?v=5opGM7jXvHM
Ref : https://youtu.be/9UZh-4Er7BQ