A piece of mobile malware has been discovered that is said to have infected tens of thousands of iPhones and iPads in an effort to help its masters make a profit.