Ransomware can infect systems through malicious email attachments, compromised websites, or software vulnerabilities.