Jump to content

reporter.pl - it needs a modification


william_

Recommended Posts

Hi,

I use reporter.pl http://www.spamcop.net/reporter.pl.

Does anyone have an amount of perl knowledge so that they can fix my modifications:

#!/usr/bin/perl

open(SENDMAIL, "|/usr/sbin/sendmail -oi -t") || die "Cannot open sendmail output";

print SENDMAIL  <<"ENDENDEND";
From: root\[at]mydomain.com
To: testaddress\[at]mydomain.com
Subject: report spam
MIME-Version: 1.0
Content-Type: message/rfc822

ENDENDEND

# check whether the ISP has sent the reply to a junkmail address, and then just cancel
my $string = "spamcop";  #added
while (defined($_ = <STDIN>)) {
		my $result = index($_, $string); #added
		if ($result == -1){ #added
				close (SENDMAIL); #added
				exit #added
		} #added
		print SENDMAIL;
}
close (SENDMAIL);

The scri_pt above does not work correctly.

if the lines with #added are removed then it works perfectly.

The aim of the crude changes was to modifiy the behaviour of the scri_pt so that it checked for the presence of the word spamcop and then just abort sending that email.

Thinking about it it would be nicer to forward the email to a different location upon finding mention of spamcop.

Link to comment
Share on other sites

You didn't say what doesn't work correctly about the program, but I'm guessing that it doesn't cancel the sending of messages when the spam attachment contains "spamcop" as you want it to do.

I don't think this scri_pt was meant to be used to do what you are trying to do. Once you open the pipe to sendmail and begin sending it stuff, you can't back out -- even if you stop in the middle it is going to try to send what you've already given it.

One could modify this program to collect all the spam data in a local variable and then test it before writing it to sendmail, but I think it might be simpler to run a grep command on your spam before handing it to this scri_pt. If the grep detects the forbidden word, then you can simply decline to send it using this scri_pt. You should be able to do this with a simple shell scri_pt, or perhaps with pipes.

-- rick

Link to comment
Share on other sites

Here is a working modification:

reporterv2.pl

 #!/usr/bin/perl

my $spamcop_email="--------------\[at]spam.spamcop.net";
my $admin_email="anaddress\[at]mydomain.com";

# for testing :
# my $spamcop_email="address1\[at]mydomain.com";
# my $admin_email="address2\[at]mydomain.com";

my $destination="";

my $search_string = 'spamcop';
my $junk_email = "";
while (defined($_ = <STDIN>)) {
		$junk_mail = $junk_mail.$_;
}
my $result = index($junk_mail, $search_string);
if ($result == -1){
		$destination=$spamcop_email;
} else {
		$destination=$admin_email;
}

my $message =<<"ENDENDEND";
From: adminaddress\[at]mydomain.com
To: $destination
Subject: report spam
MIME-Version: 1.0
Content-Type: message/rfc822

$junk_mail

ENDENDEND

open(SENDMAIL, "|/usr/sbin/sendmail -oi -t") || die "Cannot open sendmail output";
print SENDMAIL $message;
close (SENDMAIL);

Link to comment
Share on other sites

  • 3 years later...

I have been using the unmodified scri_pt for several years. Periodically I try to fix an unmentioned problem which occurs quite regularly.

I get

/home/reporter2.pl: line 7: syntax error near unexpected token `SENDMAIL,'
/home/reporter2.pl: line 7: `open(SENDMAIL, "|/usr/lib/sendmail -oi -t") || die "Cannot open sendmail output";'

I don't know perl, only what this and maybe one or two other scripts I use are supposed to do. So when I have a problem I check with you all.

Some say it's a shebang problem, which I've ruled out.

$ which bash
/bin/bash
$ which perl
/bin/perl

My shebang:
#!/bin/perl -w

The -w arg is for debug level doesn't help but appears not to hurt.

Also for good measure,

$ which sendmail
/usr/lib/sendmail

Some say the problem is an embedded CR but I've ruled that out, also. So I guess the double-quotes need to be escaped, could that be right?

Don't wanna break nothing - even if it's already semi-broke.

Thanks for any help!

Link to comment
Share on other sites

  • 1 month later...

So, I'll pose the question again, because I can. Anyone know what specifically causes this complaint from perl?

/home/path/reporter2.pl: line 7: syntax error near unexpected token `SENDMAIL,'
/home/path/reporter2.pl: line 7: `open(SENDMAIL, "|/usr/lib/sendmail -oi -t") || die "Cannot open sendmail output";'
/home/path/reporter2.pl: line 7: syntax error near unexpected token `SENDMAIL,'
/home/path/reporter2.pl: line 7: `open(SENDMAIL, "|/usr/lib/sendmail -oi -t") || die "Cannot open sendmail output";'

Thanks!

Link to comment
Share on other sites

  • 1 month later...

It's hard for me to accept that it's really not possible on my provider's system to successfully call a perl scri_pt that will attach and send procmail-flagged spam to my spamcop reporting address - or that I am the only one with interest in doing so, at this point.

Link to comment
Share on other sites

It's hard for me to accept that ... that I am the only one with interest in doing so, at this point.
...Given the fact that the last post before yours was three-and-a-half years ago and there's a good chance that there aren't all that many folks around here that use perl (I certainly don't), I don't find it hard to accept, at all!
Link to comment
Share on other sites

  • 2 weeks later...

...Given the fact that the last post before yours was three-and-a-half years ago and there's a good chance that there aren't all that many folks around here that use perl (I certainly don't), I don't find it hard to accept, at all!

If the only responses one gets from posting in Spamcop forums are intentionally unhelpful douche-responses, then it is possible that there are in fact people attempting to use the scri_pt but have found no way to find troubleshooting help for it.

I believe it to be best netiquette to revive an older thread than to start a new redundant topic. But of course there will be whining ninnies no matter which approach one takes to request assistance.

Link to comment
Share on other sites

If the only responses one gets from posting in Spamcop forums are intentionally unhelpful douche-responses, then it is possible that there are in fact people attempting to use the scri_pt but have found no way to find troubleshooting help for it.

I believe it to be best netiquette to revive an older thread than to start a new redundant topic. But of course there will be whining ninnies no matter which approach one takes to request assistance.

You've been around a while moulty - long enough to KNOW Steve T is neither whining ninny nor deliberately unhelpful.

Sorry you haven't had a technical response on that unmaintained scri_pt so far. Yes, you've been waiting a while, more than long "enough". Under that circumstance, may I suggest you try a PM or two to any members your searches of previous discussions indicate might be able to help you? They may be infrequent visitors but the e-mail alert generated by the PM should snag their attention, if they've maintained their member accounts "here". Whether or not they respond is, as always, up to them.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...