-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathscan-for-crypto.py
executable file
·55 lines (40 loc) · 1.75 KB
/
scan-for-crypto.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
#!/usr/bin/python3
"""
Copyright (c) 2017 Wind River Systems, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
OR CONDITIONS OF ANY KIND, either express or implied.
Encryption Identification Scanner command line interface
"""
import sys
if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 4):
print("Unsupported Python version " + str(sys.version))
print("\nRequires Python version 3.4 or later.")
sys.exit(1)
import traceback
from cryptodetector import CryptoDetector, Output, Options, Logger, FileLister
from cryptodetector.exceptions import CryptoDetectorError
if __name__ == '__main__':
try:
log_output_directory = None
options = Options(CryptoDetector.VERSION).read_all_options()
if "log" in options:
if options["log"]:
log_output_directory = options["output"]
CryptoDetector(options).scan()
print("done")
except CryptoDetectorError as expn:
Output.print_error(str(expn))
if log_output_directory: Logger.write_log_files(log_output_directory)
FileLister.cleanup_all_tmp_files()
except KeyboardInterrupt:
FileLister.cleanup_all_tmp_files()
raise
except Exception as expn:
Output.print_error("Unhandled exception.\n\n" + str(traceback.format_exc()))
if log_output_directory: Logger.write_log_files(log_output_directory)
FileLister.cleanup_all_tmp_files()