Prior to OS X, there were viruses written for Apple Macintosh computers. Any operating system on which software can be installed at all is potentially vulnerable to infection from a virus, which is itself a form of software. An operating system cannot distinguish good software from bad software; this is usually done by antivirus scanners or behavior monitoring programs. In the past, bona fide "viruses" were mostly targeted at specific groups or individuals, such as politicians and high-profile clergymen, most of whom are non-technical users who will use whatever their employers provide (most likely Windows). But in the recent decades average users have been intentionally attacked for the purpose of notoriety or to cause grief. Viruses in themselves are intentionally destructive, rather than stealing information or providing control over someone's machine. While virus creation and infection has been on the downturn in favor of malware, infection is still entirely possible and not to be ruled out.
These days most malicious programs in the wild are Trojan horses. Software which supposes to be something it really is not, Like "MacDefender", or "AntiVirus 2011". Besides Trojans, there are also a lot of spyware and exploits that can infect a computer remotely and surreptitiously, usually through a Web browser. Unlike viruses, which are written out of malice, these parasites are written for profit, be it to direct a botnet to attack other networks, or to steal user information to sell to identity thieves.
Apple's Web site says that "a Mac is 100 percent safe from viruses designed to attack PCs." This is true; otherwise, Apple could face a class-action lawsuit. The loophole is a single, clever subtlety in the phrase, "designed to attack PCs."
There are in fact some Trojans written for Mac OS X, but no viruses. While Apple announces that their systems are "more resistant to attack" There are professional security researchers who have successfully compromised both Macs and Windows computers remotely, as well as other operating systems for PCs, servers, and even mobile devices like the iPhone.
It is widely believed that Unix-based operating systems cannot be infected at root level unless the user authorizes it with a password; this is untrue. All platforms have known privilege escalation vulnerabilities, and more are being discovered all the time.
At the time of writing, Windows users remain by far the most likely to encounter viruses, or any other type of malware/unwanted programs. In over 20 years, the total count of Mac viruses is about 50 (all prior to Mac OS X). There are thousands for Windows.
However, The unfortunate truth is ALL computers are susceptible to viruses or attack.
While the fallacy that "Mac's can't get viruses" is pushed by Apple, the truth of the matter is they are just as susceptible as windows users except they aren't being directly targeted being that Macintosh used to run less than 6% of the global operating system market share (Source: C|Net). As more users are moving over to the Macintosh OS, they recently have been receiving more malware traffic. Macs require signed software, making it difficult to get malware to run. But naive users make it's built in protections nearly useless like in the MacDefender malware exploit from 2011. The software required the user to accept the installation, under the guise of protection, but it turned out to be malware, launching pornographic websites while warning you that you have Malware installed and offering you to purchase the Full version of MacDefender to remove the fake virus for a large sum of money. (Source: C|net)
Recently a new threat has surfaced caused by a Java exploit, in which Apple took 6 weeks after Oracle (the current owner of Java) to patch (Source: Forbes), allowing more than 2 percent (Source: ComputerWorld) of scanned Macintosh systems to become compromised. Kapersky noted through an experiment that over 600,000 systems were connected to their experimental C&C (Command and Control) botnet server, over 98% are heuristically detected to have been Macintosh systems. (Source: SecureList)
So to say that Apple Computers do not get Viruses is a commonly perpetuated fallacy, pushed by Apple, and naive Mac users alike. The truth is that no computer system or operating system is truly secure, or free of viruses and malware.
All computers are at the same risks for viruses and spyware. (And Mac's can carry Windows viruses and can possibly infect Windows machines via Network, Hard Drive, or USB Jump Drive) So users need to be careful about what websites they visit and what they download off the internet because malware is everywhere and can really cause problems no matter what OS or computer manufacturer.
Chat with our AI personalities
In the past, Macs have been hacked, and there is malware out there (such as viruses and worms) for Mac computers. While it is rare to see them, you should be careful nonetheless. Don't open suspicious files and links sent through email and, if you're concerned you may have any viruses on your computer (including Windows viruses, which you could still pass on to friends through email), you should consider running an antivirus on your computer. Sophos Anti-Virus works well on Macs, and Kaspersky Anti-Virus recently released a Mac product which I haven't tested (but is supposed to be quite good).
In the strictest sense of the word, there are no viruses affecting a computer running the latest version of Mac OS X (though there is a small amount of other malware for OS X on the internet). If you exercise caution and common sense in navigating the internet, using email, etc. then chances are you will not ever have to worry. Users of jailbroken iPhones should, however, change the root password on the phone to something other than the default, since there are a few iPhone worms capable of infecting jailbroken phones. Since Apple doesn't support jailbroken phones officially, those who have their iPhones infected are on their own.
Yes, there are viruses and other malware that can affect Macintosh computers. However, they are not widespread because the percentage of Web-connected computers running Mac OS is quite low and thus transmission is difficult. Macs have more glitches that could be exploited, but because they are fewer in number and at low diffusion throughout the Internet they are, in practical terms, immune to almost all current threats.