Mitigating malware and ransomware attacks