PROTOTYPE
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,22 +1,19 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Anchor hashes.txt relative to the libs folder
|
|
||||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
HASH_LIST_PATH = os.path.join(
|
HASH_LIST_PATH = os.path.join(
|
||||||
BASE_DIR, "hashes.txt"
|
BASE_DIR, "hashes.txt"
|
||||||
) # or os.path.join(BASE_DIR, "..", "hashes.txt")
|
)
|
||||||
|
|
||||||
|
|
||||||
def hashcheck(fileToCheck):
|
def hashcheck(fileToCheck):
|
||||||
# Remove trailing spaces or wrapped quotes from drag-and-drop
|
|
||||||
clean_path = str(fileToCheck).strip().strip('"').strip("'")
|
clean_path = str(fileToCheck).strip().strip('"').strip("'")
|
||||||
|
|
||||||
if not os.path.isfile(clean_path):
|
if not os.path.isfile(clean_path):
|
||||||
print(f"Error: Path does not exist or is a directory: {clean_path}")
|
print(f"Error: Path does not exist or is a directory: {clean_path}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Read file in binary mode and compute hash
|
|
||||||
with open(clean_path, "rb") as f:
|
with open(clean_path, "rb") as f:
|
||||||
digest = hashlib.file_digest(f, "sha256")
|
digest = hashlib.file_digest(f, "sha256")
|
||||||
file_hash = digest.hexdigest()
|
file_hash = digest.hexdigest()
|
||||||
|
|||||||
@@ -23138,3 +23138,4 @@ A1475A0042FE86E50531BB8B8182F9E27A3A61F204700F42FD26406C3BDEC862
|
|||||||
000000627a55405cf609a534f2bd38ab2b74a50b17b4db5c271ef3305e38c830
|
000000627a55405cf609a534f2bd38ab2b74a50b17b4db5c271ef3305e38c830
|
||||||
00000048b1c9e60c14a6619f0292dea96df7f10c11cfa9ae28693219c0ae844b
|
00000048b1c9e60c14a6619f0292dea96df7f10c11cfa9ae28693219c0ae844b
|
||||||
00000045ef6ec5eb590ef16ef79d467734ea7d9144d7990511514f08ed3cb673
|
00000045ef6ec5eb590ef16ef79d467734ea7d9144d7990511514f08ed3cb673
|
||||||
|
4F19AB252F8DC17EB245F69A99EB58FCAFA86794D3E3CD7F313DBA7C374D401A
|
||||||
27
main.py
27
main.py
@@ -1,7 +1,30 @@
|
|||||||
|
from pathlib import Path
|
||||||
from libs.filesearch import watch_downloads
|
from libs.filesearch import watch_downloads
|
||||||
from libs.hashd import hashcheck
|
from libs.hashd import hashcheck
|
||||||
|
from plyer import notification
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
PROJECT_DIR = Path(__file__).parent.resolve()
|
||||||
|
|
||||||
|
print(f"Monitoring Downloads folder: ")
|
||||||
|
notification.notify(
|
||||||
|
title="Vanti",
|
||||||
|
message=f"Vanti is enabled, keeping you secured",
|
||||||
|
app_name="Vanti",
|
||||||
|
timeout=5,
|
||||||
|
)
|
||||||
for file_path in watch_downloads():
|
for file_path in watch_downloads():
|
||||||
|
if file_path.name == "hashes.txt":
|
||||||
|
continue
|
||||||
|
time.sleep(2)
|
||||||
print("Received file path:", repr(file_path))
|
print("Received file path:", repr(file_path))
|
||||||
hashcheck(file_path)
|
is_virus = hashcheck(file_path)
|
||||||
|
print(f"{file_path} is a virus: {is_virus}")
|
||||||
|
if is_virus:
|
||||||
|
os.remove(file_path)
|
||||||
|
notification.notify(
|
||||||
|
title="Virus Contained",
|
||||||
|
message=f"The file {file_path} has been detected as a virus and has been contained. Move it out of the containment folder to keep it or else it will be deleted in 24 Hours",
|
||||||
|
app_name="Vanti",
|
||||||
|
timeout=5,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user