Well... you can't really get one.
I assume there is one way of how your opponent could have gotten it.
This Serperior may have been hacked from Gen V to have the Contrary ability, and he may have traded it to X and Y via Pokebank. Of course, it's still debatable if Pokemon with unavailable Hidden Abilities can get through.
If unavailable Hidden-abilitied Pokemon can't get through the Pokebank, your friend obviously knows how to hack the game, or has traded someone who knows how to hack the game because Contrary Serperior is not available.
Hope I helped. :)