Start with common sense
If it looks too good to be true, it probably is. A shiny, a rare legendary or a battle-ready competitive team that came from the GTS, Wonder Trade or a stranger should be treated as hacked.
Checks that catch most of them
- PKHeX: the save editor is the best checker available, and flags illegal data when you load a save file.
- Origin mark: a Pokémon with a mark for a game it could never have come from, or a species that game does not have, is hacked.
- Moves, ability and nature that cannot be combined: for example a Pokémon that learned a move in a generation where that move was unavailable to its species.
- Event traits: event Pokémon come as a set of traits (original trainer, ID, ribbon, moves, nature). If one trait is present and the others are not, it is faked.
- Ribbons: most events give a specific ribbon, so a missing or extra one is a warning sign.
What to keep in mind
- A skilled hacker can make a Pokémon that passes every check. Only trading with people you know and trust is safe.
- Illegitimate and illegal are not the same. A Pokémon can be obtained dishonestly without any illegal trait, and a checker will not catch that.
- Receiving a hacked Pokémon is very unlikely to damage your save. Editing a save to make one is the riskier part.
- Keep blatantly illegal Pokémon out of online battles.