Mailing List Archive

[clamav-users] clamav scan of changed files
Categorization: Unclassified
Hi,

I would like to know what would be the best way to do a virus scan of changed or new files only. I want to run a daily scan of changed and new files during weekdays and run a full scan on weekends.

I did some search and was able to find a few ways of doing it but I would also like your suggestions.

Thank you and have a great day.

Gerry Leveille
Innovation and Emerging Technologies Section (IETS)
Strategic Engineering & Technology Integration Division (SETI)
Solutions Architecture & Integration Directorate (SAID)
Information Technology Branch (ITB)
Canada Revenue Agency
875 Heron Road, Ottawa ON K1A 0L5
gerald.leveille@cra-arc.gc.ca
(613) 720-1154
Re: [clamav-users] clamav scan of changed files [ In reply to ]
Hi there,

On Tue, 20 Oct 2020, Leveille, Gerald via clamav-users wrote:

> I would like to know what would be the best way to do a virus scan
> of changed or new files only. I want to run a daily scan of changed
> and new files during weekdays and run a full scan on weekends.
>
> I did some search and was able to find a few ways of doing it but I
> would also like your suggestions.

It would help to know on what operating system(s) you plan to do this...

--

73,
Ged.

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] clamav scan of changed files [ In reply to ]
Categorization:
Unclassified

Hi Ged,

Sorry, this is on RHEL Linux 7.8.

I already have a script doing full daily scans but I want to change the weekdays scans.

Thank you
Gerry

-----Original Message-----
From: clamav-users <clamav-users-bounces@lists.clamav.net> On Behalf Of G.W. Haywood via clamav-users
Sent: October 20, 2020 8:14 AM
To: Leveille, Gerald via clamav-users <clamav-users@lists.clamav.net>
Cc: G.W. Haywood <clamav@jubileegroup.co.uk>
Subject: Re: [clamav-users] clamav scan of changed files

***ATTENTION***

This email originated from outside of the Government of Canada. Do not click links or open attachments unless you recognize the sender and believe the content is safe. For more information regarding reporting suspicious emails, please visit the KnowHow webpage: Suspicious emails - how to report<http://druid/KnowHow/sec-suseml-e.asp>

Ce courriel provient de l'extérieur du Gouvernement du Canada. Ne cliquez pas sur les liens et n’ouvrez pas les pièces jointes, à moins de connaître l'expéditeur et croire que le contenu est sécuritaire. Pour de plus amples renseignements sur la façon de signaler les courriels suspects, veuillez consulter la page Web SavoirFaire: Courriels suspects – Comment signaler<http://druid/savoirfaire/sec-suseml-f.asp>



Hi there,

On Tue, 20 Oct 2020, Leveille, Gerald via clamav-users wrote:

> I would like to know what would be the best way to do a virus scan of
> changed or new files only. I want to run a daily scan of changed and
> new files during weekdays and run a full scan on weekends.
>
> I did some search and was able to find a few ways of doing it but I
> would also like your suggestions.

It would help to know on what operating system(s) you plan to do this...

--

73,
Ged.

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] [EXTERNAL] clamav scan of changed files [ In reply to ]
"Leveille, Gerald via clamav-users" <clamav-users@lists.clamav.net> wrote:
> Categorization: Unclassified
> Hi,
>
> I would like to know what would be the best way to do a virus scan of changed or new files only. I want to run a daily scan of changed and new files during weekdays and run a full scan on weekends.
>
> I did some search and was able to find a few ways of doing it but I would also like your suggestions.

I run this script from cron:

----
#!/bin/sh
export PATH=/usr/bin:$PATH
find /data -type f -mtime -7 >scanfiles
clamscan -f scanfiles -i
rm -f scanfiles
----

-Dave

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] [EXTERNAL] clamav scan of changed files [ In reply to ]
Hello,


