The first way is hard to do if there's a large group of programmers working on the project but it's very suitable for older projects that is still under development but with lower staffing.
If possible, do things efficiently locally (use source control, use python/jython, generate code, do automated builds, do automated testing, reuse, and only deliver what you must) but leave your advantageous practices unadvertised. Then, slowly abuse your edge to steal maintenance and refactoring time from actual to-be-done tasks and features. Eventually you can ease your own future work and you'll get more time to work on the system instead of the features which become easier to add.
The second way is to employ a targeted attack against a whole malfunctional group or team at once: skunkworks projects. Do the damn thing from the scratch and do it right, then replace the old steaming pile of junk with it before anyone gets to say no, and weasel your way back to the surface by toting things were just changed a bit, and never replaced.
Of course, this comes with the assumption that the evil is in the system and your colleagues aren't actively demolishing everything you build.