#!/usr/bin/perl -- -*-fundamental-*- use strict; ## Spamthis.pl ## Written by Greg Mullane ## Please see http://www.turnstep.com/Spambot/ ## ## This program generates email of special interest to the viewer ## Use at your own risk. ## The location of your local whois and nslookup commands: ## We used to do an actual whois, but now we will use arin my $whois = "/usr/bin/whois -h whois.arin.net"; my $nslookup = "/usr/sbin/nslookup"; my $DEBUG=0; $|++; sleep(2); ## Make it wait! print "Content-type: text/html\n\n"; print "\n\nMy special friends\n"; print "

Here, spambot! Check these out!

\n"; my $host = $ENV{"REMOTE_HOST"} || ""; my $ip = $ENV{"REMOTE_ADDR"}; print "

Host: ($host)

\n

IP: ($ip)

\n" if $DEBUG; if (!$ip) { print "Sorry, this script could not be run\n"; exit; } my %email; ## Send to dotted decimal of their IP $email{"abuse\@[$ip]"}++; $email{"postmaster\@[$ip]"}++; ## Try to get a domain name if REMOTE_HOST is not set my $domain=""; unless ($host) { my $ns = `$nslookup $ip`; ## May be non-existent print "

Results of $nslookup $ip:

$ns
\n" if $DEBUG; $ns = "Name: foo.biglumber.com"; $ip = "207.228.252.42"; if ($ns =~ /^Name: +.*?([^\.]+\.[^\.]+)$/m) { $domain = $1; $email{"abuse\@$domain"}++; $email{"postmaster\@$domain"}++; } } ## Crude checks for emails in the whois record: my $whois_info = `$whois $ip`; print "

Result of $whois $ip:

\n
$whois_info
\n" if $DEBUG; ## Try and find an abuse email if ($whois_info =~ /abuse\-?email:\s+(.*)/i) { $email{$1}++; } ## Finally, we spit it all out as a pretty list: print " "; exit;