Skip to content

Instantly share code, notes, and snippets.

@DerFichtl
Last active November 23, 2024 08:21
Show Gist options
  • Save DerFichtl/d041785294d42259fa2b6ee4831c9a55 to your computer and use it in GitHub Desktop.
Save DerFichtl/d041785294d42259fa2b6ee4831c9a55 to your computer and use it in GitHub Desktop.
clamav on mac osx - install and configure the virus scanner on mac osx
layout title published tags
post
clamav - install and configure on mac osx
true
blog
clamav

Install Clamav

Install clamav via homebrew

$ brew install clamav

Check the clamav config directory

$ ls /usr/local/etc/clamav

Create a minimum config (freshclam.conf) for the definition update command freshclam

$ echo "DNSDatabaseInfo current.cvd.clamav.net\nDatabaseMirror database.clamav.net" > /usr/local/etc/clamav/freshclam.conf

Update freshclam virus definitions

$ freshclam

Scan your own users Downloads folder (takes some time to startup)

$ clamscan --infected --recursive ~/Downloads
----------- SCAN SUMMARY -----------
Known viruses: 6736785
Engine version: 0.102.2
Scanned directories: 32
Scanned files: 85
Infected files: 0
Data scanned: 2.41 MB
Data read: 1.65 MB (ratio 1.46:1)
Time: 18.931 sec (0 m 18 s)

Scan your files, create a logfile and move bad filtes to a quarantine folder

$ clamscan -r --log=~/clamav/log/scan.log --move=~/clamav/quarantine ~/Downloads

... or use the clamd demon for faster scanning.

clamd demon config and scanning

Add a minimal config for clamd

$ echo "LocalSocket /tmp/clamd.socket" > /usr/local/etc/clamav/clamd.conf

Start the clamd demon (takes some seconds)

$ clamd

Check if the clamd demon is running (end with 'q')

$ clamdtop

Use the clamdscan command instead of the clamscan command

$ clamdscan ~/Downloads
/Users/derfichtl/Downloads: OK

----------- SCAN SUMMARY -----------
Infected files: 0
Time: 1.298 sec (0 m 1 s)
@louisgit1
Copy link

Carreful about your line "Create a minimum config (freshclam.conf) for the definition update command freshclam", You forgot an "\n" on the line: $ echo "DNSDatabaseInfo current.cvd.clamav.net**\n**DatabaseMirror database.clamav.net" > /usr/local/etc/clamav/freshclam.conf

@casperghst42
Copy link

Instead of using echo for creating freshclam.conf use this:

cat <<EOF | tee /usr/local/etc/clamav/freshclam.conf
DNSDatabaseInfo current.cvd.clamav.net
DatabaseMirror database.clamav.net
EOF

That will always work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment