79474954

Date: 2025-02-28 08:54:17
Score: 1
Natty:
Report link

import os import hashlib

List of known malware hashes

malware_hashes = [ "d41d8cd98f00b204e9800998ecf8427e", # Example hash "5d41402abc4b2a76b9719d911017c592" # Example hash ]

def calculate_hash(file_path): sha1 = hashlib.sha1() with open(file_path, 'rb') as f: while chunk := f.read(8192): sha1.update(chunk) return sha1.hexdigest()

def scan_directory(directory): for root, _, files in os.walk(directory): for file in files: file_path = os.path.join(root, file) file_hash = calculate_hash(file_path) if file_hash in malware_hashes: print(f"Malware detected: {file_path}") os.remove(file_path) print(f"Malware removed: {file_path}")

Scan the current directory

scan_directory(".")

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Hacker Star