summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmat31
1 files changed, 12 insertions, 19 deletions
diff --git a/mat b/mat
index a9fb5f3..1f59e62 100755
--- a/mat
+++ b/mat
@@ -16,8 +16,7 @@ from MAT import archive
16 16
17 17
18def parse(): 18def parse():
19 ''' 19 ''' Get, and parse options passed to the program
20 Get, and parse options passed to the program
21 ''' 20 '''
22 parser = optparse.OptionParser(usage='%prog [options] files\n\ 21 parser = optparse.OptionParser(usage='%prog [options] files\n\
23The default behaviour is to clean files given in argument') 22The default behaviour is to clean files given in argument')
@@ -49,33 +48,30 @@ The default behaviour is to clean files given in argument')
49 48
50 49
51def display_version(*_): 50def display_version(*_):
51 ''' Display the program's version, and exit
52 ''' 52 '''
53 Display the program's version, and exit 53 print('Metadata Anonymisation Toolkit %s' % mat.__version__)
54 ''' 54 print('Hachoir %s' % hachoir_core.__version__)
55 print('Metadata Anonymisation Toolkit version %s') % mat.__version__
56 print('Hachoir version %s') % hachoir_core.__version__
57 sys.exit(0) 55 sys.exit(0)
58 56
59 57
60def list_meta(class_file, filename, add2archive): 58def list_meta(class_file, filename, add2archive):
61 ''' 59 ''' Print all the metadata of 'filename' on stdout
62 Print all the metadata of 'filename' on stdout
63 ''' 60 '''
64 print('[+] File %s :' % filename) 61 print('[+] File %s :' % filename)
65 if class_file.is_clean(): 62 if class_file.is_clean():
66 print('No harmful metadata found') 63 print('No harmful metadata found')
67 else: 64 else:
68 meta = class_file.get_meta()
69 print ('Harmful metadata found:') 65 print ('Harmful metadata found:')
66 meta = class_file.get_meta()
70 if meta: 67 if meta:
71 for key, value in class_file.get_meta().iteritems(): 68 for key, value in class_file.get_meta().iteritems():
72 print('\t' + key + ' : ' + str(value)) 69 print('\t%s: %s' % (key, value))
73 return 0 70 return 0
74 71
75 72
76def is_clean(class_file, filename, add2archive): 73def is_clean(class_file, filename, add2archive):
77 ''' 74 ''' Tell if 'filename' is clean or not
78 Say if 'filename' is clean or not
79 ''' 75 '''
80 if class_file.is_clean(): 76 if class_file.is_clean():
81 print('[+] %s is clean' % filename) 77 print('[+] %s is clean' % filename)
@@ -85,8 +81,7 @@ def is_clean(class_file, filename, add2archive):
85 81
86 82
87def clean_meta(class_file, filename, add2archive): 83def clean_meta(class_file, filename, add2archive):
88 ''' 84 ''' Clean the file 'filename'
89 Clean the file 'filename'
90 ''' 85 '''
91 if not class_file.is_writable: 86 if not class_file.is_writable:
92 print('[-] %s is not writable' % filename) 87 print('[-] %s is not writable' % filename)
@@ -112,8 +107,7 @@ def clean_meta(class_file, filename, add2archive):
112 107
113 108
114def list_supported(): 109def list_supported():
115 ''' 110 ''' Print all supported fileformat, and exit
116 Print all supported fileformat, and exit
117 ''' 111 '''
118 for item in mat.list_supported_formats(): 112 for item in mat.list_supported_formats():
119 print('%s (%s)' % (item['name'], item['extension'])) 113 print('%s (%s)' % (item['name'], item['extension']))
@@ -126,12 +120,11 @@ def list_supported():
126 120
127 121
128def main(): 122def main():
129 ''' 123 ''' Main function : get args and launch the appropriate function
130 main function : get args, and launch the appropriate function
131 ''' 124 '''
132 args, filenames = parse() 125 args, filenames = parse()
133 126
134 #func receive the function corresponding to the options given as parameters 127 #func receives the function corresponding to the options given as parameters
135 if args.display: # only print metadatas 128 if args.display: # only print metadatas
136 func = list_meta 129 func = list_meta
137 elif args.check: # only check if the file is clean 130 elif args.check: # only check if the file is clean