-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmal_scan.py
34 lines (30 loc) · 1.03 KB
/
mal_scan.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
import sys
import hashlib
import requests
from bs4 import BeautifulSoup
# BUF_SIZE is totally arbitrary, change for your app!
BUF_SIZE = 65536 # lets read stuff in 64kb chunks!
sha256 = hashlib.sha256()
try:
with open(sys.argv[1], 'rb') as f:
while True:
data = f.read(BUF_SIZE)
if not data:
break
sha256.update(data)
hashfunc = format(sha256.hexdigest())
print ("SHA256 Hash : " + hashfunc)
page=requests.get("https://www.virustotal.com/en/file/"+hashfunc+"/analysis/")
soup = BeautifulSoup(page.content, 'html.parser')
title= (soup.find_all('meta',attrs={'name':'description'}))
a=(title[0]['content'] if title else "Data not found Site must be busy Please try after some time")
if "detected" in a:
print (a)
else:
print ("\nFile was not found in the virustotal database")
except:
print('''
Please Enter File name
Usage : mal_scan.py "filename.ext"
example : mal_scan.py download.jpg
''')