Maeril made a comic, and it's well worth sharing...
- Step one: engage the victim in conversation while ignoring the harasser.
- Step two: find a subject to talk about while continuing to ignore the harasser.
- Step three: continue to build a safe space by keeping eye contact with the victim. Do not engage with or discuss the harasser.
- Step four: continue until the harasser leaves and the victim is in a safe place, while respecting the wishes of the victim.
While there is no step five, if you are secretly a vigilante, I'm sure you can later hunt down the harasser and scare them straight - but I generally wouldn't recommend it. People dumb enough to harass others are not smart enough to be scared straight.
If you see someone else taking these actions to help someone, it might be smart to pull out a phone and video the harasser so you can inform authorities about the scumbag, but don't video unless somebody is helping protect the victim.
This cartoon doesn't say what to do if the harasser turns attention on you. For the most part, you just ignore it. If they physically attack you, then call authorities. Otherwise, just ignore them and continue to make a safe space.