Ain't that a kick in the head? Roaches protect themselves from zombifying wasps by using their legs.

A wasp that preys on cockroaches turns them into mind-controlled zombies by stinging them in the brain, and roaches were thought to be all but defenseless against this zombifying attack.

But it turns out that cockroaches have a defensive move that can protect them from becoming members of the walking dead.

Scientists recently discovered that roaches lash out at their would-be zombie-makers with powerful karate-like kicks to the attacking insect's head. Their strategy doesn't kill the wasp, but it's usually enough to send them looking for an easier victim, according to a new study. [Zombie Animals: 5 Real-Life Cases of Body-Snatching]

Zombification in this wasp-cockroach scenario is a little different than that suffered by human zombies in pop culture. The human "undead condition" usually seems to spread through bites; as in certain contagious diseases, an infusion of tainted bodily fluid passes on the "infection," turning the victim into an animated corpse with a taste for brains

However, cockroaches zombified by emerald jewel wasps aren't dead (at least, not at first). A first sting paralyzes their legs, and a second sting to their brain delivers a neurotoxin that hijacks their nervous system, enabling the wasp to control the roach's body and behavior, according to the study.

A sting to the brain means that this roach is about to become the wasp's mind-controlled zombie slave. (Image credit: Catania Lab, Vanderbilt University)

After becoming a zombie, the roach's fate takes an even more gruesome turn. The wasp snips off the tips of the roach's antennae and drinks its blood. Quite refreshed, it takes hold of the remaining antenna stumps and steers the roach to its nest. Next, it lays an egg on the cockroach's body and entombs it inside the subterranean lair. Once the egg hatches, the newborn wasp eats its way into the roach's abdomen — while its zombified host is still alive.

Pitted against these parasites, a cockroach's only hope is evading the first sting — once that paralyzing pinch was delivered, a roach had little hope of preventing the second, zombifying stab to the brain, the scientists discovered. For the new study, Ken Catania, a professor of Biological Sciences at Vanderbilt University in Tennessee, staged 55 bouts between wasp and roach, to see if the roaches had any defensive moves that would work.

Video shot at 1,000 frames per second revealed that about half of the roaches were ambushed by the wasps without mounting any defense at all. But the roaches that defended themselves did so by rising high on their legs — "stilt-standing" — and delivering a kick with one of their spiky hind legs. The kick often connected squarely with the wasp's head and sent the smaller insect "careening into the walls of the filming chamber," Catania wrote.

Roaches' kicking power came from an energy-storing windup before the leg was released, similar to the swinging of a baseball bat, according to the study. Though the roaches' kicks didn't always discourage the wasps, about 63 percent of the adult roaches that kicked for their lives successfully avoided being zombified. Younger roaches were not so lucky — whether they kicked or not, they almost always wound up as a wasp's zombie slave, Catania reported.

Roaches' behavior — assuming an "en garde" position in the face of an attack — isn't so different from the defensive strategy practiced by a zombie's human victims in horror films, Catania said in a statement. The unusual stance "allows the roach to move its antenna toward the wasp so it can track an approaching attack and aim kicks at the head and body of the wasp," similar to the way that a human might follow a zombie's moves with their eyes before taking a swing at its rotting corpse, Catania said.

"It's reminiscent of what a movie character would do when a zombie is coming after them," he added.

The findings were published online today (Oct. 31) in the journal Brain, Behavior and Evolution.

Originally published on Live Science.