Command-line Mac OS X Virus Scan

I got a copy of Virex (v7.2) with my .Mac account. The GUI looks nice and clean but feels a bit "half-finished" to me. You can only schedule it to automatically run on login, which is a bit useless if you leave your machine on 24/7. I did a little digging and found there’s a command-line scanner that exposes a few more useful options.

I first linked the vscanx application and man pages to locations in my path and manpath:

sudo ln -s /usr/local/vscanx/vscanx /usr/local/bin/vscanx
sudo ln -s /usr/local/share/man/man1/vscanx.1 /usr/share/man/man1/vscanx.1`</pre>

Here's a quick script that cleans and quarantines infected files, and makes the report a bit more useful (by showing less info!). I've got this running daily as a cron job:

<pre>`#!/bin/sh

logfile="/var/virusscan.log"
quarantine="/Volumes/Workhorse/Quarantine/"
exclude="./exclude.txt"
scandirs="/Users/tim/"

echo "Virus scan started: "`date` >> $logfile

vscanx \
    --unzip \
    --verbose \
    --recursive \
    --one-file-system \
    --clean \
    --summary \
    --move $quarantine \
    --exclude $exclude \
    $scandirs | grep --invert-match Scanning >> $logfile

The exclude.txt lists files and directories not to scan.

There doesn’t seem to be a command to update the virus definitions, but should be possible with wget, curl, or similar.

Comments