-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.py
More file actions
84 lines (71 loc) · 2.29 KB
/
main.py
File metadata and controls
84 lines (71 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from sys import argv
from hide import hide
from extract import extract
usage = """
Usage : python ./main.py [hide/extract] [OPTIONS]
hide options :
-f <file_path> \tCover file
-d <file_path> \tData file
-p <string>\tpassword
-o <file_path>\tOutput file
extract options :
-f <file_path> \tfile to extract data from
-p <string> \tpassword
-o <file_path>\tOutput file
-h/--help\tPrint this help
"""
def exiting():
print(usage)
exit(0)
try:
mode = argv[1]
if "-h" in argv or "--h" in argv:
exiting()
if "hide" in argv and "extract" in argv:
print("Hide and Extract cannot be used together")
exit()
elif mode == "hide":
if "-f" not in argv or "-d" not in argv:
print("One or more required flags were not given.")
print("Use --help for usage info.")
exit()
try:
cover = argv[argv.index('-f') + 1]
except ValueError:
print("No Cover File Specified.")
exit()
try:
dataFile = argv[argv.index('-d') + 1]
except ValueError:
print("No Data file File Specified")
exit()
try:
password = argv[argv.index('-p') + 1]
except ValueError:
print("WARNING : No password given 'demo' will be used as password.")
password = "demo"
try:
outputFile = argv[argv.index('-o') + 1]
except ValueError:
print(f"No output File Specified 'hidden {cover}' will be used as output file")
outputFile = "hidden " + cover
print(hide(dataFile, cover, outputFile, password))
elif mode == "extract":
try:
file = argv[argv.index('-f') + 1]
except Exception:
print("No file Specified")
exit(1)
try:
password = argv[argv.index('-p') + 1]
except Exception:
print("WARNING : No password given 'demo' will be used as password ")
password = 'demo'
try:
outputFile = argv[argv.index('-o') + 1]
except Exception:
print(f"No output File Specified 'extracted_{file}' will be used as output file")
outputFile = "extracted_" + file
print(extract(file, password, outputFile))
except IndexError:
exiting()