Mailing List Archive

[clamav-users] Why clamdscan and clamscan may give different results
Having built ClamAV 0.102.1 a few days ago, I stumbled on the following
unfortunate behavior (which is probably not related to 0.102.1), and
have a suggestion to remedy it.

I recently did a backup from a Win 7 Pro machine to a directory on our
CIFS server and decided to try running ClamAV on the large set of ZIP
files which resulted, and I used clamdscan for efficiency. (All the ZIP
files within ClamAV's inherent 4 GB size limit.)

I was shocked to find that 24 out of the 715 ZIP files were flagged as
containing viruses, in spite of the fact that the Win 7 machine runs
Microsoft Security Essentials and it never found any problems in the
files which comprise the backup ZIPs. So I figured that ClamAV probably
had a few virus patterns that MSE didn't have, or the two AV updates
were out of sync.

So I ran MSE explicitly on one of the files in question, and it still
didn't find anything. OK, different virus DBs for MSE and ClamAV. Then
I ran clamscan on that same file (#177). Now *it* didn't find the virus
that the clamdscan had found. OK again, slightly different ClamAV DB
since they were run on different days.

Finally, I ran clamdscan again on that file (after stopping and
restarting clamd to make sure it had the same DB as clamscan). This
time, again, it found the same virus, whether or not I used the
"--fdpass" option (just in case that made a difference).

Why did this happen? It seems to be because clamscan does not respect
the options in clamd.conf, in particular those relating to max file
size and max scan size. The 4 console outputs below illustrate this.
The first is a simple clamscan (which finds no virus), the next are 2
clamdscans (with and without "--fdpass") and the 4th is a clamscan with
explicit max options (to correspond to the clamd maxes). Notice that
this last clamscan now detects the virus that both clamds detected.

Currently clamscan doesn't even give a warning (e.g., an error message)
if it scans no data at all. Note how the 1st clamscan (with default
maxes) reported "Backup files 177.zip: OK". It took me a while to see
that it also said "Data scanned 0.00 MB", which makes the "OK" claim
extremely questionable.

To mitigate this kind of misleading behavior, where clamscan apparently
uses some built-in maxes, I would suggest that either clamscan should
respect the relevant options in clamd.conf if they are made explicit,
or, better yet, have its own clamscan.conf which allows overriding the
any built-in defaults. (A separate clamscan.conf file could then also
make clear what the defaults are, and the extra time to process it
would be trivial compared to the time spent loading the virus DBs.)

============================================

imes>/Backup8/IME8/Backup Set 2020-01-01 104148/Backup Files 2020-01-01 104148$ clamscan -v Backup\ files\ 177.zip
Scanning Backup files 177.zip
Backup files 177.zip: OK

----------- SCAN SUMMARY -----------
Known viruses: 6659621
Engine version: 0.102.1
Scanned directories: 0
Scanned files: 1
Infected files: 0
Data scanned: 0.00 MB
Data read: 199.59 MB (ratio 0.00:1)
Time: 8.917 sec (0 m 8 s)

============================================

imes>/Backup8/IME8/Backup Set 2020-01-01 104148/Backup Files 2020-01-01 104148$ /opt/clamav/bin/clamdscan -v --fdpass Backup\ files\ 177.zip
/Backup8/IME8/Backup Set 2020-01-01 104148/Backup Files 2020-01-01 104148/Backup files 177.zip: Win.Trojan.Agent-1367203 FOUND

----------- SCAN SUMMARY -----------
Infected files: 1
Time: 2.010 sec (0 m 2 s)

============================================

imes>/Backup8/IME8/Backup Set 2020-01-01 104148/Backup Files 2020-01-01 104148$ /opt/clamav/bin/clamdscan -v Backup\ files\ 177.zip
/Backup8/IME8/Backup Set 2020-01-01 104148/Backup Files 2020-01-01 104148/Backup files 177.zip: Win.Trojan.Agent-1367203 FOUND

----------- SCAN SUMMARY -----------
Infected files: 1
Time: 1.964 sec (0 m 1 s)

============================================

imes>/Backup8/IME8/Backup Set 2020-01-01 104148/Backup Files 2020-01-01 104148$ /opt/clamav/bin/clamscan --max-filesize=1000M --max-scansize=1000M -v Backup\ files\ 177.zip
Scanning Backup files 177.zip
Backup files 177.zip: Win.Trojan.Agent-1367203 FOUND

----------- SCAN SUMMARY -----------
Known viruses: 6659621
Engine version: 0.102.1
Scanned directories: 0
Scanned files: 1
Infected files: 1
Data scanned: 4.05 MB
Data read: 199.59 MB (ratio 0.02:1)
Time: 12.085 sec (0 m 12 s)

============================================

P.S. Why ClamAV finds viruses that MSE doesn't find is a separate
question. Perhaps MSE has size limits that they don't even tell us
about?

_______________________________________________

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] Why clamdscan and clamscan may give different results [ In reply to ]
That's correct and AFAIK, has always been the case. clamscan configurations is accomplished during the compile stage leading to installation and clamd.conf options only apply to clamd and clamdscan.

-Al-

On Jan 8, 2020, at 18:25, Paul Kosinski via clamav-users <clamav-users@lists.clamav.net> wrote:
>
> It seems to be because clamscan does not respect the options in clamd.conf...
Re: [clamav-users] Why clamdscan and clamscan may give different results [ In reply to ]
>On Jan 8, 2020, at 18:25, Paul Kosinski via clamav-users <clamav-users@lists.clamav.net> wrote:
>> It seems to be because clamscan does not respect the options in clamd.conf...

On 08.01.20 18:38, Al Varnell via clamav-users wrote:
>That's correct and AFAIK, has always been the case. clamscan
> configurations is accomplished during the compile stage leading to
> installation and clamd.conf options only apply to clamd and clamdscan.

you can pass options to clamscan on command line.

clamscan is not clamd, therefore it does not pass clamd's config file.
We can of course ask why there's no common config file for all clamav
programs (maybe clamav libeary) but that is another issue.


--
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
"One World. One Web. One Program." - Microsoft promotional advertisement
"Ein Volk, ein Reich, ein Fuhrer!" - Adolf Hitler

_______________________________________________

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] Why clamdscan and clamscan may give different results [ In reply to ]
Yes of course you can pass options to clamscan on the command line
(it's what I did in my 4th example). But my point is that it makes
clamscan much harder to use in practice, as with only the default
values for the options, clamscan can be very misleading.

For now, I guess I'll have to write a little front-end script to pass
sensible options to clamscan to make it actually useful. (Currently,
clamscan has over 80 options. Are we expected to remember them all when
using the command line?)

P.S. Specifying options via environment variables and/or configuration
files to make command line usage easier is a Unix tradition. And many
GUI programs also allow persistent configuration to ease their usage.


On Thu, 9 Jan 2020 10:06:09 +0100
Matus UHLAR - fantomas <uhlar@fantomas.sk> wrote:

> >On Jan 8, 2020, at 18:25, Paul Kosinski via clamav-users
> ><clamav-users@lists.clamav.net> wrote:
> >> It seems to be because clamscan does not respect the options in
> >> clamd.conf...
>
> On 08.01.20 18:38, Al Varnell via clamav-users wrote:
> >That's correct and AFAIK, has always been the case. clamscan
> > configurations is accomplished during the compile stage leading to
> > installation and clamd.conf options only apply to clamd and
> > clamdscan.
>
> you can pass options to clamscan on command line.
>
> clamscan is not clamd, therefore it does not pass clamd's config file.
> We can of course ask why there's no common config file for all clamav
> programs (maybe clamav libeary) but that is another issue.

_______________________________________________

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