Like pappy used to say: if you see it writhe and hiss, give it a miss. Humans have passed on similar nuggets of wisdom since time immemorial, giving us a healthy (and sometimes less than healthy) respect for backing away from snakes.

Yet the fact snake bites hurt is usually an accident of nature – virtually every single species of snake evolved the ability to inject venom to catch prey, rather than for defence. But there are exceptions to the rule – new research shows some snakes actually evolved their venom specifically to drive away potential predators, including us. And it's excruciatingly painful for good reason.

The study by an international team of scientists demonstrates a unique kind of venom and envenomation strategy evolved on at least three different occasions.

Spitting cobras and rinkhals are closely related snakes capable of squirting venom far enough for an unwary human to cop an eyeful.

The effects aren't pleasant. Chemicals in the spitting cobra's venom chew away at the cornea, causing intense pain and – in high enough doses – blindness.

Fangs like water-pistols and blinding venom aren't exactly suited to bringing down a quick-footed meal, so researchers saw this as a perfect opportunity to investigate the evolutionary history of this particularly unusual characteristic.

Snakes first evolved an ability to inject venom somewhere between 60 and 80 million years ago. Since then, thousands of species in the superfamily Colubroidea have tweaked the original recipe and modified their mouth bits to suit their dietary needs.

Using fossils as calibration, the researchers used molecular dating techniques on the genomes of a number of true spitting cobra (Naja species), rinkhals (Hemachatus haemachatus), and non-spitting relatives (Walterinnesia aegyptia and Aspidelaps scutatus).

The results suggested African spitting cobras developed their eye-watering habit between 6.7 and 10.7 million years ago. Their Asian relatives followed suit 4 million years later.

Rinkhals were hard to pin down but must have developed their ability since parting from other spitting cobras more than 17 million years ago.

An analysis of their venoms revealed their make-up had more in common with each other than non-spitting relatives, with the exception of the more neurotoxic recipe belonging to Naja philippinensis.

The agonising effects of the venom's chemistry were also put to the test using living tissue and nerve samples.

"We tested how venom components affected pain-sensing nerves and showed that spitting cobra venoms are more effective at causing pain than their non-spitting counterparts," says neuropharmacologist Irina Vetter from the University of Queensland in Australia.

Added together, the sum of the results implies spitting cobras and rinkhals repurposed their venom and fangs independently, transforming into defence mechanisms capable of detracting large predators.

And just who were those large predators in each case? We can only guess, but the researchers argue there are some good reasons to think our ancestors fit the bill, citing evidence of snakes influencing primate neurobiology and behaviour.

Humans and chimpanzees diverged roughly around the same time African spitting cobras evolved the trait. We're also likely to identify potentially venomous snakes and attack from a short distance, putting pressure on spitting as a suitable means of venom delivery.

Of course, it's all speculation based on loosely circumstantial evidence at this point, but the ideas warrant further exploration.

"It is intriguing to think that our ancestors may have influenced the origin of this defensive chemical weapon in snakes," says snake venom expert Nick Casewell from the University of Liverpool.

Ironically, by understanding the evolutionary relationship between toxins and our own bodies, we're better positioned to identify potential mechanisms for new classes of medicine.

The analgesic properties of rattlesnake venom, for example, could give millions of people living with neuropathic pain a chance of relief.

"Pain-causing toxins from animal venoms can be useful tools to help us understand pain signalling at a molecular level and are helping us to identify new targets for future painkillers," says University of Queensland molecular biologist Sam Robinson.

It's time we called a truce with the spitting cobra. We'll keep our distance, and appreciate their skills from afar.

This research was published in Science.