Protection from trojan horses has been a serious issue since the days of old.
It has been discovered that the best way to avoid them is simply not to let them in the village in the first place.
After that the basic premise of your question is flawed.