-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
virustotal_module.py
35 lines (28 loc) · 941 Bytes
/
virustotal_module.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
# virustotal_module.py
import requests
def scan(url, api_key):
# VirusTotal API URL
vt_url = "https://www.virustotal.com/vtapi/v2/url/report"
# API parameters
params = {
"apikey": api_key,
"resource": url
}
try:
# Send the API request
response = requests.get(vt_url, params=params)
response.raise_for_status()
# Get the scan results
results = response.json()
if results["response_code"] == 1:
# Scan report available
return results
elif results["response_code"] == 0:
# No scan report available
return "No scan report available for the given URL."
else:
# Unknown response code
return f"Unknown response code: {results['response_code']}"
except requests.exceptions.RequestException as e:
# Handle exceptions
return f"Error occurred: {e}"