The reason designed-for-purpose anti-ship missiles/drones are so expensive is they are literally designed to be somewhat effective at executing exactly the scenario you are laying out, while not being naive about the defenses that military ships actually have. Anybody that understands the capability space knows that your scenario wouldn’t survive contact with real defenses.
You are making an argument from fiction. Do you take the “hackers breaking cryptography” trope from Hollywood at face value?