-
Notifications
You must be signed in to change notification settings - Fork 18
/
decipher.py
54 lines (42 loc) · 1.58 KB
/
decipher.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# markransom.py - decipher
# https://www.github.com/R3nt0n/markransom
__author__ = "r3nt0n"
__license__ = "GPL 3.0"
__version__ = "1.0.0"
__email__ = "[email protected]"
__status__ = "Development"
import os, sys
import argparse
from lib.cryptor import find_root_paths, find_files_and_do, decipher
def proc_args():
parser = argparse.ArgumentParser(description='Decrypt files encrypted with markransom.py.')
parser.add_argument('-k', '--key', action="store", metavar='file',type=str,dest='key', required=True,
help='the file which includes the key')
parser.add_argument('-e', '--extension', action="store", metavar='.ext', type=str, dest='ext',
help='encrypted files extension')
parser.add_argument('-f', '--file', action="store", metavar='file', type=str,dest='crypted_file', default='False',
help='decrypt a single file')
args = parser.parse_args()
key = args.key
ext = args.ext
crypted_file = args.crypted_file
if not (ext and crypted_file):
print 'Too few arguments, -e or -f are required. Exiting...'
sys.exit(3)
return key,ext,crypted_file
def main():
# Proc args
key, ext, crypted_file = proc_args()
e = []
e.append(ext)
file_list = []
# Find files
if crypted_file:
status = decipher(crypted_file, key, ext)
else:
root_paths = find_root_paths()
file_list = find_files_and_do(root_paths, e, key, action='decrypt', crypted_ext=ext)
if __name__ == '__main__':
main()