-
Notifications
You must be signed in to change notification settings - Fork 15
/
searchmetadata.py
40 lines (29 loc) · 1.28 KB
/
searchmetadata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
The examples in this file are for virustotal-python version >=0.1.0
Search the VirusTotal v3 API for a domain, IP address and comment tag.
Also, retrieve VirusTotal metadata.
Documentation:
* v3 documentation
https://developers.virustotal.com/reference/search-1
https://developers.virustotal.com/reference/metadata
"""
from virustotal_python import Virustotal
API_KEY = "<VirusTotal API Key>"
# The ID (either SHA-256, SHA-1 or MD5 hash) identifying the file
FILE_ID = "9f101483662fc071b7c10f81c64bb34491ca4a877191d464ff46fd94c7247115"
# v3 examples
vtotal = Virustotal(API_KEY=API_KEY)
# Search the VirusTotal API for google.com
resp = vtotal.request("search", params={"query": "google.com"})
# Search the VirusTotal API for information related to Google's DNS (8.8.8.8)
resp = vtotal.request("search", params={"query": "8.8.8.8"})
# Search the VirusTotal API for a file ID
resp = vtotal.request("search", params={"query": FILE_ID})
# Search the VirusTotal API for the tag comment '#malicious'
resp = vtotal.request("search", params={"query": "#malicious"})
# Retrieve VirusTotal metadata
resp = vtotal.request("metadata")
# Print out a list of VirusTotal's supported engines
resp = vtotal.request("metadata")
engines_dict = resp.data["engines"]
print(engines_dict.keys())