You don't really get "attacked" by snakes like you can be by something like a wolf or bear. Snakes aren't territorial, they just want to be left alone. It will only bite you if it feels surprised or threatened.
To be honest, the best way to "fight off" a snake attack is to just give it some space. It's not like the snake is going to chase you down if you walk away.