-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstegmachine.py
executable file
·62 lines (51 loc) · 2.19 KB
/
stegmachine.py
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
import argparse
import logging
import sys
from PIL import Image
from modules.analysis import Analyzer
from tests import start_tests
parser = argparse.ArgumentParser(add_help=True,
description='StegMachine is a flexible tool for stegoanalysis.')
mode_group = parser.add_mutually_exclusive_group(required=True)
mode_group.add_argument('--analysis', nargs='?', type=str, choices=['exif', 'chi', 'spa', 'rs', 'visual'],
help='Analyzing module')
mode_group.add_argument('--hiding', nargs='?', type=str, choices=[], help='Hiding module')
mode_group.add_argument('--test', action='store_true', help='Test module')
mode_group.add_argument('--generation', action='store_true', help='Generation module')
params_group = parser.add_mutually_exclusive_group(
)
params_group.add_argument('-b', nargs='?', type=int, choices=range(0, 255), metavar='from 0 to 255',
help="What bit should be displayed in the visual attack")
params_group.add_argument('-j',action='store_true',
help="Joins channels into one image")
parser.add_argument('input_file', type=argparse.FileType('r'))
parser.add_argument('ouput_dir', type=str)
if __name__ == "__main__":
if len(sys.argv) < 2:
parser.print_help()
else:
args = parser.parse_args()
img = Image.open(args.input_file.name)
# img.verify()
if args.analysis:
an = Analyzer()
if args.analysis == "exif":
an.exif(args.input_file.name)
elif args.analysis == "visual":
if args.b:
an.visual_attack(img, bitnum=args.b)
elif args.j:
print(args.j)
an.visual_attack(img, join=True)
else:
an.visual_attack(img)
elif args.analysis == "chi":
an.chi_squared_attack(img)
elif args.analysis == "spa":
an.spa_attack(img)
elif args.analysis == "rs":
an.rs_attack(img)
elif args.test:
start_tests()
else:
logging.info("Invalid operation specified! ❌")