In the Jin Dynasty text Records of Lost Things, it says that chickens can ward off evil, "preventing monsters, calamities, and all manner of wickedness from causing harm," while "demons and other foul creatures naturally retreat in submission." In folk belief, chickens are auspicious creatures that drive away yin and usher in yang. The Song Dynasty text Taiping Imperial Reader says that when the sun rises, roosters crow, because "the yang emerges and the rooster crows, responding through affinity." The ancients called the chicken the "essence of yang," the essence of the sun. Evil demons are all shadowy, hideous creatures that cannot abide sunlight, so naturally they would flee the chicken's righteous aura.
Vengeful ghosts are formed from resentment. Only by dispelling their resentment can they be sent back into the cycle of reincarnation. Of course, if we can't dispel it, all we can do is destroy them. As for karma and all that, what matters more than the life right in front of us?