Is there a phrase, word or saying when one 'has the thought or feeling of causing hurt of mischief" despite never dreaming of acting on it?

In psychology, these are known as intrusive thoughts(1). The term is chosen because these thoughts seem to enter your mind from outside, without your control. Intrusive thoughts can occur across a wide spectrum of subjects, from uncontrollable fears, to the urges toward mischief or violence which you experience, to the urge to harm oneself without reason, to suicidal ideation. When these thoughts occur with such frequency or intensity that they interfere with a person's life, they're often considered a symptom of obsessive-compulsive disorder. In most cases, though, a moderate amount of intrusive thoughts is not considered symptomatic.