If the snake does not eat the rat, I reach in with my hand to get it. If it is close to the head of the snake and I think the snake may strike, I use a pair of tongs to move the rat (by pulling it by the base of the tail) to another spot in the tub.
Not sure what you meant by rat attacking a snake. If I see a snake coil a rat and the rat starts to bite the snake, I give it a good thump on the head. That usually stuns the rat until the snake can finish the job.