(self, md5)
Retreives a PCAP files from VT using the Private API.

        Args:
            md5 (String): MD5 of the sample we would like to pull the pcap from.

        TODO:
            Add optional switch in the get request to store the pcap as a temp
            file before adding it to CRITs. Switch is stream=True and CRITs
            provides a handler for temp files.
            Make Error message uniform like the rest
Retreives a PCAP files from VT using the Private API.
Retreives a PCAP files from VT using the Private API .
def get_pcap(self, md5):
        """
        Retreives a PCAP files from VT using the Private API.

        Args:
            md5 (String): MD5 of the sample we would like to pull the pcap from.

        TODO:
            Add optional switch in the get request to store the pcap as a temp
            file before adding it to CRITs. Switch is stream=True and CRITs
            provides a handler for temp files.
            Make Error message uniform like the rest
        """
        network_url = self.config.get('vt_network_url', '')
        params = {'apikey': self.config.get('vt_api_key', ''), 'hash': md5}

        if settings.HTTP_PROXY:
            proxies = { 'http': settings.HTTP_PROXY,
                        'https': settings.HTTP_PROXY }
        else:
            proxies = {}

        try:
            response = requests.get(network_url, params=params, proxies=proxies)
        except Exception as e:
            key = self.config.get('vt_api_key', '')
            error = str(e).replace(key, 'REDACTED')
            logger.error("Virustotal: network connection error for PCAP (%s)" % error)
            self._error("Network connection error checking virustotal for PCAP (%s)" % error)
            return None

        if response.headers['content-type'] == 'application/cap':
            self._info("Gathered PCAP file for %s" % md5)
            return response.content
        elif response.headers['content-type'] == 'application/json':
            self._warning("Could not fetch PCAP for hash %s" % md5)
            return None
        else:
            self._warning("Could not fetch PCAP for unknown reasons")
            return None
def get_pcap ( self , md5 ) : network_url = self . config . get ( 'vt_network_url' , '' ) params = { 'apikey' : self . config . get ( 'vt_api_key' , '' ) , 'hash' : md5 } if settings . HTTP_PROXY : proxies = { 'http' : settings . HTTP_PROXY , 'https' : settings . HTTP_PROXY } else : proxies = { } try : response = requests . get ( network_url , params = params , proxies = proxies ) except Exception as e : key = self . config . get ( 'vt_api_key' , '' ) error = str ( e ) . replace ( key , 'REDACTED' ) logger . error ( "Virustotal: network connection error for PCAP (%s)" % error ) self . _error ( "Network connection error checking virustotal for PCAP (%s)" % error ) return None if response . headers [ 'content-type' ] == 'application/cap' : self . _info ( "Gathered PCAP file for %s" % md5 ) return response . content elif response . headers [ 'content-type' ] == 'application/json' : self . _warning ( "Could not fetch PCAP for hash %s" % md5 ) return None else : self . _warning ( "Could not fetch PCAP for unknown reasons" ) return None