python - 使用 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 密钥。
推荐阅读
- python - 如何从函数中的数据框返回不是由函数计算的列?
- sql - 当我们同时执行查询时,如何从同一个 sql 查询中检索不同的数据?
- javascript - Codemirror 和 Xtext - 自动完成弹出窗口未显示
- python - amazon sagemaker 中自定义代码的增量培训
- php - 对 jqgrid 日期时间列进行排序
- python - Pandas:计算连续重复项(不带循环)并将列添加到原始 DataFrame
- pointers - 将布尔值分配给变量的地址
- google-chrome - 是否可以在 Chrome 浏览器上禁用“安装 gatsby-starter”
- vue.js - Vue router-link 更改 url 但不更改 router-view 组件
- python - 从 CSV 读取输入并将它们用于不同的功能