Example #1
0
def ip_lookup(ip):
	''' Lookup IP information VirusTotal. '''
	# Query
	response_dict = ""
	try:
		# Check cache
		cache = load_cache(ip)
		if cache:
			return cache
			
		# Query VT
		ip_parameters = {'ip': ip, 'apikey': API_KEY}
		response = urllib.urlopen('%s?%s' % (ip_query_url, urllib.urlencode(ip_parameters))).read()
		response_dict = json.loads(response)
		
		# Cache results
		dump_cache(ip, response_dict)
	except Exception as e:
		exit(e)
	return response_dict
Example #2
0
def sample_lookup(hash):
	# Query
	response_dict = ""
	try:
		# Check cache
		cache = load_cache(hash)
		if cache:
			return cache
			
		# Query VT
		hash_parameters = {'resource': hash, 'apikey': API_KEY}
		response = urllib.urlopen('%s?%s' % (file_url, urllib.urlencode(hash_parameters))).read()
		response_dict = json.loads(response)

		
		# Cache results
		dump_cache(hash, response_dict)
	except Exception as e:
		exit(e)
	return response_dict
Example #3
0
def domain_lookup(domain):
	''' Lookup domain information VirusTotal. '''
	# Query
	response_dict = ""
	try:
		# Check cache
		cache = load_cache(domain)
		if cache:
			return cache
		
		# Query VT
		domain_parameters = {'domain': domain, 'apikey': API_KEY}
		response = urllib.urlopen('%s?%s' % (domain_query_url, urllib.urlencode(domain_parameters))).read()
		response_dict = json.loads(response)
		
		# Cache results
		dump_cache(domain, response_dict)
	except Exception as e:
		exit(e)
	return response_dict
Example #4
0
def ip_lookup(ip):
    ''' Lookup IP information VirusTotal. '''
    # Query
    response_dict = ""
    try:
        # Check cache
        cache = load_cache(ip)
        if cache:
            return cache

        # Query VT
        ip_parameters = {'ip': ip, 'apikey': API_KEY}
        response = urllib.urlopen(
            '%s?%s' % (ip_query_url, urllib.urlencode(ip_parameters))).read()
        response_dict = json.loads(response)

        # Cache results
        dump_cache(ip, response_dict)
    except Exception as e:
        exit(e)
    return response_dict
Example #5
0
def domain_lookup(domain):
    ''' Lookup domain information VirusTotal. '''
    # Query
    response_dict = ""
    try:
        # Check cache
        cache = load_cache(domain)
        if cache:
            return cache

        # Query VT
        domain_parameters = {'domain': domain, 'apikey': API_KEY}
        response = urllib.urlopen(
            '%s?%s' %
            (domain_query_url, urllib.urlencode(domain_parameters))).read()
        response_dict = json.loads(response)

        # Cache results
        dump_cache(domain, response_dict)
    except Exception as e:
        exit(e)
    return response_dict