It means that we must deal smartly and cunningly with cunning people. We should use their tricks on themselves.
For example, in the fable of the fox and the crane, bye serving soup in a plate the fox "played the fox with the fox" (Here the crane was at fault as he acted cunningly at first, and the fox took revenge by "playin the fox").