>> I did some search and was able to find a few ways of doing it but I would also like your suggestions.
>
> I run this script from cron:
>
> ----
> #!/bin/sh
> export PATH=/usr/bin:$PATH
> find /data -type f -mtime -7 >scanfiles
> clamscan -f scanfiles -i
> rm -f scanfiles


If you have parallel tool, the fastest way I found is :

find /data -type f -mtime -7 |parallel clamdscan -mi --fdpass
--no-summary {}


--
Cordialement / Best regards,

Arnaud Jacques
Gérant de SecuriteInfo.com

Téléphone : +33-(0)3.60.47.09.81
E-mail : aj@securiteinfo.com
Site web : https://www.securiteinfo.com
Facebook : https://www.facebook.com/pages/SecuriteInfocom/132872523492286
Twitter : @SecuriteInfoCom
Signatures for ClamAV antivirus : http://ow.ly/LqfdL

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] clamav scan of changed files [ In reply to ]
Hi there,

On Tue, 20 Oct 2020, Leveille, Gerald via clamav-users wrote:
> G.W. Haywood wrote:
>> Leveille, Gerald wrote:
>>
>> > I would like to know what would be the best way to do a virus scan of
>> > changed or new files only. I want to run a daily scan of changed and
>> > new files during weekdays and run a full scan on weekends.
>> >
>> > I did some search and was able to find a few ways of doing it but I
>> > would also like your suggestions.
>>
>> It would help to know on what operating system(s) you plan to do this...
>
> Sorry, this is on RHEL Linux 7.8.
>
> I already have a script doing full daily scans but I want to change the weekdays scans.

It very much depends on the situation you're facing.

If the machine to be scanned is somehow considered to be at risk of
compromise, then if I were going to do something like this I would
probably use 'rsync' to produce a directory on another machine which
contains the files to be scanned, then pass the directory name to its
local clamd (e.g. via clamdscan) and let it get on with it. This does
presuppose that you have another, trusted machine which is pretty much
a mirror of the machine being scanned so that rsync can do a full file
checksum to see if files have changed rather than relying on the inode
(directory) information which can be abused. It won't be blazing fast
but you can if you wish get plenty of logging on the scanning machine.

Granted I know nothing about what your machines do, and if they store
and/or share (especially with other operating systems) any untrusted
data there might be a case for scanning. But as you'll have gathered
if you've read any of my rambles on this list you'll know that I have
doubts about the utility of general system scanning. In particular,
using 'find' for example doesn't take into account that an intruder
who's worth his salt will go to great lengths to avoid changing the
directory information about things he manipulates. If he's any good,
looking for things which 'have changed' will only find the things you
aren't actually looking for, and if the scanner is on the same machine
he will almost certainly have nobbled it anyway. The 'ls', 'ps' and
'top' commands for example won't show you the binaries he's installed
and the processes he's running because he'll have nobbled all those as
well - within a fraction of a second of gaining access. Yes, he might
have nobbled rsync too, but it's a bit less likely and you're in with
a chance of testing for it.

My first experience of this sort of thing was over twenty years ago,
courtesy of the Red Hat Linux FTP server. That prompted me to move
over to Slackware and start a _long_ learning process, the pace of
which has not, er, slackened to this day. I'm not saying that the
Red Hat of today compares with the colander that it was in the late
20th century, but it's worth keeping in mind that, if you're serious
about security, you can't actually rely on anything that you haven't
thoroughly checked out yourself - and sometimes not even then.

The 64 dollar question now is "Why do you want to scan the system?"

--

73,
Ged.

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] clamav scan of changed files [ In reply to ]
Hi

> I would like to know what would be the best way to do a virus scan of changed or new files only. I
> want to run a daily scan of changed and new files during weekdays and run a full scan on
> weekends.
>
> I did some search and was able to find a few ways of doing it but I would also like your suggestions.

There is that daemon that can report any changed files in an operating
system, I known I played witg it many years ago as I wanted somethiung
able to scan anything on the fly. It was on FreeBSD, but such daemon
should exist for Linux too and it could send the files/filenames to the
scanning daemon.

