Firstly, there is no single method that will isolate all bacteria from such a sample. Many of the bacteria in question may be obligate anaerobes, while others may be strictly aerobic. Secondly, to identify all bacteria is a different question from identifying culturable bacteria. The gut microbiome is complex and still not completely understood. I suggest collaborating with someone who is an expert in gut microbial ecology - there are many out there.
Sharanpreet - In addition to trying to collect the castings (feces) of living worms, you can dissect individual worms as done in the following article.
Isolation of species can be done on various selective or enrichment media, but ID of the bacteria is through standard methods of bacterial identification. Using modern techniques such as pyrosequencing can give you a good list of bacterial species, and then you can design a system to culture the species you might be interested in studying.