I have taken Roger Eriksson's SURBL batch file and using the magic of copy and paste 
have altered it to use the Spam Assassin SURBL. 

This list is much larger than the Spamcop SURBL so your performance may suffer.

Attached renamed exclusion file and the cmd file.
You'll need to rename the sasurbl_filter.txt back to sasurbl_filter.cmd.
You'll also need the wget.exe and the todos.exe from Roger's original SURBL. See:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg17870.html






@echo off
setlocal

rem ----- sasurbl_filter.cmd version 1.2 -----
rem ----- original work by [EMAIL PROTECTED] (April 18, 2004) -----
rem
rem This script downloads the rbldns zone file of the Spam URI Realtime Blocklist,
rem converts it to a body filter, and updates the existing filter file. It also
rem creates a log file (sasurbl_log.txt). The filter is named sasurbl.txt and requires
rem Declude JunkMail Pro 1.78b or later. Domains and ip addresses in the file
rem sasurbl_exclude.txt will be excluded from the filter (by partial match). The script
rem uses wget.exe for the download and todos.exe to convert the Unix line breaks.
rem It should be scheduled to run at least once a day.
rem
rem These settings must be done (SETTINGS section below) before the script is used:
rem v_path: path to this folder
rem v_limit: update limit (max number of entries; blank or 0 if size should be 
unlimited)
rem v_maxweight: filter max weight (blank or 0 if no max weight should be used)
rem              and filter entry weight (defaults to 0 if blank)
rem v_skipweight: filter skip weight (blank or 0 if filter never should be skipped)
rem v_url: download URL for the rbldns zone file
rem v_exclude: test entries in the rbldns zone file (excluded from the filter file)

rem --------------- SETTINGS ---------------

rem --- Settings (see explanation above): ---
set v_path=D:\IMail\Declude\sasurbl
set v_limit=12000
set v_maxweight=12
set v_skipweight=42
set v_url=http://www.surbl.org/sa.surbl.org.rbldns
set v_exclude=test.surbl.org test.sa.surbl.org example.com 2.0.0.127

rem --------------- MAIN SCRIPT ---------------

rem --- Create timestamp: ---
for /f "tokens=*" %%a in ('date /t') do set v_time=%%a
for /f "tokens=*" %%b in ('time /t') do set v_time=%v_time% %%b

rem --- Check settings and change current folder (or exit if path is incorrect): ---
if "%v_limit%"=="" set v_limit=0
if "%v_maxweight%"=="" set v_maxweight=0
if "%v_skipweight%"=="" set v_skipweight=0
if not exist %v_path%\nul (set v_result=path error) & (goto :s_end)
cd /d %v_path%

rem --- Download rbldns zone file (or exit if download failed): ---
if exist sasurbl.rbldns.tmp del sasurbl.rbldns.tmp
if exist wget.exe wget %v_url% -O sasurbl.rbldns.tmp
if not exist sasurbl.rbldns.tmp (set v_result=download error) & (goto :s_end)

rem --- Convert line breaks from LF to CRLF (or exit if conversion failed): ---
if exist todos.exe todos sasurbl.rbldns.tmp
for /f "tokens=*" %%c in ('findstr /r "$" sasurbl.rbldns.tmp') do set v_result=ok
if not "%v_result%"=="ok" (set v_result=conversion error) & (goto :s_end)

