How does a computer get infected with a virus or spyware?

Unfortunately, it became quite easy nowadays to infect your computer with malware:

  1. Accepting some plug-in or toolbar installation
  2. Opening email attachments “thesisgenerator.exe”
  3. Not running the latest updates on the operating system, the browser, etc.
  4. Installing software or media from unknown sources
  5. Running your system without a firewall

Sometimes, webpages try to scare users to install a trojan. For example, there exists a trojan version of the program MacSweeper, which promises to clean your system 😛

More on the topic: http://www.computerhope.com/issues/ch001045.htm