You speak like working at a company exists in a vacuum. It doesn't. You are (generally, in Western society) free to stop working for that company. If everyone refuses to write the code, then the company won't have that code. Easily said than done, of course, because life has many pressures. But I dislike this "oh can't do anything about it individually, let's give up and double down on unethical behaviour" attitude (meanwhile we are conveniently paid a high salary for it). We always have a choice.
You dont have to either blame one set of people or another. You could put the blame in the right place instead, the design of the system which all but dictates the individuals choices.