Man in the Middle Attacks: Analysis, Motivation and Prevention