What is meant by “Sin is lurking at the door; its desire is for you, but you must master it” in Gen. 4:7 is that temptation is always before us to lure us into breaking God's Laws, which is sin, as sin is the transgression of the law:
"Whosoever committeth sin transgresseth also the law: for sin is the transgression of the law." (1 John 3:4 - King James Bible).
In the context of Genesis 4:7, it is important to consider the entire passage, which states, in The Living Bible version:
"It can be bright with joy if you will do what you should! But if you refuse to obey, watch out. Sin is waiting to attack you, longing to destroy you. But you can conquer it!"
What God is saying here is that life can be better when we think and act righteously because we avoid the penalties of sin. When we do what we should, wanting to please God, we tend to work at avoiding temptation, whether it be avoiding certain thoughts, media, situations, people and places that may tempt us to sin.
Therefore, obedience is a hedge or safety net to falling into temptation. Certain temptations, when not nipped in the bud, can lead to sin. Sin, left unchecked and not repented of, leads to destruction. This can be physical destruction, as well as the spiritual destruction that is assured.
However, there is hope in the battle against temptation and sin. We can conquer sin with God's help, through His Holy Spirit and His Son Jesus Christ. In the New Testament it states:
"No temptation has overtaken you except what is common to mankind. And God is faithful; he will not let you be tempted beyond what you can bear. But when you are tempted, he will also provide a way out so that you can endure it." (1 Corinthians 10:13 - New International Version).
Sin does continue to lurk at the door, and Satan the Devil has his hand in this. But as revealed in the Scriptures, we can defeat temptation and sin.