Escolar Documentos
Profissional Documentos
Cultura Documentos
Overview
Definitions Overview of LSB technique Software architecture Discussion Demo
Definitions
Steganography
the art of concealing the existence of information within seemingly innocuous carriers an encrypted message may draw suspicion while a hidden message will not
Neil Johnson
Background
(Bit Planes)
An Image is a 2D array of pixels Each pixel (in gray-scale) is 8 bits Each bit carries information
Binary Representation of 25
A7 0
A6 0
A5 0
A4 1
A3 1
A2 0
A1 0
A0 1
Binary Representation of 24
A7 1
A6 0
A5 0
A4 1
A3 1
A2 0
A1 0
A0 1
A7 0
A6 0
A5 0
A4 1
A3 1
A2 0
A1 0
A0 0
Bit Planes
A0
Background
(Bit Planes)
(a)
(b)
(c)
(d)
White indicates an ON bit and black an OFF bit (a) (b) (c) (d) 8-bit grayscale source image Most significant bit plane (a7) of the source Least significant bit plane (a0) of the source Bit plane a4 of the source image
An image contains more information than can be perceived. Replace the imperceptible bits of a cover image with the bits of a secret message.
Cover Image
The Challenge: Write Java code to LSB embed a secret message in an image. The secret message can be any object.
A7
A6
A5
A4
A3
A2
A1
A0
Secret Message
A7
A6
A5
A4
A3
M2
M1
M0
Stego Image
(Cover image with message)
Java Framework
Design a set of classes to perform LSB embedding Isolate the task of embedding/extracting
<<interface>> Steganographer +embed(cover:BufferedImage, msg:Object):BufferedImage +extract(stego:BufferedImage):Object
Java Framework
Java Framework
class ImageOutpuStream extends OutputStream { private BufferedImage buffer; private int row, col, band, channel, numChannels; // The least significant bit of b is written to the buffer public void writeBit(int b) throws IOException { if(!hasMoreBits()) throw new IOException(Out of capacity); int newPixel = buffer.getRaster().getSample(col,row,band); newPixel = setBit(newPixel, b, channel); buffer.getRaster().setSample(col,row,band,newPixel); advanceIndices(); } }
The writeByte and write methods are then built on the writeBit.
10
Java Framework
public Image embed(BufferedImage cover, Object message) { Image result = cover.copy(); int k = getNumberOfChannels(); OutputStream rOut = new ImageOutputStream(result, k); writeHeaderInformation(message, rout); for every pixel P in message rOut.writeByte(P); return result; }
}
This code writes image data to an OutputStream. Java has code that does this!
11
Java Framework
(assume the message is an image)
class LSBSteganographer implements Steganographer { private int numberOfChannels;
public Image embed(BufferedImage cover, Object message) { Image result = cover.copy(); int k = getNumberOfChannels(); OutputStream rOut = new ImageOutputStream(result, k); ImageIO.write((BufferedImage)message, PNG, rout); return result; } }
Real live honest-to-goodness Java code! What if the message is not an image? Can we embed it in the cover?
12
Java Framework
(assume the message is NOT an image)
Image from http://i33www.ira.uka.de/applets/mocca/images/janus.gif
public Image embed(BufferedImage cover, Object message) { Image result = cover.copy(); int k = getNumberOfChannels(); OutputStream rOut = new ImageOutputStream(result, k); DataOutputStream fout = new DataOutputStream(rOut); fout.writeObject(message); return result; }
}
Real live honest-to-goodness Java code! The contract for writeObject is that the written object be Serializable. BufferedImages are not. Therefore, must make a specific exception for image types.
13
Java Framework
(make no assumptions!)
Image from http://i33www.ira.uka.de/applets/mocca/images/janus.gif
public Image embed(BufferedImage cover, Object message) { Image result = cover.copy(); int k = getNumberOfChannels(); OutputStream rOut = new ImageOutputStream(result, k); if(message instanceof Serializable) { DataOutputStream fout = new DataOutputStream(rOut); fout.writeObject(message); } else if(message instanceof BufferedImage) { ImageIO.write(message, PNG, rout); } else throw new IllegalArgumentException(); return result; }
}
14
Classroom Use