LSB Image Steganography

Developed or developing a new product in PureBasic? Tell the world about it.
juror
Enthusiast
Enthusiast
Posts: 228
Joined: Mon Jul 09, 2007 4:47 pm
Location: Courthouse

Re: LSB (Least Significant Bit) File Embedding

Post by juror »

Nice.

Another fine share :D
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: LSB (Least Significant Bit) File Embedding

Post by davido »

Very interesting and instructive.
Thank you for sharing.
DE AA EB
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 664
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

Re: LSB (Least Significant Bit) File Embedding

Post by Kurzer »

Cool JHPJHP!

This looks like my abadoned project "ImageStega".
I tried to write a tolerant LSB encoding and encryption system using last the 1 to 4 bits and a encryption key which will survive a JPG compression. But unfortunately I lost the motivation.

Nice to see a working pendant. :D

Image
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2023: 56y
"Happiness is a pet." | "Never run a changing system!"
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: LSB (Least Significant Bit) File Embedding

Post by walbus »

Very nice,
But, it is not so simple 8)

Looking the picture analyse.
Typical is the moire and the defined location.


Image
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: LSB (Least Significant Bit) File Embedding

Post by JHPJHP »

Hi juror, davido,

Thank you for posting your comments, they are very much appreciated.

-------------------------------------------------------

Hi kurzer,

ImageStega looks very good with some nicely added features.

All my posted projects were done for the fun of programming, maybe someday you'll return to ImageStega for the same reason.

Thank you for your comments.

-------------------------------------------------------

Hi walbus,

Looking at the image you posted, I think the problem was embedding to an 8 or 16 bit image, where the minimal requirement is 24 bits.

Please download and test the updated version, posting your results.

Thank you.


-------------------------------------------------------

Updated:
- added code to test for bit-depth
-- minimum requirement: 64 x 64 x 24 (width x height x depth)

NB*: Some additional improvements have been made, but nothing worth documenting.
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: LSB (Least Significant Bit) File Embedding

Post by walbus »

Yep, the results are equal.

You musst fill the picture complete, and you must mixed the bits with random about patterns or moire.
And encrypt the data before you hidden these.

So, nobody can extract a content from a picture in my quick-aes-256 tool, it is absolutely impossible.
You see only a noise, but nobody can define what this is.
Last edited by walbus on Sun Nov 29, 2015 6:05 pm, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: LSB (Least Significant Bit) File Embedding

Post by JHPJHP »

Hi walbus,

Sorry I'm not sure I fully understand what you're reporting...

Is the application not working with some images?
- if so please post a link to the images in question

Was it an observation that hidden data using this method of steganography is less secure without encryption?
- adding encryption and a wider method of embedding (encompassing the entire image) would be fairly simple

There are many steganalysis tools that indicate an image may contain hidden data in the LSB (Least Significant Bit), but my intention was to demonstrate a basic version of security through obscurity. To be honest I was watching an episode of Blindspot where steganography was mentioned and decided to try it myself.
Last edited by JHPJHP on Sat Nov 21, 2015 11:38 pm, edited 1 time in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: LSB (Least Significant Bit) File Embedding

Post by JHPJHP »

Updated: added the option of embedding multiple files into a single image.
- display image is now updated to match changes to the imbedded image (useful for noticing distortions)

Included is a TrackBar Gadget that allows you to change the bit-section you want to store the file into.
- also used to select the file you want to extract

You'll notice the deeper you move up the bit-latter the more noticeable the embedding.
- try adding an embedded file to bit position 7 to see the full (distortion) effect

NB*: Update also includes numerous changes and improvements.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: LSB (Least Significant Bit) File Embedding

Post by JHPJHP »

Updated:
- added compression to the embedded file (both original and compressed file sizes are displayed)
- spread out the embedded pixels to the entire image
- added a context menu (right-mouse-click image to open)
- added a "Reset Image" button to remove recently embedded information
- added a bit indicator showing used and current bits
- optimized and improved the main algorithms

* Previously an embedded file name was truncated to 48 characters, but has been reduced to 24 characters.

