Files
Azure/src/scanner.py

36 lines
1.0 KiB
Python

from detections import *
from console import console
from rich.table import Table
from time import time
import os
class Scanner:
def __init__(self):
self.detections = {
"Hash Detection": Hash(),
"Yara Pattern Matching": Yara(),
"Heuristics": Heuristics()
}
def scan_file(self, file_path: str):
with console.status(f"Scanning {file_path}...") as status:
f = open(file_path, "rb")
contents = f.read()
table = Table("Scan", "Match")
for name, detection in self.detections.items():
console.print(f"Running {name}..")
match = detection.run(contents, f, os.path.realpath(file_path))
table.add_row(name, "[bold orange1]⚠️ Match" if match else "[bold green]✅ Clean")
print()
f.close()
print()
console.print(table)