April 17, 2024, 2:23 p.m. | Olatunji Ayodele Abidemi

DEV Community dev.to

import hashlib





List of known malware hashes (for demonstration purposes)

known_malware_hashes = {

'md5': ['5f4dcc3b5aa765d61d8327deb882cf99', '...'],

'sha1': ['aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d', '...'],

'sha256': ['9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08', '...']

}


def check_file_hash(file_path):

# Calculate the file's hashes

with open(file_path, 'rb') as file:

file_content = file.read()

md5_hash = hashlib.md5(file_content).hexdigest()

sha1_hash = hashlib.sha1(file_content).hexdigest()

sha256_hash = hashlib.sha256(file_content).hexdigest()



# Check if any of the file's hashes match known malware hashes

if md5_hash in known_malware_hashes['md5'] or \

sha1_hash in known_malware_hashes['sha1'] or \

sha256_hash in known_malware_hashes['sha256']:

return True # The file is infected …

ai antivirus check def demonstration file hashes import javascript list machine machine learning machinelearning malware md5 python security security operation sha1 sha256 solution

SOC 2 Manager, Audit and Certification

@ Deloitte | US and CA Multiple Locations

Senior Security Engineer

@ Core10 | Nashville, Tennessee, United States - Remote

Security Operations Engineer I

@ Jamf | US Remote

IT Security ISSO Specialist (15.10)

@ OCT Consulting, LLC | Washington, District of Columbia, United States

Compliance Officer

@ Aspire Software | Canada - Remote

Security Operations Center (SOC) - AVP

@ Paytm | Noida, Uttar Pradesh