Bests,

Olivier

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] clamav scan of changed files [ In reply to ]
On 10/21/20 4:08 AM, Olivier via clamav-users wrote:
> Hi
>
>> I would like to know what would be the best way to do a virus scan of changed or new files only. I
>> want to run a daily scan of changed and new files during weekdays and run a full scan on
>> weekends.
>>
>> I did some search and was able to find a few ways of doing it but I would also like your suggestions.
>
> There is that daemon that can report any changed files in an operating
> system, I known I played witg it many years ago as I wanted somethiung
> able to scan anything on the fly. It was on FreeBSD, but such daemon
> should exist for Linux too and it could send the files/filenames to the
> scanning daemon.
>
you could use incrond(8) which uses the inotify(2) interface to scan for changed files, this can be used to produce a list of files that will be scanned later.

Giovanni

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] clamav scan of changed files [ In reply to ]
The inotify-tools may be useful in this case. An example like in
https://fitzcarraldoblog.wordpress.com/2016/02/20/automatically-detecting-files-placed-in-my-downloads-directory-in-gentoo-linux-and-scanning-them-for-viruses/
should work.

On Wed, Oct 21, 2020 at 1:06 PM <giovanni+clamav@paclan.it> wrote:

>
> On 10/21/20 4:08 AM, Olivier via clamav-users wrote:
> > Hi
> >
> >> I would like to know what would be the best way to do a virus scan of
> changed or new files only. I
> >> want to run a daily scan of changed and new files during weekdays and
> run a full scan on
> >> weekends.
> >>
> >> I did some search and was able to find a few ways of doing it but I
> would also like your suggestions.
> >
> > There is that daemon that can report any changed files in an operating
> > system, I known I played witg it many years ago as I wanted somethiung
> > able to scan anything on the fly. It was on FreeBSD, but such daemon
> > should exist for Linux too and it could send the files/filenames to the
> > scanning daemon.
> >
> you could use incrond(8) which uses the inotify(2) interface to scan for
> changed files, this can be used to produce a list of files that will be
> scanned later.
>
> Giovanni
>
> _______________________________________________
>
> clamav-users mailing list
> clamav-users@lists.clamav.net
> https://lists.clamav.net/mailman/listinfo/clamav-users
>
>
> Help us build a comprehensive ClamAV guide:
> https://github.com/vrtadmin/clamav-faq
>
> http://www.clamav.net/contact.html#ml
>


--
Regards....

Nibin.

https://about.me/nibinvm
Re: [clamav-users] clamav scan of changed files [ In reply to ]
On Wed, 21 Oct 2020, giovanni+clamav@paclan.it wrote:

>
> On 10/21/20 4:08 AM, Olivier via clamav-users wrote:
> > Hi
> >
> > > I would like to know what would be the best way to do a virus scan
of
> > > changed or new files only. I
> > > want to run a daily scan of changed and new files during weekdays
and
> > > run a full scan on
> > > weekends.
> > >
> > > I did some search and was able to find a few ways of doing it but I
> > > would also like your suggestions.
> >
> > There is that daemon that can report any changed files in an operating
> > system, I known I played witg it many years ago as I wanted somethiung
> > able to scan anything on the fly. It was on FreeBSD, but such daemon
> > should exist for Linux too and it could send the files/filenames to
the
> > scanning daemon.
> >
> you could use incrond(8) which uses the inotify(2) interface to scan for
> changed files, this can be used to produce a list of files that will be
> scanned later.

I was assuming that clamav's on-access scanning used the same
mechanism as inotify.

I imagine that scan-on-write produces less load than scan-on-read (for
most
user files - obviously not for logfiles that are never read)
- at the price of nissing the most recent virus definitions,
and that using clamav's on-access scanning has the advantage of catching
the
nasties before the file is used, unlike the inotify-bsed solutions, which
avoid the latency that on-access scanning produces ...

Since these points are all guesses, if anyone could confirm or refute
them, that would be appreciated.

