Mail::SpamCannibal::ScriptSupport - A collection of script helpers
use Mail::SpamCannibal::ScriptSupport qw(
DO
doINCLUDE
SerialEntry
TarpitEntry
DNSBL_Entry
id
question
revIP
query
dns_udpsend
dns_udpresp
dns_ans
dns_ns
dns_ptr
rlook_send
rlook_rcv
zone_def
valid127
validIP
zap_one
zap_pair
job_died
dbjob_chk
dbjob_kill
dbjob_recover
unpack_contrib
lookupIP
list2NetAddr
matchNetAddr
BLcheck
checkclct
dumpIPs
BLpreen
mailcheck
abuse_host
is_GENERIC
block4zonedump
);
$rv = DO($file,$nowarnings);
$rv = doINCLUDE($file,$nowarnings);
$packedIPaddr = SerialEntry()
$packedIPaddr = TarpitEntry();
$packedIPaddr = DNSBL_Entry();
$unique = id($seed);
$querybuf = question($name,$type);
$rev = revIP($ip);
$response = query(\$buffer,$timeout);
$socket = dns_udpsend(\$buffer,$timeout);
$response = dns_udpresp($socket,$timeout);
($aptr,$tptr,$auth_zone) = dns_ans(\$buffer);
$nsptr = dns_ns(\$buffer);
$hostname = dns_ptr(\$buffer);
@hosts = dns_ptr(\$buffer);
$socket = rlook_send($IP,$timeout);
$hostname = rlook_rcv($socket,$timeout);
($expire,$error,$dnresp,$timeout)=zone_def($zone,\%dnsbl);
$dotquad = valid127($dotquad);
$dotquad = validIP($dotquad);
$rv = job_died(\%jobstatus,$directory);
$rv = dbjob_chk(\%default_config);
dbjob_kill(\%default_config,$graceperiod);
dbjob_recover(\%default_config);
($respip,$err,$blrsp,$exp,$zon)=unpack_contrib($record);
($which,$text)=lookupIP(\%config,$dotquadIP,$sockpath,$is_network);
$rv=list2NetAddr(\@inlist,\@NAobject);
$rv = matchNetAddr($ip,\@NAobject);
$rv = BLcheck(\%DNSBL,\%default);
$hashref = checkclct($DNSBL);
$rv = dumpIPs($DNSBL, $allipsHASHptr);
$rv = BLpreen(\%DNSBL,\%default);
@err=mailcheck($fh,\%MAILFILTER,\%DNSBL,\%default,\@NAignor,\$spamsource)
$rv=zap_one($tool,$netaddr,$db,$verbose,$comment);
zap_pair($tool,$netaddr,$pri,$sec,$debug,$verbose,$comment);
$rv = is_GENERIC($conf->{GENERIC},@hostnames);
block4zonedump($environment);
$object = new Mail::Spamcannibal::ScriptSupport; $rv = $object->dns2rblz($line); $firstline = $object->rbldns_combined($type); $textline = $object->rbldns_compress($textline); $lastline = $object->rbldnst_done(); $lastline = $object->rbldns_done(); $last_combined = rbldns_address();
Mail::SpamCannibal::ScriptSupport provides a collection of support utilities for sc_BLcheck, sc_BLpreen, sc_mailfilter, sc_admin, sc_session, and cannibal.cgi.
This is a fancy 'do file'. It first checks that the file exists and is readable, then does a 'do file' to pull the variables and subroutines into the current name space.
input: file/path/name
returns: last value in file
or undef on error
prints warning
Similar to above but supports INCLUDE keys.
Defaults:
$expire = '7d' # in seconds
$error = 'Blacklisted by: $zone'
$dnresp = inet_aton('127.0.0.3')
$timeout undef
NOTE: if the respone code found in the config file is not in the 127./8 block or is less than 127.0.0.3, $dnresp will be set to the default value.
input: dot quad ip address returns: input or 127.0.0.3
input: dot quad address returns: dot quad address or undef
input: $tool, # ref to Tools
$netaddr, # IP to remove
$db, # database name
$debug, # mode
$verbose, # report intensity
$comment,
output: 1 on removal, 0 if no record removed
input: $tool, # ref to Tools
$netaddr, # IP to remove
$pri, # database name
$sec, # database name
$debug, # mode
$verbose, # report intensity
$comment,
output: false on success, or
an error message
input: pointer to job status hash,
pid file directory
returns: true if a task is not running
else false
input: pointer to db configuration,
returns: true if all known tasks are running
or exited normally, else returns false
input: pointer to db configuration,
task shutdown grace period
returns: nothing
All DB tasks should be terminated prior to calling this function.
DO NOT call this job for a DB environment that has not been initialized.
usage: if(dbjob_chk(\%default_config) {
dbjob_kill(\%default_config,$graceperiod);
dbjob_recover(\%default_config);
... restart db jobs
}
input: pointer to db configuration, returns: nothing
input: record from 'blcontrib' database
output: netaddr - our response code,
our error message,
netaddr - remote response code,
expire
dnsbl zone
This undoes pack(``a4 x A* x a4 x N x A*'',@_);
input: (localhost)
\%database config,
dotquad IP address,
/path/to/fifo,
0,
(or remote host)
\%database config,
dotquad IP address,
hostname:port,
timeout seconds
returns: which database,
text string
which = 0 for evidence
1 for blcontrib
NOTE: the database config hash is the same as returned by Mail::SpamCannibal::SiteConfig
Text error return messages: message, meaning
invalid IP address, says it all not found in system database, not in tarpit db remote data record missing, found in contrib no text no remote data record found, says it all
Build of NetAddr object structure from a list of IPv4 addresses or address ranges. This object is passed to matchNetAddr to check if a given IP address is contained in the list.
input: array reference pointer
to a list of addresses
i.e. 11.22.33.44
11.22.33.0/24
11.22.33.0/255.255.255.0
11.22.33.20-11.22.33.46
11.22.33.20 - 11.22.33.46
output: Number of objects created
or undef on error
The NAobject array is filled with NetAddr::IP::Lite object references.
Check if an IP address appears in a list of NetAddr objects.
input: dot quad IP address,
reference to NetAddr objects
output: true if match else false
input: config file hash ref,
db config hash ref
output: false on success, or
an error message
See: config/sc_BlackList.conf.sample for a detailed description of each element in the configuration file. See: scripts/sc_BLcheck.pl for usage and configuration information for the db config hash reference.
This routine will return if it catches a SIGTERM. The longest it will wait is the timeout for a DNS query.
input: config file hash ref output: IP collection hash ref
Used by BLcheck
input: config pointer,
pointer to ALLIPS hash
returns: false on success or error message
Used by BLcheck
input: config file hash ref,
db config hash ref
output: false on success, or
an error message
See: config/sc_BlackList.conf.sample for a detailed description of each element in the configuration file. See: scripts/sc_BLpreen.pl for usage and configuration information for the db config hash reference.
This routine will return if it catches a SIGTERM. The longest it will wait is the timeout interval for a DNS query.
input: file handle,
config hash ptr,
dnsbl config hash ptr,
default config hash ptr,
net object ptr,
[optional] spam info array pointer
output: empty array on success,
(verbosity, err msg) on failure
where verbosity is false on success,
1,2,3, etc.... on failure
my %default = (
dbhome => $environment,
dbfile => [$tarpit],
txtfile => [$evidence],
DEBUG => $DEBUG,
LIMIT => $CHAR_SAVE_LIMIT, # characters
PGPLIM => $CHAR_READ_LIMIT,
);
[optional] spam info array pointer $spamip = ['spam source name or ip','spam headers + message'] This array will be filled by mail check if it is present
input: file handle,
config hash ptr,
dnsbl config hash ptr,
$localvars->{dbhome => path to environment},
net object ptr,
output: empty array on success,
(verbosity, err msg) on failure
where verbosity is false on success,
1,2,3, etc.... on failure
fills %$localvars{
SPAM => read buffer so far,
shost => spam host,
to => abuse host
hostIP => ip address
ab2 => [for debug]
};
input: hash pointer to 'GENERIC',
hostname list
returns: true is generic
false is not
input: $environment pointer returns: nothing
input: DNS bind file line returns: rbldns file line or ''
Note: if the DNS file was dumped in standard format, the returned rbldns lines will be in the standard format also. If the DNS file was created in promiscious mode, the rbldns lines will be in the enhanced format provided by:
djbdns-1.05 rbldns patch
found at:
http://www.jms1.net/djbdns/rbldns-patch.html
input: ip4tset line returns: ip4set line
input: type, one of ip4set or ip4tset
returns: dataset statement for ip4set
or undef on error
record(s) for the name server
within this address. This should be the last record after the ip4set is
generated using a starting header generated by rbldns_combined (above).
input: none returns: dataset statement + address
input: none
returns: remainder of last line
in the ip4set data file
input: none
returns: remainder of last line
in the ip4tset data file
NetAddr::IP::Lite
Net::DNS::Codes
Net::DNS::ToolKit
Net::DNS::ToolKit::RR
Mail::SpamCannibal::GoodPrivacy
Mail::SpamCannibal::BDBclient
none by default
DO
doINCLUDE
SerialEntry
TarpitEntry
DNSBL_Entry
id
question
revIP
query
dns_ans
zone_def
valid127
validIP
zap_one
zap_pair
job_died
dbjob_chk
dbjob_kill
dbjob_recover
unpack_contrib
lookupIP
list2NetAddr
matchNetAddr
BLcheck
checkclct
dumpIPs
BLpreen
mailcheck
abuse_host
is_GENERIC
block4zonedump
Copyright 2003 - 2010, Michael Robinton <michael@bizsystems.com>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Michael Robinton <michael@bizsystems.com>
the IPTables::IPv4::DBTarpit manpage, the Net::DNS::Codes manpage, the Net::DNS::ToolKit manpage, the Net::DNS::ToolKit::RR manpage, the Mail::SpamCannibal::DNSBLserver manpage, the Mail::SpamCannibal::BDBaccess manpage