Coder Social home page Coder Social logo

guywilson / cloak Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 2.36 MB

Hide a file inside an RGB bitmap or PNG image

License: MIT License

Makefile 1.71% C 97.95% Shell 0.34%
bitmap c cryptography png steganography gtk4 aes aes-256 encryption one-time-pad

cloak's Introduction

Cloak

A new version of Cloak, re-engineered from the bottom up.

Hide and extract an encrypted file within an RGB (24-bit) bitmap or PNG image.

The idea is simple, a 24-bit colour bitmap or PNG image uses 3 bytes for each pixel in the image, one each for Red, Green and Blue, so each colour channel is represented by a value between 0 - 255. If we encode a file in the least significant bits (LSBs) of the image data, there will be no visible difference in the image when displayed. At an encoding depth of 1-bit per byte, we need 8 bytes of image data to encode 1 byte of our file.

Cloak can encrypt your 'secret' data file using either the AES-256 (Rijndael) cipher (in CBC mode) or XOR encryption prior to encoding it in your chosen image. With AES encryption, you will be prompted to enter a password (max 256 chars), the SHA-256 hash of which is used as the key for the pass through AES. With XOR encryption, you must either supply a keystream file using the -k option, or specify the --generate-otp option to create the random keystream file specified with -k. The OTP generate function uses the /dev/urandom device on *nix systems.

With XOR encryption, the advantage of this mechanism is you can employ a one-time-pad scheme, which providing you stick to the rules for a one-time-pad encryption scheme, is mathematically proven to be unbreakable.

The rules are:

  1. The key is truly random
  2. The key is used once and only once
  3. The key is at least as long as the file being encrypted

Of course, any encryption scheme is useless if some third party has got hold of your encryption key.

Some tips regarding password strength

A good password is one that cannot be broken using a dictionary attack, e.g. don't use a word from the dictionary or a derivation of. Use a made-up word or phrase with symbols and numbers, better still a random string of characters. In the context of this software, an important aspect is getting the password or keystream to your intended audience securely. It is also imperative that you do not re-use a key, it may be prudent to agree a unique and random set of keys with your audience in advance.

References:

https://en.wikipedia.org/wiki/Dictionary_attack

https://en.wikipedia.org/wiki/Password_strength

https://www.random.org/

Building Cloak

Cloak is written in C and I have provided a makefile for Unix/Linux using the gcc compiler (tested on Mac OS). Cloak depends on the 3rd party libraries libpng (http://libpng.org), libgcrypt (https://www.gnupg.org/software/libgcrypt/index.html) (for the encryption and hashing algorithms, part of GPG), and Gtk4 (for the GUI if built).

Build cloak using the supplied build script, e.g. on Linux/macOs

buildit [to build the command-line only version]

buildit --gui [to build the GUI version]

Using Cloak

Type cloak --help to get help on the command line parameters:

Using cloak:
    cloak --help (show this help)
    cloak [options] source-image
    options: -o [output file]
             -f [input file to cloak]
             -k [keystream file for one-time pad encryption]
             -s report image capacity then exit
             --merge-quality=value where value is:
                       'high', 'medium', or 'low'
             --algo=value where value is:
                    'aes' for AES-256 encryption (prompt for password),
                    'xor' for one-time pad encryption (-k is mandatory),
                    'none' for no encryption (hide only)
             --generate-otp save OTP key to file specified with -k
             --gui launch app on startup, all other arguments ignored
             --test=n where n is between 1 and 18 to run the numbered test case

cloak --gui starts the Gtk GUI image

flowers_out.png

I have included a sample PNG file with this distribution - flowers_out.png which has the LICENSE encoded within it, the password used to encrypt the file is 'password', however you should use a strong password in real-world applications, see the tips on password strength above.

For example, to 'cloak' a file within flowers.png I used the following command:

cloak -f LICENSE --merge-quality=high --algo=aes -o flowers_out.png flowers.png

This tells cloak to use merge the file 'LICENSE' into the image 'flowers.png' and output the new image 'flowers_out.png' using an encoding depth of 1-bit per byte.

To 'uncloak' the file from flowers_out.png, you can use the following command:

cloak --merge-quality=high --algo=aes -o LICENSE.out flowers_out.png

This tells Cloak to use extract mode to extract the file 'LICENSE.out' from the input image 'flowers_out.png', again using 1-bit per byte.

Have fun!

cloak's People

Contributors

guywilson avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.