• Stars
    star
    879
  • Rank 51,943 (Top 2 %)
  • Language
    Python
  • License
    Other
  • Created over 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python program to steganography files into images using the Least Significant Bit.

LSB-Steganography

Python program based on stegonographical methods to hide files in images using the Least Significant Bit technique.

I used the most basic method which is the least significant bit. A colour pixel is composed of red, green and blue, encoded on one byte. The idea is to store information in the first bit of every pixel's RGB component. In the worst case, the decimal value is different by one which is not visible to the human eye. In practice, if you don't have space to store all of your data in the first bit of every pixel you should start using the second bit, and so on. You have to keep in mind that the more your store data in an image, the more it can be detected.

Information

LSBSteg module is based on OpenCV to hide data in images. It uses the first bit of every pixel, and every colour of an image. The code is quite simple to understand; If every first bit has been used, the module starts using the second bit, so the larger the data, the more the image is altered. The program can hide all of the data if there is enough space in the image. The main functions are:

  • encode_text: You provide a string and the program hides it
  • encode_image: You provide an OpenCV image and the method iterates for every pixel in order to hide them. A good practice is to have a carrier 8 times bigger than the image to hide (so that each pixel will be put only in the first bit).
  • encode_binary: You provide a binary file to hide; This method can obfuscate any kind of file.

Only images without compression are supported, namely not JPEG as LSB bits might get tampered during the compression phase.

Installation

This tool only require OpenCV and its dependencies.

pip install -r requirements.txt

Usage

LSBSteg.py

Usage:
  LSBSteg.py encode -i <input> -o <output> -f <file>
  LSBSteg.py decode -i <input> -o <output>

Options:
  -h, --help                Show this help
  --version                 Show the version
  -f,--file=<file>          File to hide
  -i,--in=<input>           Input image (carrier)
  -o,--out=<output>         Output image (or extracted file)

Python module

Text encoding:

#encoding
steg = LSBSteg(cv2.imread("my_image.png"))
img_encoded = steg.encode_text("my message")
cv2.imwrite("my_new_image.png", img_encoded)

#decoding
im = cv2.imread("my_new_image.png")
steg = LSBSteg(im)
print("Text value:",steg.decode_text())

Image steganography:

#encoding
steg = LSBSteg(cv2.imread("carrier.png")
new_im = steg.encode_image(cv2.imread("secret_image.jpg"))
cv2.imwrite("new_image.png", new_im)

#decoding
steg = LSBSteg("new_image.png")
orig_im = steg.decode_image()
cv.SaveImage("recovered.png", orig_im)

Binary steganography:

#encoding
steg = LSBSteg(cv2.imread("carrier.png"))
data = open("my_data.bin", "rb").read()
new_img = steg.encode_binary(data)
cv2.imwrite("new_image.png", new_img)

#decoding
steg = LSBSteg(cv2.imread("new_image.png"))
binary = steg.decode_binary()
with open("recovered.bin", "rb") as f:
    f.write(data)
    

License

This software is MIT-Licensed.

More Repositories

1

Motion-detection-OpenCV

Python/OpenCV script that detect motion on webcam and allow record it to a file
Python
256
star
2

Pytesser

Python wrapper for the tesseract OCR engine. The module is based on OpenCV
Python
178
star
3

idasec

IDA plugin for reverse-engineering and dynamic interactions with the Binsec platform
Python
115
star
4

pydes

Basic but pure DES implementation in Python
Python
67
star
5

pyADS

Python module to manipulate NTFS Alternate Data Stream (ADS) in Python
Python
55
star
6

Captcha-basic-recognition

Python module that intent to crack basic captcha engines using OpenCV and Pytesser
Python
39
star
7

OpenCV-tutorials

Contain the hole source code of my OpenCV tutorial
Python
33
star
8

pystack

Pystack, is a python framework that allow to create small TCP/IP stacks in an easy manner in order to obtain a wanted behavior.
Python
27
star
9

checksec

Bash script to test executable properties like (PIE, RELRO, PaX, Canaries, ASLR). (Version derivated from the original one trapkit.de/tools/checksec.html
Shell
20
star
10

Python-programs

Contains various python programs and proof of concept.
Python
10
star
11

pytts

Text-To-Speech multi-platform in python. It uses Google translate as engine.
Python
8
star
12

breach_compilation_utils

BreachCompilation utils for iterating logins and passwords
Python
5
star
13

lsbbrute

Script to bruteforce the LSB of an image to find file signatures (in every channel permutation, rotation etc..)
Python
5
star
14

pydimacs

Python module to manipulate CNF DIMACS formulas (using z3)
Python
4
star
15

LyricsTagger

Python program, that automaticaly tag lyrics in MP3 files.
Python
3
star
16

Cryptoid

ryptoid is a toy app to apply weak ciphers on plain text. (Mostly developped to learn how to develop an app).
Java
2
star
17

RobinDavid.github.io

My Github pages
HTML
2
star
18

Python-samples

Contains few python scripts for everything and nothing
Python
2
star
19

Bash-network-game

This project is a fully working 2 player network game written in bash. It intents to show the possibilities of bash which is not a simple script program.
Shell
2
star
20

RobinDavid

1
star
21

codeql-uboot

CodeQL
1
star