File::Scan isn't the best means of looking for virii but I thought it would be interesting.
And it was mentioned earlier in how to use file::scan.

#!/usr/bin/perl use strict; use warnings; use File::Find; use File::Scan; my $scandir = "c:\\"; # couldn't get it to work with 'c:/' my $results = "c:\\virusscan.txt"; open(VS, ">", $results); my $filescan = File::Scan->new(extension => 'bad', move => 'infected') +; find({ wanted => \&doscan, follow_skip => 2 }, $scandir); sub doscan { return if /^[.]+/; my $file = $File::Find::name; $file =~ s#\\##; print "$file\n"; return if (-d $file); $filescan->scan($file); if (my $e = $filescan->error()) { print "$file $e\n"; } if (my $c = $filescan->skipped()) { my @skip = ( "file not skipped", "file is not vulnerable", "file has zero size", "the size of file is small", "the text file size is greater that the 'max_txt_size' argument", "the binary file size is greater that the 'max_bin_size' argument" +, ); print VS "$file $skip[$c]\n" if ($c); # only print if the file was + skipped } if ($filescan->suspicious) { print VS "$file suspicious file\n"; } }

Update: Thanks to jdporter for pointing out using "c:\\" instead of "c:".
Added readmore tag, fixed some typos and formatting.

2nd Update: LTjake pointed out that I had an error in the return codes of File::Scan's skipped() method. I checked and found out that the HTML documentation built by the ActiveState distribution was saying one thing but the embedded pod was saying something else. I have updated the script to use the correct return codes for that method.


In reply to Perl Virus Scanner by Mr. Muskrat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.