Community Articles

Find and share helpful community-sourced technical articles.
Labels (1)
Super Guru

Use Case

I want to hide text messages inside images. When the images arrive somewhere else, I want to extract those messages.

It let's you hide text in images, binaries in images and images in images.

I was interesting in hiding text messages in images. After seeing's_Spies I thought secret messages were cool.

So using the library, I take an image and text and hide the text in there. The library produces a new image (PNG) that has the message in it. I have a second script that extracts the text.

The images look the same to my eyes.

A future test would be to run a deep learning library or image analysis tool on the images to see if they spot the bits. They should be able to. A future NiFi tool would be to spot hidden images.

It's a fun exercise to use NiFi and it seems possible that encoding messages in images were passing through Niagra Files back in the NSA days.


Step 1: Hide Text (ExecuteStreamCommand)



Step 2: Fetch File


Step 3: UnHide Text (ExecuteStreamCommand)



The left image is the original image and the right PNG is the output image with text. The size on disk has increased at a noticeable level.


The python source code is in github and referenced below:

wget $1 -O img.jpg
python img.jpg "$2"

import cv
from LSBSteg import LSBSteg

import sys
carrier = cv.LoadImage(imagename)
steg = LSBSteg(carrier)
steg.saveImage(imagename + ".png") 

#Image that contain datas

python $1

import cv
from LSBSteg import LSBSteg
import sysimagename=sys.argv[1]
im = cv.LoadImage(imagename)steg = LSBSteg(im)
print steg.unhideText()

For installation, you need to download LSB-Steganography script.


pip install cv


Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.
Version history
Last update:
‎08-17-2019 01:52 PM
Updated by:
Top Kudoed Authors