Can AI stop attacks like WannaCry?
There are projects out there attempting to apply Machine Learning / AI to cyber-security in different ways.  One that I'm familiar with is Apache Metron.  Another related project is Apache Spot.  I think if you read over the docs for these two projects respectively, they will probably give you some good insights on this subject.