You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-17Lines changed: 22 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ So this is how I got the inspiration. Neat, isn't it?
14
14
15
15
## Looking for the right way
16
16
17
-
At this point I had to start tinkering on how I could concretize this project.
17
+
At this point I had to start tinkering on how I could realize this project.
18
18
Snooping through Wikipedia, I started looking for characters that could be hidden inside text files without being too noticeable. Instantly, I was very surprising by discovering that Greek question marks (;) are very similar (if not completely unrecognizable!) to regular semicolons (;). I thought that maybe I could find a way to swap them in some clever way to hide text. But honestly, unless you are working with C/C++ code, how often do you use semicolons? (This similarity can be used to prank a programmer. Just replace every semicolon and watch him *-and his compiler-* go crazy)
19
19
20
20
So at this point, I was lost. There are *1,112,064 different characters* encoded by UTF-8. I mean, it's bound to create some very similar symbols, right? Sadly, after scrolling a while (a very long while) through the list of every character it dawned to me that this couldn't be the right path.
@@ -26,7 +26,7 @@ Almost ready to give up, my eyes noticed a very strange table named *General Pun
26
26
So, basically, *whitespaces* are special character that, as the name suggests, leave some space (usually, white) between characters. I started exploring them, toying with the idea of converting some text in space.
27
27
This could actually work, with the small limitation of actually adding some visible spacing inside the "container" text.
28
28
29
-
Some Googling later, I discovered that there are 2 different space characters that add no visible space to the file: *U+200B***(ZERO WIDTH SPACE)** and *U+FEFF***(ZERO WIDTH NO-BREAK SPACE)**. These characters are actually invisible to the user and don't show up while writing.
29
+
Some Googling later, I discovered that there are 2 different space characters that add no visible space to the file: `U+200B`**(ZERO WIDTH SPACE)** and `U+FEFF`**(ZERO WIDTH NO-BREAK SPACE)**. These characters are actually invisible to the user and don't show up while writing.
30
30
I still don't really understand how they could be legitimately used inside a document, but I chose to ride with this.
31
31
32
32
## How I did it
@@ -40,12 +40,12 @@ To decode an encrypted string, I just need to convert those strange spaces back
40
40
41
41
I made two Python3 scripts:
42
42
43
-
1.`zerowidthspy.py` - the main module. Its name stands for *Zero Width Steganography [in] Python*
43
+
1.`zerowidth.py` - the main module
44
44
2.`zero-width-steganography.py` - a wrapper, built around the aforementioned module, to quickly encode/decode/clean files
45
45
46
46
Those next sections will explain how to use the second script.
47
47
48
-
## Encoding
48
+
###Encoding
49
49
50
50
You can either provide a file text or a string as a source file. The hidden text will be hidden in here.
51
51
Then you must provide some text that will be encrypted and hidden in the source. As for the source file, you can either supply it inline or load from a file.
@@ -54,28 +54,33 @@ You must then provide a destination file that will contain the hidden text.
54
54
55
55
The next step is to state where you want to put the hidden string inside the source text. The options are:
56
56
57
-
**Top* - the hidden string will be put at the very beginning of the text file.
58
-
**Bottom* - the hidden string will be put at the end the text file.
59
-
**Nth* - the hidden text will be placed at the end of every nth line.
60
-
**Lines* - the hidden text will be placed at the end of every specified line.
61
-
**Random* - the hidden text will be placed in random positions all through the document.
57
+
**TOP* - the hidden string will be put at the very beginning of the text file.
58
+
**BOTTOM* - the hidden string will be put at the end the text file.
59
+
**RANDOM* - the hidden text will be placed in random positions all through the document.
60
+
**NTHLINES* - the hidden text will be placed at the end of every nth line.
61
+
**RANDOMINLINE* - the hidden text will be placed in random positions in the lines of the source.
62
62
63
-
If you either chose *Random* or *Nth* you must provide respectively the number of occurrences or how many lines you want to skip at every iteration
63
+
If you either chose *RANDOM*, *NTHLINES* or *RANDOMINLINE* you can provide one more parameter (*k*) which represents number of occurrences (for *RANDOM* or *RANDOMINLINE*) or how many lines you want to skip at every iteration (for *NTHLINES*).
64
+
Its value will default to 1.
64
65
65
-
## Decoding
66
+
###Decoding
66
67
67
68
Like in *Encoding*, you must provide a file text as source and you can provide a file destination. If you chose to not do so, the decoded text (if found) will be shown in console.
68
69
69
-
If you use the *verbose* command, more infos about the found text will be given.
70
-
71
-
## Cleaning
70
+
### Cleaning
72
71
73
72
The script also has the ability to clean a file containing hidden text. Just provide a source file and a destination. If you omit the destination, the source file will be overwritten.
74
73
75
-
## Logging and verbose mode
74
+
## Examples
76
75
77
-
This script logs everything inside a log file named "zero-width-steganography.log". Furthermore, if you want to have more information on what the script is doing, use the *--verbose* parameter.
76
+
* Hide the string `HELLO THERE, GENERAL KENOBI` at the end of the the file `obiwankenobi.txt` sourcing the text from `beemovie.txt`: `python3 zero-width-steganography.py -E -t "HELLO THERE GENERAL KENOBI" -f beemovie.txt -o obiwankenobi.txt`
77
+
* Hide the string `I DON'T LIKE SAND` in 10 different positions inside the `coarse.txt` file and output to console:
78
+
`python3 zero-width-steganography.py -E -t "I DON'T LIKE SAND" -f coarse.txt`
79
+
* Find the hidden test from the file `shrek.txt` and output to console: `python3 zero-width-steganography.py -D -f shrek.txt`
80
+
* Clear the file `cars-3-pixar-final` from all hidden strings: `python3 zero-width-steganography.py -C -f cars-3-pixar-final -o cars-3-pixar-final`
78
81
79
82
## Documentation
80
83
81
-
This code doesn't need any particular module. It will work with the pre installed packages.
84
+
The documentation can be found [here]().
85
+
86
+
This code doesn't need any particular module. It will work with the pre installed packages.
0 commit comments