-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirusTotalAPISupport.py
52 lines (36 loc) · 1.3 KB
/
virusTotalAPISupport.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
41
42
43
44
45
46
47
48
49
50
51
52
import requests
def main(file):
url = "https://www.virustotal.com/api/v3/files"
files = {"file": (file, open(file, "rb"), "application/x-msdownload")}
headers = {
"accept": "application/json",
"x-apikey": "apikey"
}
response = requests.post(url, files=files, headers=headers)
response_json = response.text
analysis_url = response_json[response_json.index("https"):-19]
print(analysis_url)
analysis_response = (requests.get(analysis_url, headers=headers)).text
stats = [
"harmless",
"type-unsupported",
"suspicious",
"confirmed-timeout",
"timeout",
"failure",
"malicious",
"undetected"]
analysis_result = {}
for stat in stats:
pos_in_string = analysis_response.index(stat)+len(stat)-1
num = []
for i in range(pos_in_string,len(analysis_response)):
if (analysis_response[i] == ','):
break
elif (analysis_response[i].isnumeric()):
num.append(analysis_response[i])
else:
continue
num = ''.join(num)
analysis_result[stat] = num
print(analysis_result)