The game has a very basic hack check for services that require the internet, such as battling, the GTS, and trading over wifi. This will only check for data that can actually exist in the games. For example, a Weedle can never normally learn Hyper Beam, but if you try to trade one that has it, the game will say there is a problem and will not allow it to be traded.
That being said, the hack check isn't very reliable and sometimes lets things through that would otherwise be impossible to obtain, such as an aegislash in a dream ball.
If a pokemon has been hacked but looks identical to a legitimate pokemon, the game will not be able to detect this.