Here is a filter that you can start with and modify to your liking. I use it for an email script that uses a hash, but the process is not as important as the filter itself.

sub validate_mail { my $self = shift; $self->{hackattempt} = "false"; my @entries = @_; foreach my $i (@entries) { #Catch comment spam/injection attempts!!! #Here is the filter you can modify -- if ($i =~ /(\.\.)|[\\]+|[\<\>]+|[\{\}]+|[\(\)]+|[\|]+|[\[]+|[\]]+/ +gi) { $self->{hackattempt} = "true1"; $self->{hackpattern} = $i; return $self->{hackattempt}; last; } #Remove any hi-jack attempts!!! if ($i =~ /BCC/gi) { $self->{hackattempt} = "true2"; $self->{hackpattern} = $i; return $self->{hackattempt}; last; } next; } return $self->{hackattempt}; }

My scripts use it to trigger an email that gives me the ip address and a sample of the entry (I can look at the sample and determine if it is spam or just a mistake), that code is not shown here. I then use this information to block the ip's using .htaccess -- This stops wasting resources on spammers and helps you to manage the posting process. The BCC portion of this code is aimed at an attempt to inject Blind Carbon Copy email listing into the header of the email envelope.

Goodluck,


In reply to Re: spam problem by Sagacity
in thread spam problem by batmanor

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.