The basics of offensive moshing are that you want to be as effective as possible while lowering your own likelihood of injury. So I guess the first rule is don't be stupid. If you see a hardcore dancer being lame and fighting invisible ninjas don't get in the way of the spikey bracelets he's wearing on his wrists and try not to get kicked in the junk. Instead try either throwing yourself at him from a different angle or throw someone else at him because he's a hardcore dancer so he needs to be taken out.
As for basic styles of moshing, it's best to use a visual aid, so here's Sick of it all's music video for Step Down.
That's not everything, but of all of those my favorites are the windmill and the pickin' up change.
Sometimes you're at a show with friends so while on offense it's fun to team up. The most basic of these it to whip your friend out into the pit by hand. Stand at the edge of the pit with you in back and your friend directly in front of you with a few inches between the two of you. hold one hand to the center of his back at slightly below shoulder height and put your other hand on the back of that hand. Then just launch him forward by straightening out your arms. If you put your legs and back into it it's a lot more effective.
Another fun one to do with a friend is the spin up. You should each face each other then hold arms by clasping your hands around his wrists and he does the same to you. You should be holding his left wrist with your left hand and ditto for right to right. If done properly your arms should cross in the middle. Now spin yourselves trying to orbit around a point between the two of you. If you're both of similar weight this should be easy. The fun really starts if you're not of equal weight. If there is a small difference in weights the lighter person will orbit farther from the center than the heavy person giving the heavier person an object (the lighter person) to aim at people as you two move about the pit. If there is a significant difference in weight there's a chance that the heavier person will be able to use the centrifugal force to lift the lighter person right off of the ground. Once this happens the heavier person has the opportunity to use the lighter person as a sort of buzz saw and cut through other moshers as well as the crowd around the pit. This one is a blast and one of my favorite things to do at a show.
Ok, enough about offense, let's talk defense. The most important thing to remember here is to be aware of your surroundings. If you're at bigger shows and festivals you might be at the edge of the pit facing in and be completely oblivious to another mosh pit directly behind you. I can't tell you how many times I've been nailed in the back by someone coming from another pit, but it's enough to remember it and pass along that info. When you're at the edge of a pit you may want to put both arms out with fists forward to protect yourself, but this is actually a bad way to do it. What you should do is similar to what you would do to launch a friend onto the pit. Make a fist. I'm right handed so I make that fist with my left hand. Then put your other hand on the back of that fist. your thumb and forefinger should be at your other wrist. Then put your arms out to an almost straight position. This is important. If someone runs into your arms while they're fully straight out there's a chance your elbow will bend backwards instead of the way it's supposed to bend. Keeping your elbows bent will prevent this. If a person comes towards you at speed use your legs and back to cushion his landing on your outstretched fist. Then if you feel like it, after leaning back a bit go ahead and launch him just the way you would launch a friend. Try to aim for some hardcore dancers or emofags.
I'm going to share a secret with you here. The best method for breaking up a spin up. Some people when they spin up will just stay in the same place and spin for a good while. This makes them an easy target. Stand facing them, but slightly off center to them in such a way that the people spinning spin towards you instead of away. That is, stand to the right if they're spinning clockwise and to the left if they're spinning counterclockwise. If you get the timing just right you can launch yourself at a tangent to their circle and strike one of them directly. If you do this correctly they'll just sort of explode and go flying. It's great fun.
Well, alrighty. I've had fun writing this, but it's gone on for a long while so I'm going to wrap it up. Happy moshing.