forked from uaudith/Virustotal-telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
virustotal.py
63 lines (48 loc) · 1.8 KB
/
virustotal.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
53
54
55
56
57
58
59
60
61
62
63
import requests
import json
from config import Config
apikey = Config.VIRUSTOTAL_API
class virus():
def __init__(self,file_path):
self.path=file_path
self.res=True
def smallfiles(self):
path=self.path
url = 'https://www.virustotal.com/vtapi/v2/file/scan'
name=path.split('/')[-1]
params = {'apikey': apikey}
files = {'file': (name, open(path, 'rb'))}
response = requests.post(url, files=files, params=params)
if response==False:
self.res=False
return
self.sha1=( response.json()['sha1'])
print(response.json()['verbose_msg'])
self.verbose=response.json()['verbose_msg']
def large_files(self):
path=self.path
url = 'https://www.virustotal.com/vtapi/v2/file/scan/upload_url'
params = {'apikey':apikey}
response = requests.get(url, params=params)
if response==False:
self.res=False
return
upload_url_json = response.json()
upload_url = upload_url_json['upload_url']
print('upload url is',upload_url)
files = {'file': (path, open(path, 'rb'))}
response = requests.post(upload_url, files=files)
self.sha1=response.json()['sha1']
print(response.json()['verbose_msg'])
self.verbose=response.json()['verbose_msg']
def get_report(self):
url = 'https://www.virustotal.com/vtapi/v2/file/report'
sha1=self.sha1
params = {'apikey': apikey, 'resource': sha1,'allinfo':'false'}
response = requests.get(url, params=params)
try:
self.report=response.json()['scans']
self.link=response.json()['permalink']
except Exception as e:
self.report=e
print(response.json())