How to Use Artificial Intelligence to Detect and Defend Against Cyberattacks