MCPcopy Create free account
hub / github.com/adobe/Marinus / VirusTotal

Class VirusTotal

python3_cron_scripts/libs3/VirusTotal.py:26–103  ·  view source on GitHub ↗

This class is designed for interacting with VirusTotal service. It currently supports fetching domain reports.

Source from the content-addressed store, hash-verified

24
25
26class VirusTotal(object):
27 """
28 This class is designed for interacting with VirusTotal service.
29 It currently supports fetching domain reports.
30 """
31
32 virustotal_config_file = "connector.config"
33 PRIVATE_APIKEY = None
34 PUBLIC_APIKEY = None
35 APIKEY = None
36 URL = None
37 _logger = None
38
39 def _log(self):
40 """
41 Get the log
42 """
43 return logging.getLogger(__name__)
44
45 def _init_vt(self, config):
46 self.URL = ConnectorUtil.get_config_setting(
47 self._logger, config, "VirusTotal", "virustotal.url"
48 )
49 self.PRIVATE_APIKEY = ConnectorUtil.get_config_setting(
50 self._logger, config, "VirusTotal", "virustotal.apikey"
51 )
52 self.PUBLIC_APIKEY = ConnectorUtil.get_config_setting(
53 self._logger, config, "VirusTotal", "virustotal.public_apikey"
54 )
55
56 def __init__(self, config_file="", key="public", log_level=None):
57 if config_file != "":
58 self.virustotal_config_file = config_file
59
60 self._logger = self._log()
61 if log_level is not None:
62 self._logger.setLevel(log_level)
63
64 config = configparser.ConfigParser()
65 list = config.read(self.virustotal_config_file)
66 if len(list) == 0:
67 self._logger.error("Error: Could not find the config file")
68 exit(1)
69
70 self._init_vt(config)
71
72 if key == "private":
73 self.APIKEY = self.PRIVATE_APIKEY
74 else:
75 self.APIKEY = self.PUBLIC_APIKEY
76
77 def get_domain_report(self, domain):
78 """
79 Get The Virustotal report for the given domain.
80
81 :param domain: The name of the domain to search.
82 :return: The JSON response or None if not found.
83 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected