Você está na página 1de 15

A Java Framework for Experimentation with Steganography

Dr. Kenny Hunt The University of Wisconsin La Crosse


1

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

Image Processing and Steganography

the art of concealing the existence of

information within seemingly innocuous digital images


3

Background
(Bit Planes)

An Image is a 2D array of pixels Each pixel (in gray-scale) is 8 bits Each bit carries information

Not all bits carry the same amount


A7 128 A6 64 A5 32 A4 16 A3 8 A2 4 A1 2 A0 1

Binary Representation of 25

A7 0

A6 0

A5 0

A4 1

A3 1

A2 0

A1 0

A0 1

Binary Representation of 153

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

A7 One pixel split into its 8-bits

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

The Big Idea


(LSB embedding)

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

LSBSteganographer +embed(cover:BufferedImage, msg:Object):BufferedImage +extract(stego:BufferedImage):Object +getChannelCapacity():int +setChannelCapacity(channels:int)

Java Framework

Isolate the task of writing/reading data to/from an image


ImageOutputStream extends OutputStream +ImageOutputStream(destination:BufferedImage, numChannels:int) +hasMoreBits():boolean +writeBit(int b) +writeByte(int b) +write(int b)

ImageInputStream extends InputStream +ImageInputStream(source:BufferedImage, numChannels:int) +hasMoreBits():boolean +getNextBit():int +getNextByte():int +read():int

Java Framework

Implement the task of writing to an image

Maintain row, column, band, channel as an insertion point

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

(humor meassume 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); 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

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); 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

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); 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

Assignment given in an Image Processing course

Emphasizes bit-level operations


Could

even give the UML class diagrams

Emphasizes good software design


Could

even give the students low-level code

I give no design or code


Review

the design at the conclusion of the exercise 15

Você também pode gostar