1
2
3
4
5
6 import logging
7 import os.path
8 import subprocess
9
10 from lib.common.abstracts import Auxiliary
11
12 log = logging.getLogger(__name__)
13
15 """Install our man in the middle certificate into the Trusted Root
16 Certification Authorities certificate store so we can listen in on https
17 traffic."""
19 if "cert" not in self.options:
20 return
21
22 cert_path = self.options["cert"]
23
24 if not cert_path.endswith(".p12"):
25 log.error("An invalid certificate has been provided - only "
26 "PFX certificates, with file extension .p12, are "
27 "supported.")
28 return
29
30 if not os.path.exists(cert_path):
31 log.error("Certificate file not found: %s. (Keep in mind that "
32 "the certificate must be located in the "
33 "analyzer/windows/ directory).", cert_path)
34 return
35
36 p = subprocess.Popen(["certutil.exe", "-importpfx", cert_path],
37 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
38 stderr=subprocess.PIPE)
39
40
41
42 p.communicate("")
43
44 log.info("Successfully installed PFX certificate.")
45