I don't know why you think the pipe is bad and needs replacing, but it can be done. It is a lead/oakum joint. A plumber would make very short work of this as well as replacing the pipe. You can DIY if saving a few dollars is that important, but the best course of action is to have a professional do it. But, if you must, The lead can be removed by drilling many holes around it and then prying the remaining lead out with an old screwdriver. I assume you would then want to replace the pipe with PVC. The way that can be done is with a rubber doughnut that will fit in the cast iron tee. The doughnut has to be the proper size and the tee must be in good condition for the doughnut to seal. This would probably be such a simple job for a plumber you would only be out his minimum charge and the job would be done right.