The first step in solving a problem is being aware that there is a problem - pure common sense. But suppose you're unwittingly hiding a problem from your awareness – how're you going to solve it?
To explain: suppose you have a bad habit you're trying to get rid of, whether it's picking your nose, staring at someone's cleavage, standing/sitting with bad posture, automatically feeling defensive when you see a group of teenagers getting on your bus, whatever. If your automatic reaction to realising you're doing it again is to get annoyed with yourself you'll probably never ditch the habit.
Why? The mind has a lot of self-protection mechanisms built in so whenever it encounters a 'threat' to its (your) happiness/well-being it tries to stop that threat from recurring. If each time you realise you're doing the 'wrong' thing your reaction is “SHIT, I'm STILL doing that!” your mind will say to itself “Hmm, whenever I notice myself doing that thing I get upset, so I'd better stop noticing it as that means I won't get upset.” and you're then less likely to be aware of the habit. If your subconscious is deliberately keeping things below the radar of the conscious there's nothing you can do to improve the situation.
The trick to solving the problem is this: when you notice you're picking your nose, staring at the woman's boobs, slouching, etc., instead of going “Shit! I'm doing it again!”, you should train yourself to say “Good! I've noticed I'm doing that again – now I can stop doing it!”. You're rewarding yourself for increasing your awareness of the action because without awareness of the action you can't do anything to correct it. The idea is to set up a positive feedback spiral where your mind actively wants to be aware of these habits - then you can do something about them. If you can do this consistently you will over time replace bad old habits with good new ones.
One pitfall to look out for is this: at times you'll feel as though you're doing the wrong thing a lot more than ever before and you'll feel disheartened because it seems you're getting worse rather than better. You're not getting worse; you're improving your awareness of the problem so you're getting a clearer picture of it – it's one of the milestones on the way to eradicating the habit so it's something you should be pleased about! As with anything useful this takes work, so keep at it and don't beat yourself up about the times when you slip back a bit.