The quality of acting like a villain or a rascal is knavery. You'll know that knavery happened last night if you wake to find toilet paper strung from the branches of your trees.
The noun knavery comes from knave, an old-fashioned word meaning "rascal or rogue." Shakespeare was especially famous for using knave as an insult, and knavery reflects this sense of a foolish and terrible person who's up to no good. Dirty political tricks can be called knavery, as can rascally practical jokes, and even wickedness, dishonesty, and cruelty.