Professional Documents
Culture Documents
Thesis Collection
1996-03
THESIS
IMPLEMENTATION AND EFFICIENCY OF STEGANOGRAPHIC TECHNIQUES IN BITMAPPED IMAGES AND
EMBEDDED DATA SURVIVABILITY AGAINST LOSSY
COMPRESSION SCHEMES
by
Daniel L. Currie,
III
Hannelore Campbell
March 1996
Thesis Advisors:
Approved
Thesis
C9565
Cynthia E. Irvine
Harold Fredricksen
is
unlimited.
Form Approved
is
estimated to average
OMB No.
0704-0188
hour per response, including the time reviewing instructors searching existing data sources
gathering and maintaining the data needed, and completing and reviewing the collection of information
Send comments regarding this burden estimate or any other aspect of this
Washington Headquarters Services Directorate for Information Operations and Reports 1215 Jefferson
the Office of Management and Budget. Paperwork Reduction Project (07040188) Washington DC 20503
VA 22202-4302. and to
2.
burden
to
REPORT DATE
3.
March 1996
TITLE
4.
AND SUBTITLE
5.
FUNDING NUMBERS
AUTHOR(S)
6.
Currie, Daniel
III
Campbell, Hannelore
PERFORMING ORGANIZATION NAME(S) AND ADDRESS(ES)
7.
8.
9.
PERFORMING ORGANIZATION
REPORT NUMBER
CA 93943-5000
10.
SPONSORING/ MONITORING
11.
SUPPLEMENTARY NOTES
The views expressed in this thesis are those of the authors and do not
of the Department of Defense or the United States Government.
12a.
12b.
Approved
13.
ABSTRACT (Maximum
is
DISTRIBUTION CODE
unlimited.
200 words)
its
in
images
is
least significant
of the pixel bytes with the data to be embedded. Since images are frequently compressed for storage
or transmission,
it
is
Group (JPEG) compression algorithm, while producing only a small amount of visual distortion, introduces a relatively large number of errors in the bitmap data. These errors will effectively garble any noncoded steganographically embedded data, (continued on reverse)
14.
SUBJECT TERMS
15.
NUMBER OF PAGES
16.
PRICE CODE
20.
LIMITATION OF ABSTRACT
17.
SECURITY CLASSIFICATION
OF REPORT
"Unclassified
NSN 7540-01-280-5500
18.
SECURITY CLASSIFICATION
OF THIS PAGE
Unclassified
19.
SECURITY CLASSIFICATION
OF ABSTRACT
Unclassified
UL
Standard Form 298 (Rev 2-89)
Prescribed bv ANSI Sid 239-18
Block
13 continued:
that,
although there are numerous protocols for embedding data within pixels,
is always the number of bits modified in each pixel. A balance must be found between
amount of data embedded and the amount of acceptable distortion. This thesis also demonstrates that,
despite errors caused by compression, information can be encoded into pixel data so that it is recoverable
after
Standard
Form
298, (Reverse)
Approved
is
unlimited
IMPLEMENTATION AND EFFICIENCY OF STEGANOGRAPHIC TECHNIQUES IN BITMAPPED IMAGES AND EMBEDDED DATA SURVIVABILITY
AGAINST LOSSY COMPRESSION SCHEMES
Daniel L. Currie HI
Lieutenant, United States
B.S.,
West Virginia
Navy
and
Hannelore Campbell
Lieutenant, United States
B.S.,
Navy
Submitted
in partial fulfillment
of the
'
KNOX LIBRARY
3TGRADU
!EY CA 91
ABSTRACT
The term steganography
is
communicate
by embedding a secret message within an overt message. Such techniques can be used
hide data within digital images with
little
or
no
change
visible
in the
to
perceived appearance
of the image and can be exploited to covertly export sensitive information This thesis
explores the data capacity of bitmapped image files and the feasibility of devising a coding technique which can protect
com-
pression.
In its simplest form, steganography in
least significant bits
images
is
of the pixel bytes with the data to be embedded. Since images are
it is
fre-
nique include some form of redundancy coding to counter the errors caused by lossy
compression algorithms. Specifically, the Joint Photographic Expert Group (JPEG) compression algorithm, while producing only a small
relatively large
number of
amount of visual
that,
These errors
distortion, introduces a
will effectively garble
data.
is
bits
modified
in
each pixel.
balance must be found between the amount of data embedded and the amount of acceptable distortion. This thesis also demonstrates that, despite errors caused by compression,
it is
recoverable after
JPEG
processing,
ool
VI
TABLE OF CONTENTS
I.
INTRODUCTION
WHAT IS STEGANOGRAPHY?
B
PUBLISHED WORK ON STEGANOGRAPHY
C
USES OF STEGANOGRAPHY
A.
1.
1
1
Subliminal Communication
2.
Integrity
3.
Illicit
and Authentication
Exfiltration
n.
SCOPE OF THESIS
STEGANOGRAPHIC TECHNIQUES
A
WRAPPER FILES
B
IMAGE STORAGE
PROTOCOL EVENT SELECTION
C.
D.
MESSAGE LOCATION
E
COMPARISON-BASED BIT INSERTION PROTOCOLS
VI
10
[10]
Bit Inversion
12
13
3.
Bit Deletion
14
4.
Flag Bit
15
5.
Threshold Bits
15
16
17
17
Pixel Structure
2.
3.
10
Bit Insertion
A.
2.
1.
IV
1.
2.
HI
19
19
19
19
20
20
23
25
25
25
1.
Effects on Pixels
26
27
2.
Error Distribution
28
E
AN EFFECTIVE CODING SCHEME
DISCUSSION AND CONCLUSIONS
STEGANOGRAPHY FOR ILLICIT EXFILTRATION
A
STEGANOGRAPHIC APPLICATIONS
B
29
31
33
33
34
35
AN UNEXPLORED DISCIPLINE
35
1.
35
2.
How Widespread
36
4.
Use of Steganography?
Steganography on the World Wide Web
Steganography in Printed Media
5.
36
37
39
3.
is
the
REFERENCES
APPENDIX: SOURCE CODE
A
GENERIC STEGO EMBEDDING PROGRAM
B
GENERIC STEGO EXTRACTION PROGRAM
IMAGE FILE COMPARISON PROGRAM
C
D
RGB VECTOR ENCODING STEGO PROGRAM
RGB VECTOR STEGO EXTRACTION PROGRAM
E
F.
STEGO FUNCTIONS HEADER FILE
LIST OF
36
36
39
45
56
61
68
72
77
Vlll
I.
A.
INTRODUCTION
WHAT IS STEGANOGRAPHY?
Steganography
communication
is
is
closely
related
to
is
cryptography.
secret,
where
Unlike cryptography
steganography
is
It
simple modification of English text by modulating active and passive voices to utilizing the
least significant bits in digital
image pixels
to unobtrusively
necessarily cause
original data.
The key
hidden data
or one
who
is
does
some
data
by the
there
is
not.
in
made
additional information
has been
embed
in secret
[7].
communications,
Although
in the
it
who
been building,
in the
B.
PUBLISHED
WORK ON STEGANOGRAPHY
search of the literature on and relating to steganography yields very few works
offshoot of cryptography.
It
is
its
own
right This is
probably because, until the advent of high volume/high speed data communications, the
threat of covert
communication was
bandwidth
One of the
known published
earliest
"Steganographia"
by
where
Trithemius
Trithemius.
is
treatises
certain letters in
the
"Ave Maria"
to
surrounding
200 years
it
it
caused
it
it
be banned
to
be an ordinary prayer
its
that
when
[7],
1609 by the
text.
in
volume
vowel-consonant
simple
described
six
in
until
Roman
was the
subject
Not
become recognized
as a significant
Kahn
More
When
move
and
data
is
chess boards,
etc.
huge increase
declassified or
downgraded, there
domain
is
of
a threat of covert
to another. In [9]
War
Kurak
images and
it.
and
is
Channel
the Subliminal
Simmons
[12].
is
the subject of
Although referred to as
is
a risk of spoofing.
C.
USES OF STEGANOGRAPHY
Steganography
policy,
security
employment:
exfiltration
subliminal
of data.
malicious or
is
integrity
and
and
authentication,
illicit
It is
We
illicit.
communication,
of steganography
classes
being transmitted.
Dlicit exfiltration,
is
is
not necessarily
communicated information
a deliberate violation of a
security policy.
Subliminal Communication
1.
is
covert channel
is
one
in
channels
is
it is
may be
virtually
[5],
steganographic channel
is distinct
from a covert
Some methods
of
Modulating word or
Using the
first letter
document
letter
of the message
Using the
Integrity
Integrity
in a digitized
(LSB) of each
sound
image
file
file
and Authentication
of data
is
another
important
aspect
pixel in an
of computer
seal within
bit
an image
system
file in
security
such a
way
authentication and tamper-proofing of the image. Steganography has the advantage that the
is
removed
integrity
of image
files.
This method employs an algorithm which visits certain, randomly chosen pixels, modifying
them
to
visited.
tell if
seal
key
is
This "random walk" sealing method ensures integrity since "...an interloper cannot
way of finding
the unchanged
possible seals."
all
way
to tag a file without lengthening the file or subjecting the tag to possible alteration or
removal.
AT&T
postscript files
were used
to
encode a
serial
in
rely
[2]
on protecting the steganographic method and any keys used to encrypt the hidden
two
spacing in
A successful
in line
files
3.
file
file.
file,
care must be
Dlicit Exfiltration
it
of
illicit
exfiltration
embed
of data, steganography
is
user can
embedded within
data.
It is
downgraded from
an environment where
expects to be downgraded.
in
wrapper
file
The malicious
domain
file is
moved
D.
SCOPE OF THESIS
This thesis
is
steganographic techniques and their efficiency, and to investigate the feasibility of devising
a robust form of steganography that can survive lossy compression.
highlight
the
threat
of steganography
to
system
security
Our
and
ultimate goal
to
is
demonstrate
to
image
storage, processing,
relies
on a trusted
STEGANOGRAPHIC TECHNIQUES
II.
WRAPPER FILES
A.
wrapper
is
the
medium
into
is
embedded. As with
encryption, steganography can be performed on a block of data or on a data stream. For the
we
will
commonly used
in
computer systems. Each type of file has characteristics which must be taken into account
when devising
stored with
is
a far greater accuracy than necessary for the data's use and display are suitable for
files are
among
those which
fall
into this
bits
file.
limits to steganography
file,
such as the
can be subtly modified to hide data. These techniques yield a low bandwidth, but are useful
for
common and
human
be
provide an ideal
medium
a small
in applications,
for steganography.
sound
Due
files are
relatively large to
much more
would have
to
unmodified sound
files in
Consequently, a sound
file
can hold a
much
larger
in a text
file.
By
far the
number of
suitable
applications.
wrapper
files are
As with sound
made without
image
files,
detection
files.
image
Image
files
files
have a
B.
IMAGE STORAGE
The format
in
bit
value of
bi-level
or
0.
is
application.
either
The
on or off
each pixel, allowing 256 shades of gray per pixel. Using 24 bits for a pixel to encode a color
value yields an even more accurate and realistic image. Clearly any
pixel
encoding schemes can be used to provide any desired level of detail. In general, as the
number of
bits
Due
case a pixel)
wrapper increases.
images are
difficult to utilize as
wrapper
files.
A steganographic technique would introduce noise into the image which would likely cause
noticeable degradation. This effect
is
Grey scale images are much more suitable for hiding messages. Altering the low order
bit
of the eight bits used to represent a pixel causes only a 1/256, or 0.39%, change in the
low order
bits
induces
at
is
undetectable by the
differs
into the
wrapper
file,
bit.
embedded
human
scenario.
When
message
bit is
The likelihood
be changed
it
is 0.5.
embedding n
Therefore,
wrapper
file.
Original
Oil
1|0
Oil
Wrapper
Pixels
Pixel
Message
Pixel 2
Pixel 3
|i|o|l|l|l
Bits
Transmitted
Steganographed
Pixels
Pixel
Figure
Figure
of 8
1:
demonstrates
bit pixels
how
bits. In
into a
wrapper
file
composed
embedded
Pixel 3
Pixel 2
its
the
first
pixel only
two
the
bits are
bits
therefore no change
was
bits,
made.
Color images, specifically 24
bit color
extrapolate from the above example and see that a 24 bit pixel
on
this type
is
easily
capable of holding
much
in a
24
bit color
image
file
will
be
investigated.
C.
When
the
PES
is
known
purposes,
height.
must be a protocol
bits will
image
be
files
it
numbered from
can
It
is
be
to
W*H, where
defined
as
file
it
mod
is
mathematical
selects
equal to
linear
function
to
arrangement of
image and
embed
the desired
[14].
may be designed
it is
H is the
Any
function
number of bits.
is
(i.e.
enough pixels
viewed as a
is
is
there
pixels
file
map
of the
so as to produce a pseudo-random
generated, must not visit the
same
pixel twice.
When
provision must be
made
for
PES method
is
in the
any key error would make complete recovery of the embedded data nearly impossible.
D.
MESSAGE LOCATION
Once
will
PES method
is
10
entire
is
used
in order to
the perceived distortion of the image. Nevertheless, there are several techniques and
human
eye.
is to
way
hidden data
to
is
naturally drawn.
is
that
in
it is
an area where
is
it
is
unlikely
will
be drawn to
by a steganographic
the texture, or "busy-
ness," of different areas of the picture. For example, in a photograph of a forest with clear
blue sky overhead, distortion would be more easily detected in the sky area than in the
forest area.
it is
hidden data to counter the effects of errors introduced into the image
file.
Figure 2 shows
Figure
2:
Incorporating redundancy
in
this
way
E.
the entire
image
file is
actual insinuation of
message
bits
errors
not available.
PES
when
It
against
[10]
11
message
bit in the
Having selected an
file.
bit or its
near the insertion point. Inserting message bits between wrapper bits has the effect of
shifting
all
the wrapper bits after the insertion point. This will cause undesirable effects in
(i.e.
the
files.
image
Specifically, if bits in an
image
without regard
file is
of discrete pixels) then insertion of a few bits will essentially randomize the image.
Bit Inversion
1.
The
bit is
Likewise,
if the
message
specially selected to
is
bit is
and
bit. If
is
1.
Message
1
Bits
Original
1
Insertion
Insertion
Insertion
Point
Point
Point
10;
1;
N
1
10
Wrapper
Pixels
Pixel
Pixel 2
Pixel 3
Transmitted
Steganographed
Pixels
l|l
Pixel
Figure
3:
Pixel 2
Bit Inversion
12
the message
Pixel 3
bit.
This technique requires that the original wrapper be compared to the stegotext to
recover the message.
When comparing
the
files,
every differing
and
bit
its
value
is
noted
Bit Insertion
2.
The
message
is
bit
The
bit.
Message
Bits
Insertion
Insertion
Insertion
Point
Point
Point
4
Original
10
liO
lffljl
Wrapper
Pixel
Pixels
Transmitted
Steganographed
Pixels
Pixel
Figure
The message
where
a bit differs
when
the
is
Pixel 2
10
Pixel 3
11
110
Pixel 3
Pixel 2
Bit Insertion
and
message
4:
its
alignment.
13
is
inserted in the
must be
wrapper so
3.
Bit Deletion
on the message
bit.
If a
deleted. Similarly if a
is
to
is
to
be inserted, a 01 pair
is
is
of the pair
of the pair
is
is
deleted.
Message
Bits
Original
1
Insertion
Insertion
Insertion
Point
Point
Point
ijo[i!
Wrapper
Pixels
Transmitted
Steganographed
Pixels
Pixel
Pixel
Figure
is
5:
Pixel 2
100
11
1
100 jmoil
Pixel 3
iolo
Pixel 2
00
1:1
Pixel 3
Bit Deletion
14
4.
Flag Bit
With
this technique, a
wrapper
bit
bit is inverted
selected.
is
The
bit
bit.
Message
1
Bits
Original
110
Wrapper
Pixels
Pixel
Pixel 2
Pixel 3
Flag
Flag
Flag
Bit
Bit
Bit
4/
Transmitted
Steganographed
after
is
Pixel 3
Flat Bit
failure.
Threshold Bits
however a
6:
Pixel 2
no
extracted by comparing the wrapper to the stegotext and noting the bit
each comparison
5.
0:0
Pixel
Figure
The message
A/
111
Pixels
bit protocol,
certain
an inverted
odd number n of
bit.
bits,
message
If the
number of
15
l's in the
n bits
is
bit.
In this case
bit are
used to
bit is 0.
the
message
bit is
1.
more
Message
1
Bits
Original
1
Insertion
Insertion
Insertion
Point
Point
Point
10
100
Wrapper
Pixels
Pixel
Transmitted
Steganographed
wrapper
file
Flag
Bit
Bit
10
100
Pixel 2
0|1
Pixel 3
Flag
10
11101
Pixel 3
3)
7:
Threshold Bits
entirely different
mentioned
file.
embed
image
is
is
to
bit.
is
way
for the
stegotext. This
earlier.
Frequently,
wrapper
message. This
to extract the
to
Oil
is
10
Bit
Figure
F.
Pixel 2
Pixel
100
Flag
Pixels
(note: n
0J1
it
is
For example,
in
classified data in an
comparison
in
file is
to be
no longer available
16
it is
when designing
to
be used for
a steganographic
application
original
1.
it is
preferable to use a protocol which does not rely on the availability of the
wrapper
file.
The following
are
protocol
2.
was demonstrated
Figure
in
is
bit
This
1.
Neighbor Parity
As with
discussed
bit to
protocol
this
earlier,
examines n
Message
01
Bits
Insertion
Insertion
Insertion
Point
Point
Point
Original
1
10 0l|l
oil
Wrapper
Pixels
Pixel
Pixel 2
Transmitted
Steganographed
this
requires the
8:
Pixel 2
PES
1 1
Pixel 3
Neighbor Parity
3)
Figure
For
Pixel
A/
>V
....
Pixels
(note: n
Pixel 3
will
0.
be represented
1.
17
and sometimes
18
III.
A.
The
be hidden
in
it is
number of data
image
file
bits per
image
where
(W
in
bytes
embedded per
in pixels
is:
D)
and
the
number of data
bits
pixel.
THEORETICAL LIMITS
B.
As described above,
the
file
turn,
at
which data
is
is
dependent only
is,
in
in the next
section.
From
the point of
stored can be
is
a stream
of bytes There
is
embedded
in a
total
C.
PERCEPTUAL LIMITS
In deciding
to
strike a
image. Increasing the data density increases the amount of degradation. The trick
the data density threshold at
which influence
that the
the image, and the hidden data location within the image.
19
is
in
an
to find
image
is
and texture of
Pixel Structure
1.
In
color
any image
256
common
in
file to
map
colors, a color
is
necessary to
is
bits
per pixel,
some provision
to the necessity
most
file
bit
for a
is
due
map
the
256 colors
colors.
Any
attempt to
embed
data in an 8 bit pixel value will result in that pixel value pointing
the result of
pixel value
24
bit
image
is
file
format
it is
map
is ideal
due to two
file is
of the pixel
24
making
[3],
bit pixel is
colors
a noticeable change in
bits,
an 8 bit image
in the color
distinguish a large
may be 24
in
benefit of a reference
bits
color
24
composed of three
is
map.
mapped
internally to 4, 8, or
16 bits for the display. Further, every monitor will have small differences in color
saturation, brightness, contrast, etc.
2.
The
image
itself is
when
applying a steganographic technique. The overall variety of colors, shapes, and textures and
their relative sizes
example,
9,
in
Figure
the seagull
is
is
data.
composed of only
For
few
shades of blue. Color distortion introduced in this mostly blue field will appear as specks
20
of darker or lighter blue, or even a different color, which contrasts with the blue around
as seen in Figure 10. (Distortion has been enhanced for illustration
Figure
9: Seagull,
730x480, 24
it
contains
many
and textures
21
is
very busy,
Figure
but
1 1
it is
and Figure
much
12.
Figures
less visible in
[ 1
0]
and
[ 1
2] contain the
detail.
This
is
demonstrated
Figure 12.
in
..'
'
:'.
'
22
in
data,
3.
where
maximum amount
is
of data
is
portion of the image which has not be tampered with. In Figure 10 the hidden data
is
A solution to this
problem
is to
compute
n,
the
number of bytes
data.
in the
Then,
image divided
in the
embedding
algorithm, use every nth image byte. This will spread the hidden data over the entire image,
reducing
its
detectability.
a significant improvement.
23
13; clearly,
24
IV.
A.
result
of some
form of processing Images can be compressed using lossy compression techniques, can be
digitally
enhanced, or they can have other images or graphics overlaid on them. All forms
message
survivability,
message
bits
correction
is
necessary.
two sections we
will
examine the
loss caused
To enhance
is
lossy compression In
compensate for
it
[6]
B.
JPEG COMPRESSION
The JPEG compression standard has been developed
compression
tools.
JPEG
has four
coder/decoder which
JPEG works
is
Most
is
to support a variety of
sufficient for
many
applications. [13]
into a luminance/
downsampled
is
human eye
more
sensitive to
is
it is
to
is
to
much
values are grouped into 8x8 blocks which are transformed using the discrete cosine
transform (DCT).
The
DCT
map which
contains coefficients
representing the average value in the block and successively higher-frequency changes
within the block. Each block then has
its
25
is
loss caused
by
JPEG
occurs.
Many
zero. This is acceptable since the higher frequency data that is lost will
change
visually detectable
Huffman coding
in
C.
in the
little
The
final step
before,
embedding data
embedded data
it is
produce very
first
it
image
predict mathematically
DCT
To
to ensure survivability of
JPEG
causes in an
occurs.
it
is
in the
of image pixels
may seem
be to look
to
where changes
at
the original
to
pixels will
occur.
This
is
basis signal amplitudes. This has the effect of spatially "smearing" the pixel bits so that the
is
spread over
all
Because of the
it
is
not
feasible to trace the bits through the compression algorithm and predict their location in the
compressed
Due
data.
to the
complexity of the
To
JPEG
The
BMP
file
file
its
Windows
saved under a
its
new
filename.
image processing applications. For the experiments, two photographs, one of a seagull and
one of a pair of glasses (Figure 9 and Figure
detail
effects,
JPEG
is
1),
were chosen
To
investigate
26
amount of
JPEG's
Effects on Pixels
1.
Table
files
we
bits
and the
JPEG
results
(MSB)
equivalent
While the
many
most
significant
(LSB) have an
essentially
errors in the
number of errors.
MSB
LSB
Glasses
744
4032
10247
21273
33644
42327
27196
48554
Seagull
257
99)
2821
7514
15039
29941
41593
46640
Table
Table
shows
corresponding pixels
the
Errors introduced by
Hamming
in the original
and
distance
JPEG
(number of differing
JPEG processed
files
bits)
between
for each image. Again, the seagull picture has fewer errors.
1-3
4-6
7-9
10-12
13-15
16-18
19-21
Glasses
15581
37135
30337
11976
2205
172
Seagull
24188
38710
17564
4631
409
43
Table
5 bits
and recover
garbled by
in
2:
Hamming
Table
1, it is
after
JPEG
22-24
to
embed
all
of the
JPEG
27
Error Distribution
2.
Although
JPEG causes
number of bit
which has a
Figure 14
JPEG
Hamming
is
most severe
file.
: -:'
'%
->
'-
f-?^i-
/''<-
-C
Map
of errors of
JPEG
this will
pixel
m.
severely affected by
the
v-v'
Figure 14:
is,
%?-
errors, that
JPEG
more than
-Jt'
errors, the
is
,<.
challenging.
The
embedded
in
lower order
higher order
bits are
bits,
but
cause more degradation of the image and compromise the effectiveness of the
corruption.
The
is
is
is
28
all
D.
Since a straightforward substitution of pixel bits with data bits proved useless, a simple
lower 5
1.
On
bit
bits
than 7 in an
upward
that perhaps
direction and 8 in a
unrecognizable. This
bit
tried.
A bit was
and
would be decoded
1 1 1
JPEG would
downward
embedded
in the
1000 to code a
and 10000 to
as a
more
direction or, if
it
did,
it
would make
changes only occasionally and some kind of redundancy coding could be used to
drastic
makes
bits
11111 as a
was
many
over
JPEG
is
coefficient values,
JPEG
some of which
amount of change
when
extracted,
it
was
step.
The negative
original.
It
was noticed
made by JPEG,
is
to
more
subtle
some
in color to the
JPEG
their original
that, in
that a
little
as possible
To
attempt
a point in space (Figure 15) with the three color channel values as the coordinates.
is
found
The
is
pixel
value
corresponding to the
bit
divided by a
number and
its
the remainder
modulus
is
(r
distance
changed to
mod
n)
is
number
29
RGB
color space
is
is
Blue
(R,
G,B)
71
/
/
/
Green
\Red
Figure 15:
Suppose we choose an
in
to
20
will
arbitrary
bit is
be decoded as a
0.
So we want
to
move
is
31 to code a
origin
1. It
would have
was hoped
by more than 10
its
that
JPEG would
and any
value from
modulus
is
10 to code a
correctly decoded.
For example, given a pixel (128, 65, 210) the distance to the origin would be
computed: d
= /i28
Next we find
+ 65
dmod42
+ 2i(r = 254 38
which
is 2. If
The value of d
we are
coding a
would be
21.
code a
1.
Note
that the
is
amplitude of the
maximum
red, green,
and
blue components to be computed. The results of using this encoding are described in the
next section.
30
same way
the
computed
as
was done
is
to the distance
as y
value
is
only from
to
[11],
One drawback
from
The luminance,
origin.
where R, G, and
y,
of a pixel
in
is
range of luminance
to 441.67.
is
E.
with data
bits,
forced to use an enormous amount of redundancy to achieve a suitably low error rate
is
JPEG compression
after
bits
Also, since the lowest few bits are so badly scrambled by JPEG,
higher order bits must be used which increases the visible distortion of the image. This
is
times
in a
and applying
= 0.000225 per
1
triple
bit,
where p
-(1 -0.000225)
In practice,
redundancy
rate of p
is
in
embedding data
is
i.e.
(i.e.
assumed,
is
0.8678%. Given
embed each
bit three
would yield an
error rate
per byte.
lies in the
modified to encode a
be
When a pixel
modulus of 62
= 0.001799
text can
on an image.
JPEG
2.36. Theoretically, if a
this figure
of:
is
where recognizable
number and
JPEG
is
in the
above example
difference in
sensitive to transients
its
will not
JPEG
has
value with
between adjacent
number of errors
introduced by JPEG. Thus, the very act of encoding data into pixels generates an increase
in the severity
in
garbling of the
31
embedded
data.
it
a very
good anti-steganography
tool, but
does not
some
text
to the origin
extracted from a
JPEG
bit 5 times,
32
approximately
30%
V.
A.
As was seen
and
is
in the
relatively simple to
is
The increase
in
or
file.
implement
Until recently,
as a threat.
stored. In light
in the
Although steganography
sense
strictest
it is
not.
is
considered by
[1].
to
mechanisms
in a
in the
computer system
for a
many
at
process
at
a lower security
monitor the effects of this modulation and thereby receive information from the
higher security level. In contrast, steganography can exploit a trusted subject's privileges
in a multi-level system. Specifically, those privileges
classification
operator
is
which allow
it
to write to a
lower
takes advantage of the operator's inability to discern or identify the distortion caused by
embedded
to
data. Since
human
perception
is
The key
system.
digest
[4].
may need
to
image
files is
an
for.
in
an image.
Any tampering
with
enforcement mechanism.)
33
upon
for
effects
is
to
is
It is
possible for
embedded data
in
such a
to
be encoded to
way would be
resist the
small compared
of the image due to the large amount of error correcting data which must be
to the information
being embedded.
STEGANOGRAPHIC APPLICATIONS
B.
Steganography
is
of data
complete protection.
to the size
added
JPEG,
e.g.
files
exfiltration
commonly
C++, awk,
shell script to
embed
accomplished
in
data to be exfiltrated in
batch
mode
all
image
files
would impose on
system.
The
which handles
the
files.
files
which are
An example
processing,
JPEG
of
this is
JPEG
distortion is
in
its
image
due entirely to
JPEG
processing
34
i.e.
VI.
A.
AN UNEXPLORED DISCIPLINE
As
of,
to do.
new
The following
or tangential
to,
our main
objectives.
1.
image
in
files?
This
a difficult question.
is
may be
image
the
in a
random way
If,
amount,
it
24
may
bit
two
bits
that
many
is
within 2
imperceptible, so a
probably unlikely.
an
a particular color
all
in
in
in a
value
may be
is
It
at
most a factor of 2
6
.
Assuming
clump of colors
like this
this point.
35
would be
change
in a pixel's color
suspicious.
Of course,
it is
How Widespread
2.
If a
is
it
would
is
used, by
whom, and
it is
not
for
if
known
if
3.
an application to serve as a
Web
web browser
to retrieve data
It
may be
embedded
possible to develop
in
web page
images.
disseminating information.
Steganography
4.
If data is
embedded
in
Printed Media
in
in a file,
can the embedded data be recovered? This would require a special form of steganography
to
As was seen
in this thesis,
JPEG garbles
that
when
it
wrapper
file is
in
data
Anti-Steganography Measures
5.
JPEG,
in the printing
processed.
[3]. It is likely,
36
as to
what
as with
embedded
is
the most
REFERENCES
LIST OF
1
PTR
Prentice
Hall, 1994.
2.
Brassil,
Low,
J.,
Techniques to
Identification
Maxemchuk,
S.,
N.,
1278-1287.
3.
Cha,
Park,
S.D.,
G.H.,
Downgrading Problem,"
in
Applications Conference,
4.
Dorothy
Denning,
Solution
to
the
On-Line Image
New Orleans,
LA,
December
1995.
"Cryptographic
E.,
5.
"A
pp. 52-61.
A Secure Computer
System,
New
York, 1988.
6.
7.
Kahn, D.,
8.
9.
Kurak,
77k?
C, McHugh
J.,
"A
Lockstone, Keith,
"A
USENET newsgroup
11.
12.
Pennebaker,
William
B.,
Standard,
Van Nostrand
Simmons,
G.J.,
Mitchell,
Reinhold,
29 Nov. 1994.
Joan
L.,
New York,
JPEG
Still
Image Compression
1993.
Advances
in
13.
Wallace,
14
Walton,
S.,
"Image Authentication
for a Slippery
37
New Age,"
Dr.
Dobbs
Standard,"
Journal, No.
38
A.
code
is
written in
C++
#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include "stegofunctions.h"
/*
21 Feb
infile
embedded
bits
in the
infile,
//
infile.
infile is the
24
textin;
//
bits are
fstream
file into a
*/
BMP file
bit
modified 24
bit
BMP file
be embedded
in the
image
// file
file
names
//
bitsleft;
loop counter
//
//
//
in
is
file,
embedded, placed
textbyte;
steghead 1
//
hide,
//
//
//
in
fulllong;
bmpheader header;
//
This
is
39
typedef struct
color;
Function prototypes
//
textbit);
mainO
{
//
read in
names of image
"Enter name of
imagefile;
"Enter name of
"Enter name of
cout
cout
cin
image
file
";
:
";
";
:
stegfile;
cout
"\n";
Open
cout
the
"\n";
cout
//
file
textsourcefile;
cout
cin
and output
"\n";
cout
cin
file
infile.open(image_file, ios::in);
read_bmp_header(infile, header);
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
bitcount
imagesize
"Image
"X
"Y
"Number
header numbercolors
"Colors
"Filesize: "
"Offset
bits: "
"Size: "
header. filesize
'\n';
header, offsetbits
header. size
'\n';
'\n';
"
'\n';
"Height: "
header.height
'\n';
header.
size: "
'\n';
header.
'\n';
pixels: "
header. x_pixels
'\n';
pixels: "
header.y_pixels
'\n';
colors: "
'\n';
important: "
header. colors_important
"\n";
file
write_bmp_header(outfile, header);
40
'\n';
//
//
image bytes
count
as folows:
how many
//
//
2.
Embed
//
3.
Read
//
4.
//
//
is
6.
image
file.
bytes.
in a data byte.
//
//
contained
image
file file.
Get another
text byte
textbytes = bytecount(textin);
"The
has textbytes
"textsource
cout
input text
cout
//
open.\n\n";
file is
"
file
file
by closing
it
then opening
it.
textin. close();
textin. open(textsource_file, ios::in);
//
cout
cin
density;
bitsjeft
//
Make
8;
//
//
for density at
Embed
Bits left to
";
embed
fit
((text_bytes*8)/density
if
//
Embed
//
values will constitute the stego 'header' to allow recovery of the data.
the
to
//
//
cout
cout
"\nData
length: "
density
"\n";
fulllong =
hide = 3;
hide = hide
//
++x)
//
0;
& stegheadl;
Hide now contains lower 2
fulllong = fulllong
infile
steg_headl
bits
of steg_headl
hide;
1),
41
'\n';
image_byte = imagebyte
2;
imagebyte = imagebyte
2;
imagebyte = image_byte fulllong;
//
Embed
bits
steg_headl = stegheadl
2;
//
1);
++x)
//
full_long=0;
hide
hide
=
=
3;
hide
//
fijlljong
&
steg_head2;
= fulllong
bits
of steg_head2
hide;
imagebyte = imagebyte
imagebyte = imagebyte
2;
=
image_byte image_byte fulllong;
//
1);
2;
Embed
bits
steg_head2 = steg_head2
2;
1);
//
hidemask = (unsigned
//
while (!textin.eof()
short)
image bytes
at the specified
- 1;
density
textbyte =0;
textbyte
< density)
//
1); //
Read
a text byte
8;
of the
//
//shift left to
accommodate
new
textbyte
old bits
= textbyte
bitsleft,
textbyte = textbyte old_textbyte; // tack on the old bits
bitsleft = bitsjeft + 8; // The old bits + the new bits
textbyte
while (bitsjeft
fullshort =
>=
density)
0;
datahide = hidemask;
datahide = datahide & textbyte;
// Hide now contains lower density
full
short
full
short
bits
data hide;
42
of textbyte
end
image_byte =
0;
imagebyte = imagebyte
image_byte = imagebyte
image_byte = image_byte
density;
//
textbyte
bitsleft
density;
full_short;
//
=
bitsleft =
textbyte
1);
Embed
density bits
&image_byte,
1);
density;
oldtextbyte = textbyte;
//
//End while
// At this point there are less than density bits to embed.
or bitsleft >
// There are two possibilities bitsleft =
// In any case a new textbyte must be read.
//
End while
//
At end of input
file
while (!infile.eof()
) {
1);
1);
//End
else
//
data will
fit
cout
}
if
"Data
End
file is
too big to
fit
fit
outfile.close();
textin.closeO;
infile.close();
return 0;
//End of main()
//
//
The
it
with the
into its
LSB
component
bits.
in bitarray[0].
i,
&
0;
1)
bitarray [i]
1;
43
inbyte
}
else inbyte
1;
1;
}//Endofbitslice()
//
//
determines which
//
pixel,
// It
is
bit,
component of the
component.
else
>=
= &pixel.red;
(*big
<
if (textbit
else
*big
}
*big
1)
= *big
= *big
= &pixel.blue;
*big = *big
1; } //
//End of function
//
Makes
the
1;
Makes
the
LSB
insert_lbit()
44
LSB
B.
/*
21Feb - This version of Extract will extract data hidden at any density
The user will be prompted for the density. If is entered, the
program will try to find the stego header to get the density and
the
number of hidden
(1-7).
*/
bytes.
#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include "stegofunctions.h"
#define PI 3.14159265
fstream
infile,
outfile;
//
//
infile is the
24
bit
// file
names
int x;
//
loop counter
bmpheader header;
typedef struct
//
This
is
color;
//
Function prototypes
main()
{
//
//
cout
file in
file
"\n":
45
will
be stored,
image
"Enter
cout "Enter
name
dataoutfile;
cout
the stego
file
name:
";
stegfile;
cin
file
cin
infile.open(steg_file, ios::in);
read_bmp_header(infile, header);
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
"\nStego image
"Filesize:
"Width:
width
bitcount
"Image
imagesize
"X
"Y
"Number
numbercolors
"Colors
colorsimportant
file
"
"Offset
header.file_size
bits: "
"Size: "
information: \n\n";
header.size
"
'\n';
header, offsetbits
'\n';
header.
"Height: "
'\n';
header.height
'\n';
'\n',
header.
size: "
'\n';
header.
'\n';
pixels: "
header.x_pixels
'\n';
pixels: "
header.y_pixels
'\n';
colors: "
header.
important: "
'\n';
header.
'\n';
infile.close();
infile.open(steg_file, ios::in);
//
//
stego header.
//
Now we must
//
//
Get the
stego
file
and
now
which
it
number of bytes
was hidden.
number of bytes...
stegbytes =
0; //
stegbytes
for(x=0;x<16;++x)
steg_bytes
steg_bytes
2;
//
Make room
1);
stegin & 3; // Get rid of all bits above the lower two.
stegbytes = steg_bytes stegin; // Put the bits on the bottom of
stegin
//
steg_bytes
now
//
stegbytes
//
density
contains the
density
0;
++x)
46
in the
image.
infile
seekg((77
density
-x), ios::beg);
density
Make room
2; //
char*) &densin,
infile. read((unsigned
3; //
Get
densin;
rid
of all
1);
bits
//
//
density
cout
cout
cout
//
now
"\nThe hidden
"The hidden
data
is "
steg_bytes
density
"\n";
is
now
outfile.open(data_out_file, ios::out);
//
//
//
Open
stego
bits.
//
The image header and the stego header are contained in the
first 78 bytes so we go to the 79th byte which contains the
//
//
//
infile.
of the
first
is
file.
seekg(78, ios::beg);
leftoverbits
all
0;
byte of the
first
//
Density 1111111111111111111111111111111111111111111
mask = 1;
hiddenbyte =
0;
++x)
infile. read((unsigned
inbyte
char*) &inbyte,
inbyte
& mask;
1),
x);
1);
-H-bytes_recovered;
break;
case
2:
//
Density 22222222222222222222222222222222222222222222
47
mask = 3;
hiddenbyte =
0;
x=x+2)
(inbyte
|
1);
x);
1);
++bytes_recovered,
break;
case
3:
//
Density 33333333333333333333333333333333333333333333
mask = 7,
hiddenbyte =
0;
switch (leftover_bits)
case
0:
inbyte
= inbyte
&
//
hiddenbyte = hidden_byte
//
1);
mask;
inbyte;
inbyte
= inbyte
&
//
mask;
hidden_byte = hidden_byte
(inbyte
|
//
1);
&
upper2 = inbyte
//
3);
3;
6);
++bytes_recovered;
break;
case
1:
hidden_byte = orphanbits
//
2; //
Low
stored
inbyte
= inbyte
&
//
bit
1);
mask;
48
now
inbyte
&
= inbyte
hidden_byte = hidden_byte
(inbyte
|
1);
&
upperl = inbyte
leftover_bits
inbyte
bits
1);
//
4);
1;
orphanbits =
1);
mask;
//
char*) &inbyte,
infile. read((unsigned
&
Orphan
6; //
7);
bits are
and 2
2;
++bytes_recovered;
break;
case
2:
hiddenbyte = orphanbits
//
1; //
stored
inbyte
&
inbyte
mask;
hidden_byte = hidden_byte
infile
(inbyte
|
inbyte
&
= inbyte
//
1);
2);
1);
mask;
5);
++bytes_recovered;
break;
default: cout
return 0;
} //
break;
case
4:
//
mask=
Density 44444444444444444444444444444444444444444444
15;
hidden_byte =
0;
infile. read((unsigned
inbyte
= inbyte
&
char*) &inbyte,
1);
mask;
49
inbyte
&
inbyte
4);
1);
mask;
hidden_byte = hidden_byte
inbyte;
1);
-H-bytesrecovered;
case
5:
//Density 5555555555555555555555555555555555555555555
mask = 31;
hiddenbyte =
0;
switch (leftoverbits)
case
0:
inbyte
&
= inbyte
1);
mask;
//
//
&
upper3 = inbyte
7;
//
Orphan
1);
5);
leftoverbits
2;
++bytes_recovered;
break;
case
1:
bit
inbyte
= inbyte
&
//
mask;
//
stored
1);
now
1);
1);
& 3;
Store the bits 6,7
++bytes_recovered;
50
break;
case
2:
hidden_byte = orphan_bits;
Low 2
//
now
bits
stored
inbyte
//
upper 1 = inbyte
&
//
Pull out
orphanbits = (inbyte
1);
//
2);
1;
leftover_bits
1);
& mask;
inbyte
&
orphan
30)
7),
bits
1;
4;
++bytes_recovered;
break,
case 3
hiddenbyte = orphanbits;
Low
//
now
3 bits
stored
&
inbyte = inbyte
1);
mask;
hidden_byte = hiddenbyte
leftover_bits
(inbyte
|
3),
0;
++bytes_recovered;
break;
case
4:
hiddenbyte = orphanbits;
//
Low 4
now
bits
stored
upper4 = inbyte
&
1);
15;
//pull
4);
orphanbits = (inbyte
leftover_bits
&
16)
4;
1;
51
it
++bytes_recovered;
break;
default: cout
return 0;
} //
End of leftover
switch
break;
case
6:
//Density 666666666666666666666666666666666666666666
mask = 63;
hiddenbyte =
0;
switch (leftoverbits)
case
0:
inbyte
&
= inbyte
//
hiddenbyte = hiddenbyte
//
inbyte;
upper2 = inbyte
&
1);
mask;
1);
3;
//
6);
bits 2,3,4,5
++bytes_recovered;
break;
case
2:
hiddenbyte = orphanbits,
//
Low
2 bits
now
inbyte
= inbyte
&
mask,
//
//
leftover_bits
1),
6 bits
stored
2);
0;
++bytes_recovered,
break;
case
4:
hiddenbyte = orphanbits;
//
upper4 = inbyte
&
stored
1);
15;
//
//Pull out
orphan_bits = (inbyte
leftoverbits = 2;
orphan
& 48)
4);
bits 4,5
it
4;
++bytes_recovered;
break;
default: cout
return 0;
//
break;
case
7:
//
mask =
Density 7777777777777777777777777777777777777777777
127;
hidden_byte =
0;
switch (leftover_bits)
case 0:
infile.read((unsigned char*) &inbyte,
inbyte
&
= inbyte
//
hiddenbyte = hiddenbyte
//
inbyte;
upper 1 = inbyte
&
1);
1;
//
leftover_bits
1);
mask;
7);
1,2,3,4,5,6,7
7,
++bytes_recovered;
break;
case
7:
hiddenbyte = orphan_bits;
//
Low
7 bits
now
stored
53
upper 1 = inbyte
&
1);
1;
//
7);
++bytes_recovered;
break;
case
2:
hiddenbyte = orphanbits
Low
bit
//
1;
now
stored
inbyte
= inbyte
&
1);
mask;
//Store the bits 2,3,4
hidden_byte = hiddenbyte
(inbyte
inbyte
= inbyte
&
mask;
//
leftoverbits
2);
1);
5);
0;
++bytes_recovered;
break;
default: cout
return 0;
//
break;
default:
cout
"Invalid density!
AbortingAn",
return 0,
} //
End
density switch
if (infile.eof()) return 0;
}
//
//
Don't
let
it
return 0;
}
54
file.
//
//
The
it
with the
into
LSB
its
component
bits.
in bitarray[0].
bitarrayfi]
if (inbyte
&
bitarrayfi]
inbyte
else inbyte
0,
1)
1;
1;
}
}
//Endofbitslice()
//
//
determines which
//
pixel,
// It
is
bit,
component of the
component.
else
>=
&pixel.red;
= &pixel. green,}
if (*big < pixel. blue) big = &pixel.blue;
big
if (textbit
else
*big
//
==
*big
1)
= *big
= *big
1;
= *big
*big
} //
1; } //
Makes
the
1;
Makes
the
LSB
55
LSB
C.
#include <iostream.h>
#include <fstream.h>
#include "stego_functions.h"
/* 21
Feb 96
the
Hamming
same
exactly the
displays the
size. It
Hamming
This program
is
produces an error
mapfile;
//
24
//
24
The 2
map
and
file2,
and finds
must be
which
files
file
used to look
at the errors
or by a steganographic program.
fstream filel,file2,
files, filel
caused by
JPEG
*/
bit
bit
// file
names
blue, green
max =
//
int x, y,
OxfT,
OxOf,
filel
and
white =
file2
Oxff;
//
loop counters
//
one_3_diff =
0,
number of bits
differing in each
color channel
intermediatediff, totaldiff;
//
//
0,
//
total
number of bits
differing in
each pixel
Function prototypes
mainO
{
//
read in
cout
names of filel,
file2,
"\n":
56
file
"Enter name of
filel;
"Enter name of
"Enter filename
errormap;
cout
cin
cout
cin
file
#2
";
:
";
cout
//
#1
file_2;
cout
cin
file
";
:
"\n";
Open
filel
cout"File#
:"file_l
'\n';
"Filesize:
headerl
"Offset
"Height: headerl
header
l.bitcount
imagesize
"Image
"X
"Y
headerl
"Number
headerl numbercolors
orsimportant
cout "Colors
"
cout
headerl. file_size
bits: "
cout
"Size: "
cout
headerl. size
'\n';
"
cout
'\n';
'\n';
"
cout
'\n';
offsetbits
height
'\n';
cout
'\n';
size: "
cout
headerl.
'\n';
cout
pixels: "
headerl. x_pixels
'\n';
cout
pixels: "
y_pixels
'\n';
colors: "
cout
'\n';
important: "
cout
//
headerl. col
'\n':
"\n";
Open
file2
file2.open(file_2, ios::in);
read_bmp_header(file2, header2);
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
"Width:
width
"Height: header2
header2
"Image
header2.image_size
"X
header2.x_pixels
header2.y_pixels
"Y
"Number
header2.number_colors
"Colors
header2 colorsimportant
"File
"
file_2
"File_size: "
'\n';
header2.file_size
header2.offset_bits
header2.size
"
'\n';
header2.
"
'\n';
'\n';
'\n';
height
'\n';
bit_count
'\n';
size: "
'\n';
pixels: "
'\n';
pixels: "
'\n';
colors. "
'\n';
important: "
"\n";
57
'\n':
/*
//
Check
if
(header l.imagesize
//
They
to see if the
*/
is
the same,
header2.image_size)
made
file
= 0;
y < headerl imagesize; y=y+3)
error_pixels
for (y
0;
1);
1);
1);
1);
1);
1);
if
(flbyte_b != f2byte_b)
||
(flbyte^g != f2byte_g)
++error_pixels;
= bits_different(flbyte_b, f2byte_b);
= bits_different(flbyte_g, f2byte_g);
diffr = bits_different(flbyte_r, f2byte_r);
intermediatediff = (diffb + diff_g + diffr);
if (intermediatediff <= 1)
totaldiff = 0;
diff_b
diff_g
else
totaldiff = (intermediate_diff -
1)
3;
switch (totaldiff)
{
//
case
&min,
mapfile. write((unsigned char*)&max,
&min,
1);
1);
1);
++one_3_diff;
break;
// 4, 5,
case
or 6 bits differ
&max,
&max,
&min,
1);
1);
58
1);
||
(flbyte_r != f2byte_r)
++four_6_diff;
break;
// 7, 8,
case 2
or 9 bits differ
:
mapfile.write((unsigned char*)
mapfile.write((unsigned char*)
&min,
mapfile.write((unsigned char*)
&max,
&max,
1);
1);
1);
++seven_9_diff;
break;
//10, 11, or 12 bits differ
case 3
mapfile.write((unsigned char*)
&max,
mapfile.write((unsigned char*)
&min,
1);
1);
1);
++ten_12_diff;
break,
//
case 4
mapfile.write((unsigned char*)
mapfile.write((unsigned char*)
&max,
mapfile.write((unsigned char*)&min,
&max,
1);
1);
1);
++thirteen_15_diff;
break;
//16, 17, or 18 bits differ
case 5
mapfile.write((unsigned char*)
&min,
mapfile.write((unsigned char*) &min,
mapfile.write((unsigned char*)
&max,
1);
1);
1);
++sixteen_18_diff;
break;
//19, 20, or 21 bits differ
case 6
&mid,
mapfile.write((unsigned char*) &mid,
mapfile.write((unsigned char*)
1);
1);
1);
++nineteen_2 1 _diff;
break;
//22, 23, or 24 bits differ
case 7
&min,
mapfile.write((unsigned char*) &min,
mapfile.write((unsigned char*)
1);
1);
1);
++twentytwo_24_diff,
break;
default
}
cout
"default
bad value
in
switch statement\n";
//end switch
//
end
if
else
{
59
1);
1);
1);
//
end for y
//
The image_size
else
cout
if
statement
"\nThe bitmaps
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
"There
one_3_diff
by
four_6_diff
6
by
seven_9_diff
9
by
ten_12_diff
by
by
sixteen_18_diff
by
nineteen_21_diff
by
twentytwo_24_diff
by
are "
" pixels
error_pixels
" differ
2,
1,
" differ
" differ
10,
" differ
" differ
" differ
different. \n";
bitsAn";
7,8, or
" differ
thirteen_15_diff
or
4, 5,
" differ
which are
or 3 bitsAn";
1,
bitsAn";
or 12 bitsAn";
22, 23, or
24 bitsAn";
"\n";
mapfile.closeO;
filel.closeO;
file2.close0;
return 0;
//
//
End main()
0;
0;
count +=(xor_byte
&
xorbyte = xorbyte
{
1 );
return count;
60
D.
/*
19
Some
file.
*/
#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include "stego_functions.h"
fstream infile,
//
24
infile is the
bit
bmp
the modified 24
outfile,
//
outfile is
textin;
//
file
bit
bmp
file
be hidden
unsigned char
user-supplied
file
//
variables to hold
names
c, r, g, b,
textbyte,
int
,y, z,
//
//
image
file
bytes
unused byte
loop variables
i,
//
d_mod,
//
epsilon,
//
stegmodulo
amount of displacement of the pixel along
its
line to origin
repeat,
skip;
//
number of pixels
to skip
long total_pixels,//
pixelnum;//
double
t,
dist, //
//
//
new
position
//
bmpheader header;
//
//
number of bytes
61
//
Function prototype
mainO
{
//
read in
names of image
"Enter name of
imagefile;
"\nEnter name of
"Enter name of
cout
cout
cin
the
cout
cin
image
file
";
";
";
stegfile;
cout
"\n";
Open
cout
file
"\n";
cout
//
and output
textsourcefile;
cout
cin
file
"\n";
image
the input
file
"\n";
infile.open(image_file, ios::in);
read_bmp_header(infile, header);
//
Print the
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
//
image
file's
header data
"Width: header.width
bitcount
imagesize
"Image
header
"X
"Y
"Number
header.numbercolors
"Colors
header.colorsimportant
Open
"File_size: "
header. file_size
'\n';
header, offsetbits
header.size
'\n';
'\n';
"
'\n';
"Height: "
header.height
'\n';
header.
size: "
'\n';
header.
'\n';
pixels: "
x_pixels
'\n';
pixels: "
header.y_pixels
'\n';
colors: "
'\n';
important: "
"\n";
its
header
write_bmp_header(outfile, header);
62
'\n';
//
Open
textin.open(textsource_file, ios:
"The
in
it
:in);
textbytes = bytecount(textin);
cout
number of characters
textbytes
" bytesAn";
textin.closeO;
file
textin.open(textsource_file, ios:
//
image
:in);
pixels.
infile.seekg(header.offset_bits, ios::beg);
//
Make
sure
we
//file header.
//
Make
total_pixels
if
fit
cout
"Input
data
file is
total _pixels)
return 0;
}
//
skip
pixelnum =
0;
while (!textin.eof()
) {
++x)
//Embed
all
is
1); //
Read
//
Read
a text byte
//
empty
//
Embed
Redundancy times
1);
1);
1);
++pixelnum;
63
each
bit
//
= rawred;
green = raw_green;
blue = rawblue;
red
//
Make
sure no value
is
bounds
//
blue*blue));
how much.
//
Find out
//
//
if (textbyte
if
if the pixel
&
) {
//
Embed
(dmod == encodel)
to the
file.
epsilon
0;
else
if
epsilon
= encodel
else
if
else
if
epsilon
= -l*(d_mod
epsilon
= -l*(lo_to_hi + dmod);
encodel);
else
// 1 is
//
the line on
which the
pixel
lies,
}//Endif
else
if
//
Embed
(dmod == encodeO)
epsilon
0;
else
64
dmod;
if
else
if
epsilon
= (encode_0 + (stegmodulo
dmod));
else
if
else
// 1 is
//
which the
the line on
pixel lies.
//
end else
value
outfile. write
outfile. write
outfile. write
//
truncated on conversion
is
1);
1);
1);
++z)
1);
1);
1);
++pixelnum;
outfile. write
outfile. write
outfile. write
//forz
textbyte
65
1);
1),
1);
encodeO);
//
embed
for x to
end while
} //
//
End
8 bits
textin.eofQ
At end of input
file
while (!infile.eof()
1);
1);
1);
outfile. write
outfile. write
outfile. write
1);
1);
1);
cout
pixelnum
'\n';
outfile.close();
textin.closeO;
infile.close();
return 0,
//
End of main()
//
//
in
if (red
else
> hibound)
< lobound)
(green
else
red
is
adjusted to be in bounds.
= hibound;
if (red
if
make
red
= lobound;
66
if
(green
if (blue
else
//
if (blue
end in_bounds
67
E.
/*
origin.
This version
Some
file.
*/
#include <iostream.h>
#include <fstream.h>
#include <math.h>
#include "stegofunctions.h"
fstream
infile,
outfile;
//
//
24
infile is the
outfile is the
bmp file
bmp file
bit
modified 24
bit
file
//
//
names
the byte of data being recovered
file
bytes
unsigned char
int x,y,z,i, //
c,
r,
g, b;
loop variables
//
double
//
number of pixels
to skip
dist;
//
//
//
in the
bit
recovery process
bmpheader header;
//
//
This
is
Function prototype
int
//
long variable
68
's in
an unsigned
mainQ
{
//
//
Get the name of the input image file containing stego data (stegfile)
and the name of the file in which the extracted data will be stored.
name:
image
"Enter
"Enter name
=
"\nThe
be
based on mod62\n";
"How many
hidden?
stegbytes;
"What
cout
"\n";
the stego
cout
cin
steg_file;
cout
//
cin
file
data_out_file;
data_out_file
"steg.out";
cout
data will
extracted
";
bytes are
cout
cin
";
file
cout
'\n';
//
cout
//
cin
is
";
skip;
skip =17;
cout
'\n';
infile.open(steg_file, ios::in);
read_bmp_header(infile, header);
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
cout
"\nStego image
"Filesize:
"Width:
width
bitcount
"Image
image_size
"X
"Y
"Number
number_colors
"Colors
colorsimportant
file
"
information: \n\n";
header, filesize
header, offsetbits
header. size
"
'\n';
header.
"Height: "
'\n';
header.height
'\n';
'\n';
'\n';
header,
size: "
'\n';
header.
'\n';
pixels: "
header.x_pixels
'\n';
pixels: "
header.y_pixels
'\n';
colors: "
important: "
header.
'\n';
header.
cout'\n';
infile.close();
infile.open(steg_file, ios::in);
//
Open
69
'\n';
//
We need
//
// first
to
be
at the first
54 bytes so
is
contained
we go
//
//
is
byte of the
first pixel.
in the
of the
first
first
byte of the
file.
infile.seekg(header.offset_bits, ios::beg);
//
bytes_recovered
pixelnum =
all
0;
0;
hiddenbyte =
0;
//
Read
a pixel
1);
1);
1);
++pixelnum;
//
rawred;
=
green
(int) raw_green;
blue = (int) rawblue;
red
//
(int)
Compute
if
(dmod >
pivot) hidden_bit |= (1
y);
else;
}
//
//Fory
++z)
bit is
read
70
bit
1);
1);
1);
++pixelnum;
if
//forz
|= (1
x);
else;
//End of x loop
1);
++bytes_recovered;
if (infile.eof()) return 0;
//
//
Don't
let
it
file.
cout
pixelnum
'\n';
infile.close();
outfile closeQ;
return 0;
II*
int
************************************************************
byteweight(unsigned long hbyte)
int x,
w;
w=0;
for(x=0;x<15;++x) {
if (hbyte & l)++w;
hbyte
return w;
}
71
F.
This
//
is
#include <fstream.h>
struct
bmpheader
char bm[2];
//
//
is
no
bit
bmp
pallette
width,
height;
unsigned short
planes,
bit_count;
unsigned long
compression,
imagesize,
x_pixels,
y_pixels,
numbercolors,
col orsi important;
};
int
//
redundancy =
5; //
the
number of times
modulo parameters
stegmodulo = 62,
pivot = 30, // Anything over 30
encodel = 47,
encode_0 = 1 6,
hibound = 224,
lobound = 31,
lo_to_hi = 15;
to
embed
a bit
Set the
int
is
/*int
since
72
we
are using
steg_modulo=62
lo_to_hi
//
11;*/
Function prototypes
bmpheader& header);
void write_bmp_header(fstream& outfile, bmpheader& header);
void read_bmp_header(fstream&
long
int
byte_count(fstream&
infile,
intext);
infile);
infile);
bmp
//
The
The
The
The
//
//
//
//
//
file
endian format.
little
//which
is
bmp
little
endian
passed by reference.
void read_bmp_header(fstream&
infile,
bmpheader& header)
infile. read((unsigned
char*) &header.bm[0],
1);
infile. read((unsigned
char*) &header.bm[l],
1);
header, filesize
read_lsbfirst_long(infile);
= read_lsbfirst_short(infile);
header. reserved[l] = read_lsbfirst_short(infile);
header, offsetbits = read_lsbfirst_long(infile);
header. size = read_lsbfirst_long(infile);
header. reserved[0]
header, width
readjsbfirstlong(infile);
= readlsbfirstjong(infile);
header.planes = read_lsbfirst_short(infile);
header.bitcount = readjsbfirstshort(infile);
header. compression = read_lsbfirst_long(infile);
header. imagesize = readjsbfirstjong(infile);
header. x_pixels = readjsbfirstjong(infile);
header. y_pixels = readjsbfirstjong(infile);
header. numbercolors = read_lsbfirst_long(infile);
header. colorsimportant = read_lsbfirst_long(infile);
} // End of readbmpheaderO
header. height
/*
//
***********************************************************
bmp
header to a
file.
73
bmpheader& header)
outfile. write((unsigned
char*)&header.bm[0],
outfile. write((unsigned
1);
write_lsblongfirst(outfile,header.file_size);
write_lsbshortfirst(outfile,header.reserved[0]);
write_lsbshortfirst(outfile,header.reserved[l]);
write_lsblongfirst(outfile,header.offset_bits);
write_lsblongfirst(outfile,header.size);
write_lsblongfirst(outfile,header. width);
write_lsblongfirst(outfile,header.height);
write_lsbshortfirst(outfile,header. planes);
write_lsbshortfirst(outfile,header.bit_count);
write_lsblongfirst(outfile,header. compression);
write_lsblongfirst(outfile,header.image_size);
write_lsblongfirst(outfile,header.x_pixels);
write_lsblongfirst(outfile,header.y_pixels);
write_lsblongfirst(outfile,header.number_colors);
write_lsblongfirst(outfile,header.colors_important);
//
End of write_bmp_header()
long
int
byte_count(fstream& intext)
//
//
int
count =
while
(!
file
0;
intext. eof())
++count,
}
return count;
} //
//
End of byte_count
Read
little
infile)
(buffer[3]
24);
74
and
value
|=
value
|=
value
|=
16);
8);
return value;
//
//
Read
little
infile)
value = (unsigned
value
|=
short) (buffer[l]
8);
return value;
//
End of unsigned
short
//
Write a
little
unsigned char
buffer[4];
buffer[0]
buffer[l]
buffer[2]
buffer[3]
=
=
=
=
outfile. write((unsigned
8);
16);
24);
75
//
//
Write a
little
unsigned char
buffer[2];
buffer[0]
buffer[l]
= (unsigned
= (unsigned
char) (value);
8);
char*) &buffer,
2);
char) ((value)
outfile. write((unsigned
//
76
2.
Monterey,
3.
CA
Chairman, Code
93943-5101
CS
Raymond
CA
93943
2
I shell
5.
VA 22182-3280
Dr. Blaine
Burnham
Agency
National Security
R23
9800 Savage Road
20755-6000
Fort Meade,
6.
MD
William Marshall
Agency
Research and Development Building
R23
9800 Savage Road
National Security
Fort Meade,
7.
MD 20755-6000
Dr Cynthia E. Irvine
Computer Science Department
Code CS/Ic
Naval Postgraduate SchoolMonterey,
15
CA 93943-51 18
77
8.
9.
Commanding
MA/FS
Officer
NAB
10.
ATTN:
CDR J
O'Dwyer
Fort Meade,
1 1
MD
LT Hannelore Campbell
USS Boxer (LHD 4)
FPOAP 96661
12.
LT
Daniel
Currie
III
78
:00L
:Y
CA 9394^101
3 2768 00322410 6