To behave toward others in a manner resembling or commensurate with their behavior towards oneself, especially in a situation where one is insulted or otherwise ill-treated.
retaliate against
How often have the words give as good as one gets and retaliate against occurred in a corpus of books? (source: Google Ngram Viewer )