Marketed as a tool against criminals, spyware use by governments around the world has led to scandals.