One of the biggest changes to the code from the previous version is a fix to the amount of space available to embed information.
- previously only 20% of an images space was available, restricting the allowed size of an embedded file
- the addition of compression allows for larger embedded files and better security against steganalysis tools

Using the context menu or double-clicking the image opens it in the default viewer allowing for closer examination.
- the image is saved to the temp folder as a JPEG to destroy any embedded information

To better view the spread of pixels embed a file into bit-position 7, then either double-click the image or use the context menu to open it in the default viewer.
- the context menu also includes the functionality of the various buttons
Last edited by JHPJHP on Sun Jan 03, 2016 3:30 am, edited 2 times in total.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: LSB (Least Significant Bit) File Embedding

Post by JHPJHP »

Updated:
- added an additional button / context menu item: Extract All
-- duplicate files will be overridden without warning (does not apply to Extract File)

NB*: Update also includes a fix to the context menu and a few cosmetic changes.
Last edited by JHPJHP on Sun Nov 22, 2015 6:38 pm, edited 1 time in total.
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: LSB (Least Significant Bit) File Embedding

Post by walbus »

It looking now very good.
Except for two things.
The pictures have a start sequence and now a typical moire all over.
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: LSB (Least Significant Bit) File Embedding

Post by JHPJHP »

Hi walbus,

Thank you for your comments and for taking the time to post them.

I see your point about the start sequence, but I believe the amount security is enhanced by a random spread of pixels compared to a uniform spread of pixels is insignificant against a professional steganalysis tool; used largely to determine by percentage if a file contains hidden data, but not what is hidden.
wikipedia.org wrote:...
many simple steganographic systems simply modify the least-significant bit (LSB) of a sample; this causes the modified samples to have not only different noise profiles than unmodified samples, but also for their LSBs to have different noise profiles than could be expected from analysis of their higher-order bits, which will still show some amount of noise.
NB*: My intention is not to create a complete steganography tool, but to provide the forum a method for creating their own.

--------------------------------------------------------------

Updated:
- added encryption to the header information (algorthiums taken from my post: Services, Stuff, and Shellhook)
- fixed some minor issues including various cosmetic changes
- embedded filenames are now truncated to 32 characters
Last edited by JHPJHP on Tue Feb 27, 2018 5:18 am, edited 4 times in total.
walbus
Addict
Addict
Posts: 929
Joined: Sat Mar 02, 2013 9:17 am

Re: LSB (Least Significant Bit) File Embedding

Post by walbus »

Many thanks JHPJHP,
you have maked a very good thing.

You want see patterns or moires, use a simple way.

Make a white picture, now increase the contrast and change the brightness.
Repeat this often.

This is very helpfull for debugging and optimization.

My way is, i make a container.
To time i include one hidden file.
But is it simple for making automatic a ZIP container for including in the picture,
or i use my File Merge function automatic before.

My way is :
I make a empty space, fits of maximum hidding size in the image.
But important, the space for the content with a padding divisible by 16 , minus 16.
I fill the rest with randoms.
Now you always know how big your container is.
Now copy all content in this container.
You can or must now (very simple) including in the container all what you want - Size of content, a hash from the content for a automatic authentication.
Now encrypt this divisible by 16 container with AES.
The litle rest are randoms, it looking same as the container.
Now you have a exactly in your image matching container, consisting only of white noise.
All patterns and moires, headers or extenders are gone.
For decrypt all, now extract simple your container from the picture and make a AES decrypting from it.
Extract then your content from the container (ZIP file or/and all other)
This size is now simple, also the content, including paths and all over.

Best regards Werner
JHPJHP
Addict
Addict
Posts: 2129
Joined: Sat Oct 09, 2010 3:47 am
Contact:

Re: LSB (Least Significant Bit) File Embedding

Post by JHPJHP »

Hi walbus,

Thank you for the information, your methods are very smart.

-------------------------------------------------------

Updated:
- fixed a couple calculations
-- minimum image size is no longer restricted by width / height
-- embedded file spread is more accurately calculated to fill the entire image
-- text area information better represents the available file sizes
Locked