In the early 20th century, they used to extract CEEs from pregnant mare urine for HRT. And now we have all the cool modern stuff. Here is a Wikipedia article to get started. I also recommend researching ancient transgender history for more info since it is really interesting.
Afaik the amount you take must be adjusted carefully to how your body responds. So that requires professional measurements.
Also I'd like to add that illegal stuff can contain anything and no you are not immune to that risk.