1.0.1 commits

This commit is contained in:
Joshua | Tommaso
2023-11-30 22:39:32 +01:00
parent ed703eec41
commit 11074fe8d6
6 changed files with 56 additions and 6 deletions

View File

@@ -47,6 +47,8 @@
- **Encryption:** Encrypt the hidden file with a password of your choice *(coming soon)*.
- **Compression:** Compress the hidden file to reduce its size *(coming soon)*.
- **Multiple Files:** Hide multiple files inside an image *(coming soon)*.
- **Stealth Mode:** Hide the fact that the image contains a hidden file *(coming soon)*.
- **User settings:** Save your preferences for future use *(coming soon)*.
# How it works
@@ -111,7 +113,7 @@ python vangonography.py -cli
```
You can then use the following arguments along with it:
```console
usage: vangonography.py [-h] [-ood] [-l LOG_FILE] [-cli] [-o OUTPUT_DIR] [-v] [-s] [-e] [-d] [-c COVER_IMAGE]
usage: vangonography.py [-h] [-ood] [-l] [-cli] [-o OUTPUT_DIR] [-v] [--encrypt] [--decrypt] [--key KEY] [--json JSON_FILE] [--stealth] [-s] [-e] [-d] [-c COVER_IMAGE]
[-f HIDDEN_FILE]
Van Gonography is a steganography tool that hides files in images.
@@ -121,20 +123,23 @@ options:
Optional arguments:
-ood Open file after decoding from image (default: False)
-l LOG_FILE, --log LOG_FILE
Log file for the program (default: False)
-l, --log Log file for the program (default: False)
-cli Run the program in CLI mode, this means there's not gonna be any menu (default: False)
-o OUTPUT_DIR, --output OUTPUT_DIR
Output directory for the modified image or revealed file
-v, --version Show the version number and exit
--encrypt Encrypt the data before hiding it (default: False)
--decrypt Decrypt the data after revealing it (default: False)
--key KEY Key to decrypt the data (default: None)
--json JSON_FILE JSON file containing the arguments (default: None)
--stealth Hides the file in stealth mode (default: False)
Positional arguments (only used in CLI mode):
-s, --show Show the difference between two images (default: False)
-e, --encode Encode the file in the image (default: False)
-d, --decode Decode the file hidden in the image (default: False)
-c COVER_IMAGE, --cover COVER_IMAGE
Image to be used for hiding or revealing, positional only when using decoding, encoding or
differentiate
Image to be used for hiding or revealing, positional only when using decoding, encoding or differentiate
-f HIDDEN_FILE, --file HIDDEN_FILE
File to be hidden
```

7
configs/decoding.json Normal file
View File

@@ -0,0 +1,7 @@
{
"desc": "This is a sample config file for decoding a .txt file inside one of the cover images provided in the img folder, no logging.",
"cli": true,
"decode": true,
"output": "",
"cover": "Cover_txt.png"
}

9
configs/encoding.json Normal file
View File

@@ -0,0 +1,9 @@
{
"desc": "This is a sample config file for encoding a .txt file inside one of the cover images provided in the img folder and includes the logging option.",
"cli": true,
"encode": true,
"output": "",
"log": true,
"file": "tests/input/Test.txt",
"cover": "../img/Cat.jpg"
}

4
configs/ui.json Normal file
View File

@@ -0,0 +1,4 @@
{
"desc": "This is a basic example of how to run the program in the UI mode, I'm setting the -cli argument to false, but you don't actually need to do that in the command line.",
"cli": false
}

View File

@@ -1,6 +1,7 @@
import os
import io
import sys
import json
import logging
import argparse
@@ -417,13 +418,16 @@ def main():
# Optional arguments
optional_group = parser.add_argument_group('Optional arguments')
optional_group.add_argument("-ood", dest="ood", action="store_true", default=False, help="Open file after decoding from image (default: False)")
optional_group.add_argument("-l", "--log", dest="log", type=str, default=False, metavar="LOG_FILE", help="Log file for the program (default: False)")
optional_group.add_argument("-l", "--log", dest="log", action="store_true", default=False, help="Log file for the program (default: False)")
optional_group.add_argument("-cli", dest="cli", action="store_true", default=False, help="Run the program in CLI mode, this means there's not gonna be any menu (default: False)")
optional_group.add_argument("-o", "--output", dest="output", type=str, metavar="OUTPUT_DIR", help="Output directory for the modified image or revealed file")
optional_group.add_argument("-v", "--version", action="version", version=f"VanGonography v{__version__}", help="Show the version number and exit")
optional_group.add_argument("--encrypt", dest="encrypt", action="store_true", default=False, help="Encrypt the data before hiding it (default: False)")
optional_group.add_argument("--decrypt", dest="decrypt", action="store_true", default=False, help="Decrypt the data after revealing it (default: False)")
optional_group.add_argument("--key", dest="key", type=str, metavar="KEY", help="Key to decrypt the data (default: None)")
optional_group.add_argument("--json", dest="json", type=str, metavar="JSON_FILE", help="JSON file containing the arguments (default: None)")
optional_group.add_argument("--stealth", dest="stealth", action="store_true", default=False, help="Hides the file in stealth mode (default: False)") # TODO: Implement this shit
# For anyone wondering, I have no idea how to implement the stealth mode, so if you want to share some ideas
# Positional arguments group (only used in CLI mode)
positional_group = parser.add_argument_group('Positional arguments (only used in CLI mode)')
@@ -435,6 +439,20 @@ def main():
args = parser.parse_args()
# Getting the json file and setting the arguments
if args.json:
with open(args.json, "r") as json_file:
json_data = json.load(json_file)
json_data.pop("desc") # Removing the description argument for not causing errors when setting the attributes
for key, value in json_data.items(): # Looping through the json file data
if hasattr(args, key): # Checking if the key exists in the args variable
setattr(args, key, value) # The args variable is a Namespace object
else:
print(f"Invalid argument was passed, double check the argument name and try again: {key}")
logging.error(f"Invalid argument: {key}")
return
# Checking for CLI mode
if args.cli:
# Logging setup

7
src/log.log Normal file
View File

@@ -0,0 +1,7 @@
2023-11-30 22:08:40 - INFO - Logging started
2023-11-30 22:08:40 - INFO - Arguments: Namespace(ood=False, log='log.log', cli=True, output='', encrypt=False, decrypt=False, key=None, json='options.json', show=False, encode=True, decode=False, cover='../img/Cat.jpg', file='tests/input/Test.txt')
2023-11-30 22:08:40 - INFO - Encoding started
2023-11-30 22:08:40 - INFO - Encoding tests/input/Test.txt in ../img/Cat.jpg
2023-11-30 22:08:40 - DEBUG - STREAM b'IHDR' 16 13
2023-11-30 22:08:40 - DEBUG - STREAM b'IDAT' 41 65536
2023-11-30 22:08:40 - INFO - File hidden successfully in ../img/Cat.jpg.