Page 1 of 1
[LINUX] Scan downloaded files for viruses
Posted: June 23rd, 2008, 8:26 am
by undertow
The following script is for Linux only. It requires
ClamAV to be installed. It will scan the downloaded directory, and if anything is found it will rename the directory adding an "_INFECTED_" prefix to the directory name. It also places a file named "clamscan.log" within the directory as well. So far, it's been working great.
Code: Select all
#!/bin/sh
BASENAME=`basename "$1"`
LOGFILE="$1/clamscan.log"
/usr/bin/clamscan -i -l "$LOGFILE" -r "$1"
if [ $? -eq 1 ]; then
cd "$1"/..
mv "$BASENAME" _INFECTED_"$BASENAME"
fi
Re: [LINUX] Scan downloaded files for viruses
Posted: June 23rd, 2008, 3:07 pm
by shypike
Did it find any viruses yet?
Seriously, it hard to tell if it actually works until it catches a virus.
Re: [LINUX] Scan downloaded files for viruses
Posted: June 23rd, 2008, 3:18 pm
by undertow
shypike wrote:
Did it find any viruses yet?
Seriously, it hard to tell if it actually works until it catches a virus.
Of course I tested it, and yes it did detect the virus just fine.
I queued up a nzb, and copied a virus infected file into the generated directory within my incomplete directory. Once the download finished and the processing script began, it immediately detected the compromised file and renamed the directory accordingly.
Feel free to test for yourself by using the following test file: hxxp://
www.eicar.org/download/eicar.com **
I've renamed the url so it cannot be clicked. Be advised that the link is to a file
knowingly infected with the Eicar Test Virus.
Re: [LINUX] Scan downloaded files for viruses
Posted: June 23rd, 2008, 4:30 pm
by shypike
Good job
Re: [LINUX] Scan downloaded files for viruses
Posted: February 6th, 2012, 3:07 pm
by sander
I added two echo commands to the script of which the output shows up in the SAB webgui (instead of the time it took to scan the files)
Code: Select all
#!/bin/sh
BASENAME=`basename "$1"`
LOGFILE="$1/clamscan.log"
/usr/bin/clamscan -i -l "$LOGFILE" -r "$1"
if [ $? -eq 1 ]; then
cd "$1"/..
mv "$BASENAME" _INFECTED_"$BASENAME"
echo "Virus found!"
else
echo "All OK - no virus found."
fi
See
for the result (with the old output at the bottom of the picture)
Re: [LINUX] Scan downloaded files for viruses
Posted: February 11th, 2012, 6:33 pm
by aaearon
Love it, thanks