Sharks are attracted to thrashing--they equate those movements with wounded prey--and can sense fear, both of which can send them into attack mode. Try to keep your wits about you so you can make smart decisions and prepare to defend yourself. If the shark is nearby and hasn't attacked, move toward the shore as swiftly and quietly as you can, using smooth, rhythmic strokes.  Try to keep the shark in your sights at all times.  If you notice the shark is displaying aggressive behavior (erratic movements, a hunched back, or quick turns), move as quickly as possible to a rock, nearby kelp canopy, or shore. Get it between you body and the shark and use it as a shield, protecting your front and sides. The surfboard's buoyancy can prevent a shark from dragging you deep under the water, should it attack. If the shark does attack, don't play dead. Use your surfboard as a weapon. Try to avoid using your hands if possible, since you may injure them on the shark's teeth. Aim your blows at the shark's eyes, gills, or nose. Your life depends on swift medical attention. Scream for help, send a friend to get the lifeguard and call 911, do whatever it takes to make sure help is on the way as soon as possible.

Summary:
Remain calm. Get out of the water. Try to use your surfboard as a buffer. Defend yourself aggressively. Get out of the water and seek immediate medical attention if attacked.