使用Virustotal和Python提取应用程序哈希的分数



我正在尝试使用VirusTotal API获取应用程序哈希和IP地址的分数。

该代码适用于IP地址。请参阅以下代码:

###### Code starts 
import json
import urllib.request
from urllib.request import urlopen
url = 'https://www.virustotal.com/vtapi/v2/ip-address/report'
parameters = {'ip': '90.156.201.27', 'apikey': 'apikey'}
response = urllib.request.urlopen('%s?%s' % (url, urllib.parse.urlencode(parameters))).read()
response_dict = json.loads(response)
#### Code ends

但这对应用程序哈希不起作用。以前有人做过这方面的工作吗:

例如,应用程序哈希"f67ce4cdea7425cfcb0f4f4a309b0adc9e9b28e0b63ce51cc346771efa34c1e3"的得分为29/67。请参阅此处的图片。有人在这个API上工作以获得分数吗。

您可以对python库中的请求模块进行同样的尝试

import requests
params = {'apikey': '<your api key>', 'resource':<your hash>}
headers = {"Accept-Encoding": "gzip, deflate","User-Agent" : "gzip,  My Python 
requests library example client or username"}
response_dict={}
try:
response_dict = requests.get('https://www.virustotal.com/vtapi/v2/file/report', 
params=params).json()
except Exception as e:
print(e)

你可以用它来获取数据:

if response_dict.get("response_code") != None and response_dict.get("response_code") > 0:
# Hashes
sample_info["md5"] = response_dict.get("md5")
# AV matches
sample_info["positives"] = response_dict.get("positives")
sample_info["total"] = response_dict.get("total")
print(sample_info["md5"]+" Positives: "+str(sample_info["positives"])+"Total "+str(sample_info["total"]))
else:
print("Not Found in VT")

为了参考,请检查virustotalapi,它允许您同时使用多个api密钥。

最新更新