My one piece of advice for anyone thinking of off-line scanning
would be to work out what you will do when your scanner finds a nasty.

--
Andrew C. Aitchison Kendal, UK
andrew@aitchison.me.uk

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] clamav scan of changed files [ In reply to ]
Hi there,

On Wed, 21 Oct 2020, Andrew C Aitchison via clamav-users wrote:

> I was assuming that clamav's on-access scanning used the same
> mechanism as inotify.

No need to assume anything:

https://www.clamav.net/documents/on-access-scanning

It's documented there that it uses fanotify, only works on Linux and
requires Linux kernel version >= 3.8 to work. The fanotify man page
has a comparison with the inotify API.

> I imagine that scan-on-write produces less load than scan-on-read (for most
> user files - obviously not for logfiles that are never read)
> - at the price of nissing the most recent virus definitions,

Well I _do_ read my log files(!) and if I ever scanned anything I'd
exclude logfiles from the scan as a matter of routine. I think your
cost assessment is about right, modulo the database update frequency.

> and that using clamav's on-access scanning has the advantage of catching the
> nasties before the file is used, unlike the inotify-bsed solutions, which
> avoid the latency that on-access scanning produces ...

Not sure that I follow all that, but the perceived advantage of having
a potential to catch any nasties must necessarily be discounted by the
probability that it will catch anything when it actually looks for it.
Rough order of magnitude I guess a one in three chance on a good day.

> My one piece of advice for anyone thinking of off-line scanning
> would be to work out what you will do when your scanner finds a nasty.

Excellent advice. :)

--

73,
Ged.

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] clamav scan of changed files [ In reply to ]
On Wed, 21 Oct 2020, G.W. Haywood via clamav-users wrote:

> On Wed, 21 Oct 2020, Andrew C Aitchison via clamav-users wrote:

> > and that using clamav's on-access scanning has the advantage of
catching the
> > nasties before the file is used, unlike the inotify-bsed solutions,
which
> > avoid the latency that on-access scanning produces ...
>
> Not sure that I follow all that, but the perceived advantage of having
> a potential to catch any nasties must necessarily be discounted by the
> probability that it will catch anything when it actually looks for it.
> Rough order of magnitude I guess a one in three chance on a good day.

I meant that on-access scanning may block the nasty before the vulnerable
program parses/executes the exploit, but an inotify-based solution
will give the nasty file to the vulnerable program at the same time as,
if not before, the scanner gets to check it.

--
Andrew C. Aitchison Kendal, UK
andrew@aitchison.me.uk

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: [clamav-users] clamav scan of changed files [ In reply to ]
Hi there,

On Thu, 22 Oct 2020, Andrew C Aitchison via clamav-users wrote:
> On Wed, 21 Oct 2020, G.W. Haywood via clamav-users wrote:
>> On Wed, 21 Oct 2020, Andrew C Aitchison via clamav-users wrote:
>
>> > and that using clamav's on-access scanning has the advantage of catching the
>> > nasties before the file is used, unlike the inotify-bsed solutions, which
>> > avoid the latency that on-access scanning produces ...
>>
>> Not sure that I follow all that, but the perceived advantage of having
>> a potential to catch any nasties must necessarily be discounted by the
>> probability that it will catch anything when it actually looks for it.
>> Rough order of magnitude I guess a one in three chance on a good day.
>
> I meant that on-access scanning may block the nasty before the vulnerable
> program parses/executes the exploit, but an inotify-based solution
> will give the nasty file to the vulnerable program at the same time as, if
> not before, the scanner gets to check it.

Perhaps - you might have to be a bit more, er, creative with inotify
but it can generate an event on file create, which fanotify won't do.
The creativity would mostly mostly about preventing access to a newly
created file until it's been scanned and pronounced OK. I don't know
how you'd handle modifications which turn benign files into malicious
ones, and that sort of thing seems to be more common lately.

--

73,
Ged.

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml