When a beetle is infected by the cordyceps fungus, the following process occurs:

Spore attachment and invasion: The spores of the cordyceps fungus adhere to the beetle's body and germinate. The fungal filaments then penetrate the beetle's exoskeleton and enter its body.