You’ve been infected with the “Flashback” malware. See this Apple support document:
Back up all data, if you haven't already done so.
Select ▹ Software Update to install the latest Java update (if Java is already installed) or the Flashback malware removal tool (if Java is not installed under Lion), as well as any other available updates. Installing either of those items should clear the infection in most cases. You must update to the latest version of Mac OS X 10.6 or 10.7 before you can install the Java update.
The removal tool runs automatically in the background and is then deleted. Don’t look for something to click. If the malware is removed, you’ll be notified.
After you’ve secured your system — not before — change every Internet password you have, starting with banking passwords, and check all financial accounts for unauthorized transactions.
You need to install the Java for Mac OS X 10.6 Update 8 to remove the variants of the flashback trojan.
If Safari crashes again, use the removal tool here > Flashback Removal Tool - F-Secure Weblog : News from the Lab
You can avoid malware in the future > OpenDNS Community > Blog > Worried about Mac malware? Just set up OpenDNS.