Reinstalling the firmware should get rid of malicious apps installed to the system root, because you're completely replacing the installed firmware. If you just do a factory reset, you're just using...