Front - Jack up the vehicle and pull the tire/rim. Use a good punch and heavy hammer to drive the broken stud out. Remove the brake caliper and rotor. Install the new stud as far as possible by hand. Make sure it starts square in the hole. Put some anti seize or light oil on the threads and stack some washers over the threads so you don't have to put the nut on so far. Use a standard nut of the proper size (metric I believe) NOT a lug nut and tighten it down with a breaker bar and deep well socket. Watch to make sure it is seated all the way, then remove the nut/washers. Reinstall the brake rotor and caliper, tire/rim and use a NEW lug nut on that new stud.
Rear - Jack up vehicle, remove tire/rim and remove brake rotor. Use a punch/heavy hammer and drive the broken stud out. Installing the new one means you may have to rotate the axle some to get it into the hole, sometimes things are in the way (wheel cylinder, brake shoes, brake center pin). Then proceed as you would for the front. Reinstall the brake drum (check the brakes for wear/leakage/damage while your there) Re-install the tire/rim and enjoy.
Do NOT install the new stud using the rim as a backer for the nut, REAL possible to bend or crack the rim with the nut. Then you buy a new rim as well as a stud. Do not leave the rotor in place while torque in the new stud. It can damage the rotor enough to cause pulsating brakes.