Apple has told millions of iPhone users to act now after identifying a sophisticated attack plaguing devices.