Spyware removal iPhone 12.1.4

someone had full access to my iPhone and MacBook (with my iTunes account) and installed a spyware capable of having microphone and camera access as well as a key logger, screen sharing and location. I did a factory reset using a different computer and wiped/reinstalled macOS. Does using the same iCloud and iTunes account that I had before restoring make it possible for the spyware to be reinstalled? If so, how do I remove it without losing my data?
Well the first thing I would do is change my password on my Apple account and set up two-factor authentication, if you haven't already.

Yes, the same data will be reinstalled to your devices if a backup was done after the "bug" was installed. If you have a known good backup before this happened, then I would suggest restoring from that known good backup. Otherwise you will need to reset and set up as a new device.

And just an FYI, you will have to jump through a few small hoops to prove you are the owner of these devices during this process.

Original thread: https://forums.imore.com/threads/spyware-removal-iphone-12-1-4.412138/