added hash based scanning, yara scanning, and heuristics scanning

This commit is contained in:
2026-04-03 21:29:33 +11:00
parent 4e12fb2ee5
commit ac7a1658c3
10 changed files with 149 additions and 0 deletions

36
src/scanner.py Normal file
View File

@@ -0,0 +1,36 @@
from detections import *
from console import console
from rich.table import Table
from time import time
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():
start_time = time()
console.print(f"[d]Running {name}..", end='\r')
match = detection.run(contents, f)
table.add_row(name, "[bold orange1]⚠️ Match" if match else "[bold green]✅ Clean")
console.print(f"Running {name}.. [d]({round(time()-start_time, 3)}s)", highlight=False)
f.close()
print()
console.print(table)