如何在Python的VirusTotal中使用API​​扫描文件

时间:2019-06-30 11:14:12

标签: python api

我正在创建一个脚本,该脚本应该使用TotalVirus的API(https://developers.virustotal.com/reference)在用户给定的文件上的TotalVirus中运行病毒扫描。

我的脚本的目标是:

  1. 文件名-使用将提供文件名和文件路径,脚本将在VirusTotal中扫描文件。

  2. 路径-脚本将从用户指定的路径中扫描所有文件。

  3. 列表-用户将提供路径,以及该路径中的文件列表。该脚本将扫描VirusToal列表中的文件。

我决定从这里开始使用脚本-https://github.com/blacktop/virustotal-api/blob/master/virus_total_apis/api.py

我复制并粘贴了上面链接中的代码,并尝试使用以下代码调用功能“ scan_file”:

tmp = PublicApi.scan_file('MyAPICodeIsHere', '7z.exe', 'C:\\Program Files\\7-Zip\\7z.exe', '7z.exe', '2')

这是我收到的错误:

Traceback (most recent call last):
  File "C:/Users/OSUser/.PyCharmCE2019.1/config/scratches/testtuhs.py", line 877, in <module>
    tmp = PublicApi.scan_file('64be7cea7bcabaf2be366253b247a6a1075e2a90a71bbc45058398bb8638f8db', '7z.exe', 'C:\\Program Files\\7-Zip\\7z.exe', '7z.exe', '2')
  File "C:/Users/OSUser/.PyCharmCE2019.1/config/scratches/testtuhs.py", line 65, in scan_file
    params = {'64be7cea7bcabaf2be366253b247a6a1075e2a90a71bbc45058398bb8638f8db': self.api_key}
AttributeError: 'str' object has no attribute 'api_key'

我的猜测是我错误地称呼功能-“ scan_file”。

如何正确调用函数“ scan_file”,所以当我调用它时,它将在VirusTotal中扫描文件? P.S-链接中的代码允许使用指令进行更多功能,但是我不知道如何使用/调用它们。 谢谢。

0 个答案:

没有答案