|
@@ -1,4 +1,3 @@
|
1
|
|
-
|
2
|
1
|
# Repetition Structures - Steganography
|
3
|
2
|
|
4
|
3
|
![main1.png](images/main1.png)
|
|
@@ -7,7 +6,7 @@
|
7
|
6
|
|
8
|
7
|
One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as the `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. These structures are also referred to as *repetition structures*. In today's laboratory experience you will complete a steganography application to practice the use of nested loops and the manipulation of bidimensional arrays.
|
9
|
8
|
|
10
|
|
-## Objectives:
|
|
9
|
+##Objectives:
|
11
|
10
|
|
12
|
11
|
1. Apply nested loops and decision structures to manipulate bidimensional arrays and extract messages hidden in images.
|
13
|
12
|
|
|
@@ -16,7 +15,7 @@ One of the advantages of using computer programs is that we can easily implement
|
16
|
15
|
3. Use the binary representation of characters.
|
17
|
16
|
|
18
|
17
|
|
19
|
|
-## Pre-Lab:
|
|
18
|
+##Pre-Lab:
|
20
|
19
|
|
21
|
20
|
Before coming to the laboratory session you should have:
|
22
|
21
|
|
|
@@ -37,24 +36,24 @@ Before coming to the laboratory session you should have:
|
37
|
36
|
---
|
38
|
37
|
|
39
|
38
|
|
40
|
|
-## Steganography
|
|
39
|
+##Steganography
|
41
|
40
|
|
42
|
|
-Steganography is the science of camouflaging the presence of hidden messages in legitimate carriers (seemingly harmless files). This science has been used by cybercriminals to inflict damage to computer systems and by (old style) terrorists to encode hidden messages transmitted through the internet. There is claim that Al-Qaeda may have used steganography to encode messages into images, and then transport them via e-mail, and possibly via USENET, to prepare and execute the September 11, 2001 terrorist attack.
|
|
41
|
+Steganography is the science of camouflaging the presence of hidden messages in legitimate carriers (seemingly harmless files). This science has been used by cybercriminals to inflict damage to computer systems and by (old style) terrorists to encode hidden messages transmitted through the internet. There is claim that Al-Qaeda may have used steganography to encode messages into images, and then transport them via e-mail, and possibly via USENET, to prepare and execute the September 11, 2001 terrorist attack.
|
43
|
42
|
|
44
|
43
|
Steganography has some lawful uses too [1]:
|
45
|
44
|
|
46
|
|
-* A medical imaging laboratory can embed a patient's information into the images, thus preventing against fraud and/or patient misdiagnosis.
|
|
45
|
+* A medical imaging laboratory can embed a patient's information into the images, thus preventing against fraud and/or patient misdiagnosis.
|
47
|
46
|
* We can use hidden information to identify the legitimate owner of a document or image. If the document is leaked, or distributed to unauthorized parties, one can trace it back to the rightful owner and perhaps discover which party broke the license distribution agreement.
|
48
|
47
|
|
49
|
48
|
In this laboratory experience you will implement a simple algorithm to extract hidden messages from steganography images.
|
50
|
49
|
|
51
|
50
|
---
|
52
|
51
|
|
53
|
|
-## Image Editing
|
|
52
|
+##Image Editing
|
54
|
53
|
|
55
|
54
|
In this laboratory experience, you will recover secret messages that have been hidden in an image. To be able to carry out your task, you should understand some concepts related to images, be familiar with the methods of the `QImage` class in `Qt`, and with functions to work with data of the `QRgb` type.
|
56
|
55
|
|
57
|
|
-### Pixels
|
|
56
|
+###Pixels
|
58
|
57
|
|
59
|
58
|
The smallest element in an image is called a *pixel*. This unit consists of a single color. Since each color is a combination of tones for the primary red, green and blue colors, it is coded as an unsigned integer whose bytes represent the tones of red, green and blue of the pixel (Figure 1). This combination is called the color's *RGB* which is an acronym for "Red-Green-Blue". For example, a pure red pixel has an RGB representation of `0x00ff0000`, while a white pixel has an RGB representation of `0x00FFFFFF` (since the color white is a combination of tones of red, green and blue in all of their intensity).
|
60
|
59
|
|
|
@@ -68,7 +67,7 @@ The smallest element in an image is called a *pixel*. This unit consists of a si
|
68
|
67
|
|
69
|
68
|
`Qt` uses the `QRgb` type to represent `RGB` values. Using the functions that are described below we can perform important operations to analyze images, such as obtaining the RGB of each pixel in an image, and to obtain the red, green and blue components of the `QRgb` value of the pixel.
|
70
|
69
|
|
71
|
|
-### Library
|
|
70
|
+###Library
|
72
|
71
|
|
73
|
72
|
In today's laboratory experience you will use the `QImage` class. This class allows you to access the data in the pixels of an image to manipulate it. The documentation for the `QImage` class can be found in http://doc.qt.io/qt-4.8/qimage.html.
|
74
|
73
|
|
|
@@ -79,8 +78,8 @@ The code provided in the file `steganography.cpp` contains the following objec
|
79
|
78
|
|
80
|
79
|
The objects of the `QImage` class have the following methods that will be useful for today's laboratory experience:
|
81
|
80
|
|
82
|
|
-* `width()` // returns the positive integer value for the image's width
|
83
|
|
-* `height()` // returns the positive integer value for the image's height
|
|
81
|
+* `width()` // returns the positive integer value for the image's width
|
|
82
|
+* `height()` // returns the positive integer value for the image's height
|
84
|
83
|
* `pixel(i, j)` // returns the `QRgb` for the pixel in position `(i,j)`
|
85
|
84
|
|
86
|
85
|
|
|
@@ -92,7 +91,7 @@ The following functions are useful to work with data of type `QRgb`:
|
92
|
91
|
|
93
|
92
|
|
94
|
93
|
|
95
|
|
-#### Examples:
|
|
94
|
+####Examples:
|
96
|
95
|
|
97
|
96
|
1. If the following `4 x 4` image of pixels represents the object `origImage`,
|
98
|
97
|
|
|
@@ -132,7 +131,7 @@ int main() {
|
132
|
131
|
---
|
133
|
132
|
|
134
|
133
|
|
135
|
|
-### Embedding a message into an image
|
|
134
|
+###Embedding a message into an image
|
136
|
135
|
|
137
|
136
|
One of the simplest methods of *hidding* a message in an image is by encoding the message into the least significant bits of the image pixel's colors. This method effectively hides the message in the image because changing the least significant bit of a 8-bit color is barely noticeable by the human observer.
|
138
|
137
|
|
|
@@ -151,7 +150,7 @@ Let's illustrate the embedding procedure of the word "Dog" into the following im
|
151
|
150
|
|
152
|
151
|
![main3.png](images/main3.png)
|
153
|
152
|
|
154
|
|
-Assume that each square is a pixel of the image.
|
|
153
|
+Assume that each square is a pixel of the image.
|
155
|
154
|
|
156
|
155
|
The first step would be to obtain the ASCII representation of the message. The bits of the ASCII representation are the bits we will encode into the colors of the pixels. The ASCII representation of `Dog` is:
|
157
|
156
|
|
|
@@ -176,7 +175,7 @@ Input: p: a pixel
|
176
|
175
|
b2,b1,b0: the trio of bits
|
177
|
176
|
Output: modifiedPixel: the pixel with the embedded trio
|
178
|
177
|
========
|
179
|
|
-1. r = red component of p
|
|
178
|
+1. r = red component of p
|
180
|
179
|
2. g = green component of p
|
181
|
180
|
3. b = blue component of p
|
182
|
181
|
4. clear the least significant bits of r,g,b
|
|
@@ -225,12 +224,12 @@ The following are the color codes for first eight pixels of the original and mod
|
225
|
224
|
| `0x00 00 00` | `111` | `0x01 01 01` |
|
226
|
225
|
|
227
|
226
|
|
228
|
|
-Question:
|
|
227
|
+Question:
|
229
|
228
|
What message is hidden (using the least significant bit technique) in an image whose first 8 pixels are:
|
230
|
229
|
|
231
|
230
|
```
|
232
|
231
|
0x545554 0x666667 0x444544 0x333232
|
233
|
|
-0xff0000 0x0100ff 0x00ff00 0x10aaba
|
|
232
|
+0xff0000 0x0100ff 0x00ff00 0x10aaba
|
234
|
233
|
```
|
235
|
234
|
|
236
|
235
|
Explain your answer.
|
|
@@ -240,8 +239,26 @@ Explain your answer.
|
240
|
239
|
|
241
|
240
|
---
|
242
|
241
|
|
243
|
|
-!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-05.html"
|
|
242
|
+!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-01.html"
|
|
243
|
+<br>
|
|
244
|
+
|
|
245
|
+!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-02.html"
|
|
246
|
+<br>
|
|
247
|
+
|
|
248
|
+!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-03.html"
|
|
249
|
+<br>
|
|
250
|
+
|
|
251
|
+!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-04.html"
|
|
252
|
+<br>
|
|
253
|
+
|
|
254
|
+!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-05.html"
|
|
255
|
+<br>
|
|
256
|
+
|
|
257
|
+!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-06.html"
|
|
258
|
+<br>
|
244
|
259
|
|
|
260
|
+!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-07.html"
|
|
261
|
+<br>
|
245
|
262
|
|
246
|
263
|
---
|
247
|
264
|
|
|
@@ -252,45 +269,44 @@ Explain your answer.
|
252
|
269
|
|
253
|
270
|
In today's laboratory experience you will complete a steganography application to extract hidden messages from images.
|
254
|
271
|
|
255
|
|
-### Exercise 1: Extract the binary message
|
|
272
|
+###Exercise 1: Extract the binary message
|
256
|
273
|
|
257
|
|
-#### Instructions
|
|
274
|
+####Instructions
|
258
|
275
|
|
259
|
|
-1. Load the Qt project called `Steganography` by double-clicking on the `Steganography.pro` file in the `Documents/eip/Repetitions-Steganography` folder of your computer. You can also go to `http://bitbucket.org/eip-uprrp/repetitions-steganography` to download the `Repetitions-Steganography` folder to your computer.
|
|
276
|
+1) Load the Qt project called `Steganography` by double-clicking on the `Steganography.pro` file in the `Documents/eip/Repetitions-Steganography` folder of your computer. You can also go to `http://bitbucket.org/eip-uprrp/repetitions-steganography` to download the `Repetitions-Steganography` folder to your computer.
|
260
|
277
|
|
261
|
|
- The project contains the skeleton for an application to recover embedded messages from images. The messages that you will be recovering have been embedded using the least significant bit technique. The end of each message was encoded by using the ASCII character with binary code `00000000`.
|
|
278
|
+The project contains the skeleton for an application to recover embedded messages from images. The messages that you will be recovering have been embedded using the least significant bit technique. The end of each message was encoded by using the ASCII character with binary code `00000000`.
|
262
|
279
|
|
263
|
|
-2. Compile and run the program. You should obtain an interface that looks similar to:
|
|
280
|
+2) Compile and run the program. You should obtain an interface that looks similar to:
|
264
|
281
|
|
265
|
|
- ![img1.png](images/img1.png)
|
|
282
|
+![img1.png](images/img1.png)
|
266
|
283
|
|
267
|
|
-3. The button `Load Image` has already been programmed to allow the user to load an image and display it. Your task is to program the functionality of the button `Retrieve Message` to analyze the image and extract the hidden message. The hidden message should be displayed in the `Write a message` window.
|
|
284
|
+3) The button `Load Image` has already been programmed to allow the user to load an image and display it. Your task is to program the functionality of the button `Retrieve Message` to analyze the image and extract the hidden message. The hidden message should be displayed in the `Write a message` window.
|
268
|
285
|
|
269
|
|
-4. You will be working with the `steganography.cpp` file. Complete the `ExtractMessage` function that receives a steganography image so it extracts the digits of the binary message encoded in the image and stores them in a string. The function should invoke another function `binaryStringToMessage` that converts the string from `0`'s and `1`'s in the message's characters and returns the hidden message.
|
|
286
|
+4) You will be working with the `steganography.cpp` file. Complete the `ExtractMessage` function that receives a steganography image so it extracts the digits of the binary message encoded in the image and stores them in a string. The function should invoke another function `binaryStringToMessage` that converts the string from `0`'s and `1`'s in the message's characters and returns the hidden message.
|
270
|
287
|
|
271
|
288
|
|
272
|
|
- For example, if the first few pixels the image were these:
|
|
289
|
+For example, if the first few pixels the image were these:
|
273
|
290
|
|
274
|
|
- ````
|
275
|
|
- 0x98 99 98 0x00 00 01 0x00 00 00 0x01 01 00
|
276
|
|
- 0x01 01 01 0x01 00 01 0x01 00 00 0x01 01 01
|
277
|
|
- 0xf0 ea 00 0x44 00 f0 0x00 aa 22 . . . .
|
278
|
|
- ````
|
|
291
|
+````
|
|
292
|
+0x98 99 98 0x00 00 01 0x00 00 00 0x01 01 00
|
|
293
|
+0x01 01 01 0x01 00 01 0x01 00 00 0x01 01 01
|
|
294
|
+0xf0 ea 00 0x44 00 f0 0x00 aa 22 . . . .
|
|
295
|
+````
|
279
|
296
|
|
280
|
|
- your `ExtractMessage` function would extract the least significant bits of each colors component and construct the `string`: `"010001000110111101100111000000000.."`.
|
|
297
|
+your `ExtractMessage` function would extract the least significant bits of each colors component and construct the `string`: `"010001000110111101100111000000000.."`.
|
281
|
298
|
|
282
|
|
- Notice that your algorithm should have some mechanism for detecting if the last 8 character block were all `0`. When this happens, the algorithm should stop reading the pixels.
|
|
299
|
+Notice that your algorithm should have some mechanism for detecting if the last 8 character block were all `0`. When this happens, the algorithm should stop reading the pixels.
|
283
|
300
|
|
284
|
|
- The string of binary digits should then be sent to another function `binaryStringToMessage` (see Exercise 2) that interprets the `0`'s and `1`'s as the bits of ASCII characters. In the example, the string `”010001000110111101100111000000000”` would be decoded to "Dog"
|
285
|
|
- (because `01000100` corresponds to 'D', `01101111` is 'o', `01100111` is 'g', and a `00000000` symbolizes the end of the string.)
|
|
301
|
+The string of binary digits should then be sent to another function `binaryStringToMessage` (see Exercise 2) that interprets the `0`'s and `1`'s as the bits of ASCII characters. In the example, the string `”010001000110111101100111000000000”` would be decoded to "Dog" (because `01000100` corresponds to 'D', `01101111` is 'o', `01100111` is 'g', and a `00000000` symbolizes the end of the string.)
|
286
|
302
|
|
287
|
|
- To implement the algorithm for extracting the message, you should understand how the message was encoded. If necessary, review the "Embedding a message into an image" section.
|
|
303
|
+To implement the algorithm for extracting the message, you should understand how the message was encoded. If necessary, review the "Embedding a message into an image" section.
|
288
|
304
|
|
289
|
305
|
|
290
|
|
-### Exercise 2: Interpreting the message
|
|
306
|
+###Exercise 2: Interpreting the message
|
291
|
307
|
|
292
|
308
|
|
293
|
|
-#### Instructions
|
|
309
|
+####Instructions
|
294
|
310
|
|
295
|
311
|
1. Complete the `binaryStringToMessage` function that receives the string of `0`'s and `1`'s extracted from the image so it returns the hidden message. You can use the `binStringToChar` function to convert substrings of 8 `0`'s and `1`'s in its corresponding character.
|
296
|
312
|
|
|
@@ -299,7 +315,7 @@ In today's laboratory experience you will complete a steganography application t
|
299
|
315
|
* `pug.png`, contains the message "Hello World !"
|
300
|
316
|
* `uprTorre.png`, contains the message "CCOM3033 - Steganography Lab Rules!!!"
|
301
|
317
|
|
302
|
|
-3. Once you validate your program using the test images, use the program to analyze the following images.
|
|
318
|
+3. Once you validate your program using the test images, use the program to analyze the following images.
|
303
|
319
|
|
304
|
320
|
* `gallito.png`
|
305
|
321
|
* `puppy.png`
|
|
@@ -310,7 +326,7 @@ In today's laboratory experience you will complete a steganography application t
|
310
|
326
|
|
311
|
327
|
---
|
312
|
328
|
|
313
|
|
-## Deliverables
|
|
329
|
+##Deliverables
|
314
|
330
|
|
315
|
331
|
Use "Deliverables" in Moodle to upload the `steganography.cpp` file that contains the `ExtractMessage` and `binaryStringToMessage` functions. Remember to use good programming techniques, include the names of the programmers involved, and to document your program.
|
316
|
332
|
|
|
@@ -319,6 +335,6 @@ Use "Deliverables" in Moodle to upload the `steganography.cpp` file that contain
|
319
|
335
|
---
|
320
|
336
|
|
321
|
337
|
|
322
|
|
-## References
|
|
338
|
+##References
|
323
|
339
|
|
324
|
340
|
[1] Rocha, Anderson, and Siome Goldenstein. "Steganography and steganalysis in digital multimedia: Hype or hallelujah?." Revista de Informática Teórica e Aplicada 15.1 (2008): 83-110.
|