• New SMTPFILTER-SPFEVAL script.

    From winserver.support@winserver.com@1:124/5013 to All on Thu Jan 31 19:12:12 2019
    Date: Sat, 01 Dec 2012 11:42:17 -0400
    From: "WINSERVER SUPPORT" <winserver.support@winserver.com>
    To: all
    Subject: New SMTPFILTER-SPFEVAL script.
    Newsgroups: win.server.program
    Message-ID: <1354380113.32.0@winserver.com>
    X-Mailer: Wildcat! Interactive Net Server v7.0.454.5
    Lines: 126

    The attached script is designed to pass SPF whitelisted domains with Received-SPF: PASS results. The comments in the script should
    explain how to use it and how it
    works.

    Let me know if you plan to use this.

    --
    Hector, Engineering & Technical Support
    Santronics Software, Inc.
    http://www.santronics.com (sales)
    http://www.winserver.com (support)
    http://www.winserver.com/AupInfo (Online AUP Help)
    Office: 305-248-3204

    ////////////////////////////////////////////////////////////////////
    // file : smtpfilter-spfeval.wcc
    // date : 11/29/2012 12:25 pm
    // about : check/accept whitelisted SPF domains with PASS results.
    // author : HLS/SSI
    // usage :
    //
    // Add script name, smtpfilter-spfeval, to the [hooks] section in
    // order you wish, how, the intent of this script it to short-circuit
    // or pre-empt the need to run the more "expensive" smtpfilter-checkwords
    // script. So this spfeval script should run before checkwords is run.
    //
    // Add domains you trust in the file data\SpfEval-Sender-whitelist.txt.
    // Create the file if missing. These are sender domains (SMTP MAIL FROM:
    // command sender return address).

    ////////////////////////////////////////////////////////////////////

    const FILTER_VERSION = "1.0"

    #include <smtpfilterhlp.wch>

    const SpfEvalSenderWhiteList = "wc:\data\SpfEval-Sender-whitelist.txt"
    const SPFHDR = "Received-SPF:"

    //----------------------------------------------------------
    // AddressFound() is a common function found in many
    // smtpfilter apps for checking an email address in a
    // flat text listing file (fn).
    // Return TRUE if match found //----------------------------------------------------------

    Function AddressFound(byval email as string, \
    byval fn as string) as boolean
    AddressFound = FALSE
    dim fv as integer = open fn for input
    if fv > 0 then
    email = sfStripBrackets(email)
    do while not eof(fv)
    dim spec as string
    input #fv, spec
    spec = lcase(trim(spec))
    if (spec <> "") and spec(1) <> ";" then
    if WildcardMatch(email,spec) then
    AddressFound = TRUE
    exit do
    end if
    end if
    loop
    close #fv
    end if
    end Function

    //----------------------------------------------------------
    // MAIN PROGRAM
    //----------------------------------------------------------

    sfInitializeHook(paramstr(1))

    dim args as string = lcase(paramstr(1))
    dim fname as string = GetParamStr(args,"psf") // prespool file
    dim helo as string = GetParamStr(args,"cdn") // EHLO/HELO
    dim from as string = GetParamStr(args,"from") // MAIL FROM
    dim rcpt as string = GetParamStr(args,"rcpt") // RCPT TO

    if (args = "") then
    print "Program: "; Paramstr(0)
    print "Version: "; FILTER_VERSION
    end
    end if


    //
    // Check the data\spfeval-Sender-whitelist.txt file for the sender
    // addresses we are checking for Received-SPF: PASS results.
    //
    // Only do this for the domains that you know for sure have
    // a -ALL policy thus assuring a trusted 100% FAIL or PASS test.
    // WCSAP will reject the -ALL policy FAILs and the current
    // message will never reached SMTPFITLER scripts. However,
    // for a PASS, it should be sysop-controlled who will be passed.
    //

    if not AddressFound(from, SpfEvalSenderWhiteList) then
    END
    end if

    //
    // Whitelisted address found, get the Received-SPF
    // header, if any, and look for PASS results.
    //

    dim spf as string = ""
    sfGetHeaderLine(fname,SPFHDR,spf)
    if lcase(left(spf,4)) = "pass" then
    sflog(lchInfo,"Accepting SPF Pass Message: "+from)
    sfSetGlobalResult(SF_ACCEPT,SF_ENDRULES)
    END
    end if

    // This is interesting. If we had whitelisted the domain
    // in spfeval-whitelist.txt then we expected a Receiver-SPF
    // perhaps. If the above check did not yield a PASS, then
    // what do we do here?

    // Ending with no GlobalResult, continues with next
    // SMTPFILTER script, if any.
    END
    //


    --- Platinum Xpress/Win/WINServer v3.1
    * Origin: Prison Board BBS Mesquite Tx //telnet.RDFIG.NET www. (1:124/5013)