-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcafuse.py
executable file
·61 lines (49 loc) · 1.7 KB
/
mcafuse.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import trio
import pyfuse3
from mcafee_fde import McafeeFde
from crypto_handler import CryptoHandler
from utils import parse_args, init_logging, log, check_signature, check_if_files_exist
def main():
options = parse_args()
init_logging(options.debug)
if options.verbose:
log.info('|++| Starting McAfuse...')
crypto_hnl = None
mcafee_fde = None
try:
check_if_files_exist(options.disk_image, options.keyfile, options.mountpoint)
check_signature(options.disk_image, b'#SafeBoot', 0x2)
if options.keyfile:
crypto_hnl = CryptoHandler(options.keyfile, options.verbose)
mcafee_fde = McafeeFde(
options.disk_image,
crypto_hnl,
options.info,
options.all,
options.verbose
)
except (ValueError, FileNotFoundError, NotADirectoryError, NotImplementedError) as ex:
log.error(ex)
return
fuse_options = set(pyfuse3.default_options)
fuse_options.add('fsname=McAFuse')
fuse_options.add('allow_other') # to allow user to navigate fuse fs
try:
pyfuse3.init(mcafee_fde, options.mountpoint, fuse_options)
trio.run(pyfuse3.main)
except RuntimeError as re:
log.error(re)
log.error('|!| -- [ERROR] -- The program need administrative privileges, try with sudo')
return
except:
log.warning('|--| Terminated with CTRL-C (SIGINT)...')
log.warning('|--| Unmounting...')
pyfuse3.close(unmount=True)
return
if options.verbose:
log.info('|++| Gracefully terminating McAfuse...')
pyfuse3.close()
if __name__ == '__main__':
main()