Cyberattacks through malware are growing at their fastest pace in four years, as smartphones and other connected devices give hackers a new crop of targets to attack.