Usually worms crawling on a dog's rectum are tapeworms:
These are flat segmented worms that often looks like pieces of rice. There are two types of tapeworms. dipylidium caninum, which dogs get from ingesting fleas and Taenia tapeworms which dogs get from ingesting dead rabbits or sometimes from undercooked venison, etc.
The dogs may both be infected if they both had fleas or both ate the same dead rabbit, but it is not directly contagious from one dog to another.
These parasites do cause anal irritation and therefore, scooting her behind on the rug would be a common symptom. These parasites can also cause a dull haircoat but are otherwise relatively harmless. They are easily treated with medication.
If the worms are not flat and segmented, then it's not tapeworms! If that's the case, try to collect a few of the worms along with a stool sample to have your vet check out.
Well, there is a product called Tapeworm Tabs (Tradewinds) that you can buy OTC without a script. The active ingredient is praziquantel. You can find it online if the feedstore doesn't carry it. The dose is dependent on weight, so you'll need an accurate weight on your pet.
Thanks, XXXXX XXXXX