Skip to content

Commit 7aacd33

Browse files
authored
Merge pull request #1 from lorossi/development
Development
2 parents 3455343 + 833e2b7 commit 7aacd33

File tree

8 files changed

+1262
-913
lines changed

8 files changed

+1262
-913
lines changed

.gitignore

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/__pycache__
2-
/src
3-
/old
4-
/test
5-
*.txt
6-
*.log
1+
__pycache__
2+
venv
3+
.vscode
4+
.coverage

LICENSE

Lines changed: 21 additions & 407 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ So this is how I got the inspiration. Neat, isn't it?
1414

1515
## Looking for the right way
1616

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.
1818
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)
1919

2020
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
2626
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.
2727
This could actually work, with the small limitation of actually adding some visible spacing inside the "container" text.
2828

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.
3030
I still don't really understand how they could be legitimately used inside a document, but I chose to ride with this.
3131

3232
## How I did it
@@ -40,12 +40,12 @@ To decode an encrypted string, I just need to convert those strange spaces back
4040

4141
I made two Python3 scripts:
4242

43-
1. `zerowidthspy.py` - the main module. Its name stands for *Zero Width Steganography [in] Python*
43+
1. `zerowidth.py` - the main module
4444
2. `zero-width-steganography.py` - a wrapper, built around the aforementioned module, to quickly encode/decode/clean files
4545

4646
Those next sections will explain how to use the second script.
4747

48-
## Encoding
48+
### Encoding
4949

5050
You can either provide a file text or a string as a source file. The hidden text will be hidden in here.
5151
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.
5454

5555
The next step is to state where you want to put the hidden string inside the source text. The options are:
5656

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.
6262

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.
6465

65-
## Decoding
66+
### Decoding
6667

6768
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.
6869

69-
If you use the *verbose* command, more infos about the found text will be given.
70-
71-
## Cleaning
70+
### Cleaning
7271

7372
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.
7473

75-
## Logging and verbose mode
74+
## Examples
7675

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`
7881

7982
## Documentation
8083

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

Comments
 (0)