Search code examples
hidesteganography

hide tar file in png


Can I simply embed tar file inside png image? I`m tried cat file.tar image.png > secret.png, but this not working for me. does have anybody working example? it would be preferable in ruby or python


Solution

  • If you want security - Encrypt the data first!

    If you just want to bundle additional files with images and you don't care if people who can view the image can also access the files then this doesn't apply to you.

    However, it's somewhat trivial to recover ordered data from an image using image processing techniques. What you're encoding in the image should have the following properties to keep you safe and to be difficult to discover:

    1. Be cryptographically secure
    2. Be indistinguishable from random noise (see 1.)
    3. Be large enough that all the pixel of the image carry the encrypted data

    The reason we do the last one is because it is very easy to detect if the encoded data stops half way down the image. You'll have an image where half has higher noise, and half doesn't. In some cases, this is visible to the naked eye, let alone to someone who knows what they're doing.

    I don't know if the following libraries do all this. Rely on them at your own risk.

    In any case, the original image should not be widely available. It's very easy to recover the data using the difference between the original and the steganographic image.

    As of August 2024

    You can use the stegify library and command line tool to hide data in an image:

    stegify encode --carrier image.png --data file.tar --result steg.png
    
    stegify decode --carrier steg.png --result file.tar
    

    Legacy Answer

    You can use the stepic library.

    It will do what you want out of the box:

     stepic --encode --image-in=plain.png --data-in=data.tar --out=secret.png
    

    to decode:

     stepic --decode --image-in=secret.png --out=data.tar
    

    You can download and install from the stepic webpage