rem --- Add rbldns entries to file (skip header, test entries, and trailing 
spaces/tabs): ---
if exist sasurbl.rbldns.entries.tmp del sasurbl.rbldns.entries.tmp
for /f "tokens=1 delims=         " %%d in ('findstr /v /b /i /l "$ @ : ; ! # 
%v_exclude%" sasurbl.rbldns.tmp') do echo %%d>> sasurbl.rbldns.entries.tmp

rem --- Add filter entries to file (unreversed ip addresses and domains): ---
if exist sasurbl.filter.entries.tmp del sasurbl.filter.entries.tmp
for /f "tokens=1-4 delims=." %%e in ('findstr /i /r 
"^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\>" sasurbl.rbldns.entries.tmp') do echo 
%%h.%%g.%%f.%%e>> sasurbl.filter.entries.tmp
for /f "tokens=1" %%i in ('findstr /i /r "^.*\.[A-Z]*\>" sasurbl.rbldns.entries.tmp') 
do echo %%i>> sasurbl.filter.entries.tmp

rem --- Create filter file header: ---
if exist sasurbl.filter.tmp del sasurbl.filter.tmp
echo # SURBL filter updated %v_time%> sasurbl.filter.tmp
echo # Spam URI Realtime Blocklist (%v_url%)>> sasurbl.filter.tmp
if %v_maxweight%%v_skipweight% NEQ 0 echo # This filter will be:>> sasurbl.filter.tmp
if %v_maxweight% NEQ 0 echo # - stopped at first match with the additional weight 
%v_maxweight% >> sasurbl.filter.tmp
if %v_skipweight% NEQ 0 echo # - skipped if the weight %v_skipweight% already has been 
reached>> sasurbl.filter.tmp
if %v_skipweight% NEQ 0 echo # - skipped if the message has not failed any previous 
tests>> sasurbl.filter.tmp
echo.>> sasurbl.filter.tmp
if %v_maxweight% NEQ 0 echo MAXWEIGHT %v_maxweight% >> sasurbl.filter.tmp
if %v_skipweight% NEQ 0 echo SKIPIFWEIGHT %v_skipweight% >> sasurbl.filter.tmp
if %v_skipweight% NEQ 0 echo TESTSFAILED END ISBLANK>> sasurbl.filter.tmp
if %v_maxweight%%v_skipweight% NEQ 0 echo.>> sasurbl.filter.tmp

rem ---
rem --- 
Rem ---  Add END tests here to bypass the filter if needed 
rem ---   
rem ---
echo #>> sasurbl.filter.tmp
echo # FP Bypasses>> sasurbl.filter.tmp
echo #>> sasurbl.filter.tmp
echo #>> sasurbl.filter.tmp
echo MAILFROM END ENDSWITH @prnewswire.com>> sasurbl.filter.tmp
echo MAILFROM END ENDSWITH @sortmonster.com>> sasurbl.filter.tmp
echo REVDNS END ENDSWITH microneil.com>> sasurbl.filter.tmp
echo REVDNS END ENDSWITH ipswitch.com>> sasurbl.filter.tmp
echo MAILFROM END ENDSWITH @declude.com>> sasurbl.filter.tmp
echo REVDNS END ENDSWITH ruralpress.com>> sasurbl.filter.tmp
echo MAILFROM END ENDSWITH @usda.gov>> sasurbl.filter.tmp
echo MAILFROM END ENDSWITH .usda.gov>> sasurbl.filter.tmp
echo MAILFROM END ENDSWITH [EMAIL PROTECTED]>> sasurbl.filter.tmp
echo #>> sasurbl.filter.tmp


rem --- Add entries to filter file (skip entries in exclusion file; exclusion ---
rem --- match pattern can be modified by inserting /x [exact], /b [begins with], ---
rem --- or /e [ends with] before /g:surbl_exlude.txt below): --
if not exist sasurbl_exclude.txt echo.> besasurbl_exclude.txt
for /f %%j in ('findstr /i /r "." sasurbl_exclude.txt') do set v_excludefile=ok
if "%v_excludefile%"=="ok" (
for /f "tokens=*" %%k in ('findstr /v /i /l /g:sasurbl_exclude.txt 
sasurbl.filter.entries.tmp') do echo BODY %v_maxweight% CONTAINS %%k>> 
sasurbl.filter.tmp
) else (
for /f "tokens=*" %%l in (sasurbl.filter.entries.tmp) do echo BODY %v_maxweight% 
CONTAINS %%l>> sasurbl.filter.tmp
)

rem --- Count number of entries (and exit if filter file is empty or limit is 
exceeded): ---
for /f "tokens=1 delims=:" %%m in ('findstr /v /b /i /r "# $ MAXWEIGHT SKIPIFWEIGHT 
TESTSFAILED" sasurbl.filter.tmp ^| findstr /n /l "."') do set v_count=%%m
if "%v_count%"=="" (set v_result=no entries) & (goto :s_end)
if %v_limit% EQU 0 goto :s_replace
if %v_count% GTR %v_limit% (set v_result=limit exceeded) & (goto :s_end)

rem --- Replace existing filter file: ---
:s_replace
if exist sasurbl.old del sasurbl.old
if exist sasurbl.txt rename sasurbl.txt sasurbl.old
rename sasurbl.filter.tmp sasurbl.txt

rem --- Write log entry and clean up: ---
:s_end
if not exist sasurbl_log.txt (echo # SURBL filter log created %v_time%> 
sasurbl_log.txt) & (echo.>> sasurbl_log.txt)
if "%v_result%"=="ok" (echo %v_time% Update successful [%v_count% entries]>> 
sasurbl_log.txt) else (echo %v_time% Update failed [%v_result%]>> sasurbl_log.txt)
if exist sasurbl.rbldns.tmp del sasurbl.rbldns.tmp
if exist sasurbl.rbldns.entries.tmp del sasurbl.rbldns.entries.tmp
if exist sasurbl.filter.entries.tmp del sasurbl.filter.entries.tmp
if exist sasurbl.filter.tmp del sasurbl.filter.tmp
endlocal
127.0.0.
surbl.org

Reply via email to