added hash based scanning, yara scanning, and heuristics scanning
This commit is contained in:
36
src/scanner.py
Normal file
36
src/scanner.py
Normal 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)
|
||||
Reference in New Issue
Block a user