I can tell you as I've confessed before on here, that I myself struggle with sin sometimes as well. Whenever I'm weak in my faith and then (temporarily) let Jesus go, I go back to my usual sinful ways: being drawn to immorality, the morbid, the macabre, hatred, inappropriate fantasies, defrauding others, and not respecting my family.
The main reason why I can recognize those sin habits and detest them is because of the Holy Spirit. He helps convict you of sin.
"But the Advocate, the Holy Spirit, Whom the Father will send in My name, will teach you all things and will remind you of everything I have said to you." (John 14:26, NIV)