You are correct that this post is misnamed in using the word 'Protection' - it should have been 'Warning'. There is little you can currently do to prevent a perl script running with sufficient permissions to write to files writing to files! You can detect this though, which was the point.

Detecting damage is a worthwhile endeavour as you can run a script like:

#!/usr/bin/perl -w # clean.pl # this code will remove the viral infection when run in same dir # as a virus if you add the viral code to the data section local $/; $signature = <DATA>; 1 while $signature =~ s/\n$//g; $signature = quotemeta $signature; while (<*>) { next unless $_ =~ m/\.(pl|cgi|pm)$/; open (FILE, "<$_") or die "Unable to check $_ for infection"; $check_if_infected = <FILE>; close FILE; if ($check_if_infected =~ s/^$signature//) { open (CLEAN, ">$_") or die "Unable to disinfect $_"; print CLEAN $check_if_infected; close CLEAN; print "Uninfected $_\n"; } } __DATA__ # Viral code goes here as the viral signature

Whist neither of these pieces of code 'prevent' infection by either your code, mine or any of the others, if you add these two pieces of code together you can detect and repair which is about the best you can hope for without writing some very OS invasive antiviral software. Noton Antivirus slows my dos box by a measured 50-60% for most tasks as it is continually vetting executing threads.


In reply to Re: Re: Virus protection for Perl scripts by tachyon
in thread Virus protection for Perl scripts by tachyon

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.