-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvt.py
28 lines (23 loc) · 867 Bytes
/
vt.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
import virustotal3.core
import json
from config import conf
VT_KEY = conf['virustotal']
def virustotal(query_item, query_type):
""" virustotal api """
result = {}
if query_type == 'ip':
virus_total = virustotal3.core.IP(VT_KEY)
result = virus_total.info_ip(query_item)
elif query_type == 'domain':
virus_total = virustotal3.core.Domains(VT_KEY)
result = virus_total.info_domain(query_item)
elif query_type == 'url':
virus_total = virustotal3.core.URL(VT_KEY)
result = virus_total.info_url(query_item)
elif query_type == 'hash':
virus_total = virustotal3.core.Files(VT_KEY)
result = virus_total.info_file(query_item)
if 'data' in result and 'attributes' in result['data']:
return result['data']['attributes']['last_analysis_stats']
else:
return result