Pegasus Mail & Mercury

Welcome to the Community for Pegasus Mail and
The Mercury Mail Transport System, the Internet's longest-serving PC e-mail system!
Welcome to Pegasus Mail & Mercury Sign in | Join | Help
Home Blogs Forums Downloads Pegasus Mail Overview Mercury Overview Wiki

Mail filtering based on content of ZIP files (EXE in ZIP)

  •  11-07-2013, 14:08

    • Supur is not online. Last active: 12-09-2018, 12:59 Supur
    • Not Ranked
    • Joined on 05-12-2010
    • Member
    • Points 210

    Mail filtering based on content of ZIP files (EXE in ZIP)

    Hi all,

    I think it would be usefull to be able to filter emails which have EXE file in ZIP attachments. Currently I don't see automatic option to do that within Mercury server so I made a batch file which does the job using Policies:

    Content of file TASKS.MER: (add the last "Task:" line to your TASKS.MER)

    #
    # Mercury/32 policy task list file
    #

    Task: "ZIP-EXE",17,0,"C:\\MERCURY\\ZIP-EXE\\zip-exe.bat ~X ~R "~F" ~Z","","",0,"Admin"


    Content of file ZIP-EXE.BAT: (Add this file to folder C:\MERCURY\ZIP-EXE)

    @echo off

    rem %1 = File to scan
    rem %2 = File to report
    rem %3 = Attachment filename (with quotes)
    rem %4 = Attachment extension

    echo Scan file: "%1" Report: "%2" Att filename: %3 Att ext: "%4"
    echo Scan file: "%1" Report: "%2" Att filename: %3 Att ext: "%4" > %2

    rem Is attachment a compressed file type?
    if %4 == .zip goto test
    if %4 == .arj goto test
    if %4 == .rar goto test
    echo This is not a compressed file: %4                            &rem If not compressed,

    echo This is not a compressed file: %4 >> %2
    exit /B 0                                                                         &rem then safe exit

    :test

    echo File %3 is compressed
    echo File %3 is compressed >> %2

    rem Does it contain an EXECUTABLE?
    findstr /m /l /i ".exe .scr .com .bat .vbs" %1 > nul            &rem Case Insensitive!  
    rem echo ELEVEL: %ERRORLEVEL%                           &rem If found, then ELEVEL = 0!
    rem echo ELEVEL: %ERRORLEVEL% >> %2
    if %ERRORLEVEL% == 0 echo Found an EXECUTABLE in file %3.
    if %ERRORLEVEL% == 0 echo Found an EXECUTABLE in file %3. >> %2
    if %ERRORLEVEL% == 0 exit /B 1
    echo Didn't found an EXECUTABLE in the file.                &rem If nt found,
    echo Didn't found an EXECUTABLE in the file. >> %2
    exit /B 0                                                                       &rem then safe exit



    I hope somebody will find this to be helpful.

     

    Bye,

    Nenad

     

     

View Complete Thread

Contact | Advertise | Host provider: PraktIT | Terms of Use | Privacy Statement
Copyright © 2007-2011 David Harris / Peter Strömblad. | Pegasus Mail Home Page