Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simple C++ Image Steganography tool to encrypt and hide files inside images using Least-Significant-Bit encoding.

License

NotificationsYou must be signed in to change notification settings

7thSamurai/steganography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple C++Encryption andSteganography tool that uses Password-Protected-Encryption to secure a file's contents, and then proceeds to embed itinsde an image's pixel-data using Least-Significant-Bit encoding. For Linux, MacOS, and Windows systems.

Encoding

$ ./steganography encode -i data/orig.png -e data/jekyll_and_hyde.zip -o output.pngPassword: 1234* Image size: 640x426 pixels* Encoding level: Low (Default)* Max embed size: 132.38 KiB* Embed size: 61.77 KiB* Encrypted embed size: 61.78 KiB* Generated CRC32 checksum* Generated encryption key with PBKDF2-HMAC-SHA-256 (20000 rounds)* Encrypted embed with AES-256-CBC* Embedded jekyll_and_hyde.zip into image* Sucessfully wrote to output.png

Original image:

Original image

Image with embedded ZIP containg the entire contents of the book "Dr Jekyll and Mr Hyde":

Image with embed

Decoding

$ ./steganography decode -i output.png -o "out - jekyll_and_hyde.zip"Password: 1234* Image size: 640x426 pixels* Generated decryption key with PBKDF2-HMAC-SHA-256 (20000 rounds)* Sucessfully decrypted header* File signatures match* Detected embed jekyll_and_hyde.zip* Encoding level: Low (Default)* Encrypted embed size: 61.78 KiB* Successfully decrypted the embed* Decrypted embed size: 61.77 KiB* CRC32 checksum matches* Successfully wrote to out - jekyll_and_hyde.zip

Building

$ mkdir build$ cd build$ cmake -DCMAKE_BUILD_TYPE=Release ..$ make -j 4

Usage

Usage: steganography [-h] {decode,encode}Optional arguments:  -h, --help   shows help message and exits  -v, --versionprints version information and exitsSubcommands:  decode        Decodes and extracts an embed-file from an image  encode        Encodes an embed-file into an image

Encoding

Usage: encode [-h] --input VAR --output VAR --embed VAR [--passwd VAR]Encodes an embed-file into an imageOptional arguments:  -h, --help   shows help message and exits  -v, --versionprints version information and exits  -i, --input  specify the input image. [required]  -o, --output specify the output image. [required]  -e, --embed  specify the file to embed. [required]  -p, --passwd specify the encryption password.

Decoding

Usage: decode [-h] --input VAR [--output VAR] [--passwd VAR]Decodes and extracts an embed-file from an imageOptional arguments:  -h, --help   shows help message and exits  -v, --versionprints version information and exits  -i, --input  specify the input image. [required]  -o, --output specify the output file. [default: ""]  -p, --passwd specify the encryption password.

Theory Of Operation

Encoding

The program operates by first randomly generating a128-bit Password Salt and a128-bit AES Initialization Vector by reading binary data from/dev/urandom.It then uses thatPassword Salt as a parameter in generating an encryption key, by usingPBKDF2-HMAC-SHA-256 on a user inputted string.ACRC32 hash of the file to embed is then calculated, and stored in the header to act as a checksum for the validity of the data.It then pads the binary data of the file to embed using thePKCS #7 algorithm, followed by actually encrypting both the header andthe padded data, withAES-256 inCBC Mode, using the previously generatedInitialization Vector.Now the data is actually encoded inside the image by first picking a random offset, and then going through each bit of data and storing itinside the actual image pixel data, which it accomplishes by setting theLeast-Significant-Bit of each channel byte of each pixel.

Decoding

The decoding process works exactly the same as the encoding process previously described above, just in reverse.The only difference is that for decoding, after the program attempts to extract and decrypt the data, it compares some of the information in the header sectionin an attempt to validate the extraction process. The header fields which are compared are: The 4 byte file signature custom to this program, and theCRC32 hash of the decrypted data.If any of these fields do not match to their correct values, the decryption process will fail. This should only happen if the file which you were attempting todecrypt does not actually contain an embed, if the password you entered is wrong, or if the image file was somehow corrupted.

Detection

While the detection of data being embedded in an image is a trivial task, theoretically there is no way of knowing that it was this program that did it, and theoreticallythere should be no known way to decrypt the data without knowing the password, that is without spending millions of years in the process of doing so.

Disclaimer

Do not use this program to encrypt and hide important data which you wish to keep away from prying eyes. This is just a simple proof-of-concept program that I made for fun.I'm no cryptographer. I'm just a hobbyist, use at your own risk.

Copyright

This software is licensed under MIT. Copyright © 2022 Zach Collins

About

Simple C++ Image Steganography tool to encrypt and hide files inside images using Least-Significant-Bit encoding.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp