[UPDATE 2014-10-20]: This tricks seems to cause high CPU usage in Yosemite, try using launchd instead.
[UPDATE 2014-10-02]: defend yourself from becoming a zombie courtesy of Mac.BackDoor.iWorm
[UPDATE]: Use this trick to fend off the new malware XLSCmd
Macs are not immune to malware. Authors of malicious software often try to get a LaunchDaemon or LaunchAgent installed onto your computer in one or more of the following locations:
/Library/LaunchDaemons /Library/LaunchAgents /System/Library/LaunchDaemons /System/Library/LaunchAgents /Users/<username>/Library/LaunchAgents
OS X has a lesser-known feature called Folder Actions. These allow you to run scripts when an item is added to a folder. You can set up a simple script that lets you know when an item is added to one of the folders above and then open it to see what was added. If it is not something you recognize or were expecting, delete it.
Enable Folder Actions
- Right-click one the the folders listed above
- Choose Services > Folder Actions Setup…
- Check Enable
Assign A Folder Action
- Click the plus sign on the right side of the window
- Highlight add – new item alert.scpt
- Click Attach
Repeat the steps above for each folder you want to monitor. When a new item is added to any of these folders, a window will popup asking if you want to view it.