Understanding and Preventing Ransomware Attacks