From the Super Mario Wiki
Cobrats are large desert-dwelling snakes that were first seen in Super Mario Bros. 2, where they would unexpectedly spring from sand or vases. Their name is a portmanteau of "brat" and "cobra", which is a kind of snake famous for being charmed out of vases or baskets through the use of flute-like musical instruments. The Super Mario Bros. 2 boss Tryclyde resembles a three-headed Cobrat.
 Super Mario series
 Super Mario Bros. 2
In Super Mario Bros. 2, Cobrats jump out of the sand or vases to attack, and most of them can spit out black projectiles similar to Snifits. They appear in the desert levels and are easy to defeat if in a line; the player can throw one and cause a domino effect. They can be avoided easily and only pose a threat when in large numbers.
 Super Mario Bros. 3 ports
 The Super Mario Bros. Super Show!
Cobrats appeared several times on The Super Mario Bros. Super Show!, where their size varied from minuscule to exceptionally large. The role of Cobrats in the show varied, as they would occasionally appear as enemy monsters and on other occasions would be used as handheld weaponry, capable of firing small, exploding black orbs. They have even been used as transportation in the episode Star Koopa.
 Nintendo Comics System
In the Nintendo Comics System story Just Deserts, two Cobrats, which are capable of speech, appear as inhabitants of Bowser's desert fortress; the story itself makes it ambiguous as to whether or not these two Cobrats are actually affiliated with Bowser or simply live in his pyramid fortress.
 Nintendo Adventure Books
In Leaping Lizards, an unnamed Cobrat competes in the International Mushroom Games as a member of a team called the Sneaks. It participates in the Beetlebowl (an all-team event) and the Super Triple Jump, where it leaps by coiling its body up like a spring.
 Super Mario-Kun
In volume 8 of Super Mario-Kun, a Cobrat breaks out of a fake drink vending machine located in a desert. Yoshi shortly eats it. More Cobrats appear out of vases. Birdo tries shooting eggs at one, but the Cobrat eats them. Mario then dives into a vase to obtain a POW Block. He then uses it to defeat the Cobrats.
 Mario Pinball Land
 Mario Kart 7
Cobrats appear on the stage Shy Guy Bazaar in Mario Kart 7. They hide in a vase which moves around in attempt to delay the racers. When crashed into, several cobrats spring out. The vase immediately reappears after the shattered vase vanishes. As in Mario Pinball Land, the cobrats are colored green rather than red.