VirusTotal API

How to install

(1)安装vt-py最简单和推荐的方法是使用pip:

$ pip install vt-py

(2)或者,你可以直接从GitHub获得源代码并运行setup.py。为了获得代码,你可以克隆公共存储库:

git clone git://github.com/VirusTotal/vt-py.git
cd vt-py

(3)或者,下载最新版本的tarball并解压:

tar -zxvf vt-py-X.Y.Z.tar.gz
cd vt-py-X.Y.Z

(4)一旦你有了代码,你可以安装它:

sudo python3 setup.py install

Quickstart

Get information about a file

Start by importing the vt module:

>>>import vt

Create a client, replace <apikey> with your actual VirusTotal API key:

>>>client = vt.Client("<apikey>")

Ask for the file you are interested in, you can replace the hash in the example with some other SHA-256, SHA-1 or MD5:

>>> file = client.get_object("/files/44d88612fea8a8f36de82e1278abb02f")

Now file is an instance of vt.Object that contains information about the requested file. This object have the attributes returned in the API response which are listed in the VirusTotal API v3 documentation. Some examples:

>>>file.size

68

>>> file.sha256
'275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f'
>>> file.type_tag
'text'
>>> file.last_analysis_stats
{'failure': 0, 'harmless': 0, 'malicious': 62, 'suspicious': 0, 'timeout': 0, 'type-unsupported': 9, 'undetected': 2}

Get information about an URL

>>> url_id = vt.url_id("http://www.virustotal.com")
>>> url = client.get_object("/urls/{}", url_id)
>>> url = client.get_object("/urls/{}".format(url_id))
>>> url.times_submitted
213730
>>> url.last_analysis_stats
{'harmless': 61, 'malicious': 0, 'suspicious': 1, 'timeout': 0, 'undetected': 8}

Scan a file

在扫描文件之前,强烈建议您按照“Get information about a file”中的描述查找它。如果文件已经存在,并且lastest analysis足够新,您可以使用它而不是再次扫描文件。如果没有,你可以用:

>>> with open("/path/to/file", "rb") as f:
>>>   analysis = client.scan_file(f)

当vt.Client.scan file()返回分析尚未完成时,返回的对象只有分析ID,没有属性。为了跟踪分析的状态,你必须请求分析对象,直到它的状态完成:

>>> while True:
>>>   analysis = client.get_object("/analyses/{}", analysis.id)
>>>   print(analysis.status)
>>>   if analysis.status == "completed":
>>>      break
>>>   time.sleep(30)

或者你也可以使用wait for completion参数:

>>> with open("/path/to/file", "rb") as f:
>>>   analysis = client.scan_file(f, wait_for_completion=True)

Scan an URL

>>> analysis = client.scan_url('https://somedomain.com/foo/bar')

VirusTotal API--------Python代码实现访问VirusTotal,获取杀软结果相关推荐

  1. python代码根据当前时间获取下一周的日期

    python代码根据当前时间获取下一周的日期 #使用python代码根据当前日期计算下一周的日期范围 import datetime,calendar import pandas as pddef g ...

  2. 50行Python代码,教你获取公众号全部文章

    点击"小詹学Python",选择"置顶或者星标" 第一时间收到精彩推送! 小詹说:我们平时阅读公众号的文章会遇到一个问题--阅读历史文章体验不好.的确如此,小詹 ...

  3. python实现50行代码_50行Python代码,教你获取公众号全部文章

    > 本文首发自公众号:python3xxx 爬取公众号的方式常见的有两种 - 通过搜狗搜索去获取,缺点是只能获取最新的十条推送文章 - 通过微信公众号的素材管理,获取公众号文章.缺点是需要申请自 ...

  4. 50行python代码自动生成文章_50行Python代码,教你获取公众号全部文章

    > 本文首发自公众号:python3xxx 爬取公众号的方式常见的有两种 - 通过搜狗搜索去获取,缺点是只能获取最新的十条推送文章 - 通过微信公众号的素材管理,获取公众号文章.缺点是需要申请自 ...

  5. ROS笔记之使用Python代码实现rosbag info获取bag的信息

    代码 import subprocess import yamlbag_path='bag所在路径'def get_bag_info(self):info_dict = yaml.safe_load( ...

  6. Python Django URL逆向解析(通过Python代码逆向访问)代码示例

  7. 【性能测试】获取性能系统指标之示例Python代码

    #!/usr/bin/env python #-*- coding: utf-8 -*- import sys import datetime import time import psutil fr ...

  8. Python3 利用Virustotal API 获取json格式的分析报告

    Python3 利用Virustotal API 获取json格式的分析报告 import requests import json import osAPI="" // your ...

  9. c# typescript_在任何IDE中从C#,Java或Python代码获取TypeScript接口的简单方法

    c# typescript by Leonardo Carreiro 莱昂纳多·卡雷罗(Leonardo Carreiro) 在任何IDE中从C#,Java或Python代码获取TypeScript接 ...

最新文章

  1. Android Parcelable和Serializable的区别
  2. Exception in thread “main“ java.io.IOException: Cannot run program “python3“: CreateProcess error=2,
  3. Oracle从小白到大牛的刷题之路(建议收藏学习)
  4. java 的单态模式(只可以创建一个对象)
  5. 【git】git如何添加本地不是git的项目到Git库中
  6. 量子计算机 程序,量子计算机程序 会早于量子计算机出现
  7. 屏蔽拦截广告(一、PC端浏览器)
  8. 盘古开发框架集成 ShenYu 网关实现 Dubbo 泛化调用
  9. 美图秀秀一寸照片的制作
  10. 工业互联网:制造业的二次升级
  11. 3. pandas基础
  12. 六西格玛dfss_六西格玛设计DFSS概述
  13. 【解决方法】ubuntu20 hp1020 打印机不识别无反应
  14. SaaS部署和私有化部署的区别及各自的优点
  15. 【Linux】bert-base-cased 不在缓存需要从 s3 上下载的问题
  16. 【数据治理】数据分析八大模型:OGSM模型
  17. ST-LINK/V2驱动下载与安装
  18. 卸载 金山毒霸 的方法
  19. 舆情监测专题报告写作内容及格式参考模板
  20. 轨道阱 matlab,静电场轨道阱质谱(Orbitrap)

热门文章

  1. pytorch Embedding 修改 自定义
  2. MATLAB施密特正交化
  3. 单片机怎样用汇编语言设计一个输出为6KHZ,占空比为45%的波形
  4. FastDFS (五) --------- FastDFS 在 web 项目中的应用
  5. Buck工作原理分析,连续模式,断续模式
  6. 目标检测系列之 -- ACF算法
  7. 【翻译】普罗米修斯HA与萨诺斯的挎包或接收器?
  8. SATA 学习笔记2 - Shadow Register和FIS的传输
  9. spring boot启动类启动 错误: 找不到或无法加载主类 xxx.xxxx.Application 的解决方法
  10. 嵌入式linux通过程序设置系统时间,嵌入式新手如何设定Linux的时间函数