I have turned down opportunities to work where I felt morally questionable about the job on which I'd be working.
At the end of the day, you live with yourself, and no amount of money or perks is worth feeling guilty or bad about you as a person.
I've even taken it beyond that -
I used to work at a large company where the company goal didn't really fit into my personal philosophy. I wasn't asked to write anything objectionable, and I actually even felt that most tasks I worked on where interesting and challenging.
However, after a couple of years, I started to realize that I was feeling fairly unfulfilled - the goals of the company didn't fit with my personal philosophy. Doing better in my job, in my mind, didn't make me feel like I was doing something valuable for the world at large, and I realized that was important to me. I don't pretend that it is important for the world at large, or any of my peers, but it was personally important to me. I ended up changing jobs, where I moved into a position with a lower pay, but a much more personally satisfying role.
I now realize this was a very smart move for me. Working in a position where I was happier actually made me work harder, and as a result, I managed to improve my career at a pace that I believe is much faster than it would have been without the move. The small step backwards put me on a much better long term path - mostly because it put me into a position where I was excited and motivated to strive forward.
I feel that it's difficult, sometimes, to turn away the money - but in the long run, for me personally, whenever I've been presented an opportunity where I've asked the question of myself, I realize I'm much better off moving onto the next thing.