On-demand scanning for only new files or scan a list from a file

I run a free to use file hosting service and with it are the risks of abuse for malware. In the past I've used ClamAV with a bash script to search for any files that are as old or newer than X minutes, usually about 5 minutes and put the found files listed line by line in a file and ClamAV will scan those files only. Put on a Cron for every 5 minutes to run. ClamAV's detection is pathetic though and has not caught most of the stuff it has needed to find. So switching over to Sophos Linux, it has done a great job already detecting multiple files of the uploaded files folder that ClamAV had already missed in the past. It takes just 3 1/2 minutes for it to scan through 3500+ files and archives totaling 17 gigs. I have it set to scan the whole directory every 5 minutes. This takes a while, even if it is under 3 1/2 mins. Ideally I want Sophos to only scan new files so it can be set to run every minute, or every 5 minutes, whether that be from it's command line or via it reading a file list. This way newly uploaded malware is taken care of as fast as possible for the security of the end users.  Here is the script file I use for Sophos already: #! /bin/bash
PATH=/home/user:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if [[ $UID -ne 0 ]]; then sudo "$0"; exit 0; fi
# Directories to scan
scan_dir="/home/user/directory/files/"
# Virus relocation folder
virus_vault="/home/user/directory/viruses/files/"
# Create new log folder if it doesn't exist
mkdir -p /home/user/directory/viruses/logs/$(date +%Y-%m)
# Location of log file
tmp_log_file="/home/user/directory/viruses/logs/$(date +%Y-%m)/sophos-scan-$(date +%Y-%m-%d)-tmp.log"
log_file="/home/user/directory/viruses/logs/$(date +%Y-%m)/sophos-scan-$(date +%Y-%m-%d).log"
# Scan files and remove (--remove) infected
savscan $scan_dir -nc -ss -archive -all -suspicious -pua --quarantine -move=$virus_vault -p=$tmp_log_file
# Format log
echo " " >> "$log_file"
echo " " >> "$log_file"
echo "-----------------" >> "$log_file"
echo " " >> "$log_file"
date >> "$log_file"
echo " " >> "$log_file"
echo "-----------------" >> "$log_file"
echo " " >> "$log_file"
# move consolidate log to daily file
cat $tmp_log_file >> $log_file
# remove temporary file
rm -f $tmp_log_file
# make sure virus files are right owners
chown -R user:user $virus_vault Here is what it's based off, what I did for ClamAV to find new files and scan those only. #! /bin/bash
if [[ $UID -ne 0 ]]; then sudo "$0"; exit 0; fi
# Directories to scan
scan_dir="/home/user/example.com/files"
# Virus relocation folder
virus_vault="/home/user/example.com/viruses/files"
# Temporary file
list_file=$(mktemp -t clamscan.XXXXXX) || exit 1
# Create new log folder if it doesn't exist
mkdir -p /home/user/example.com/viruses/logs/$(date +%Y-%m)
# Location of log file
log_file="/home/user/example.com/viruses/logs/$(date +%Y-%m)/clamscan-$(date +%Y-%m-%d).log"
# Make list of new files
if [ -f "$log_file" ]
then
# use newer files then logfile
find "$scan_dir" -type f -cnewer "$log_file" -fprint "$list_file"
else
# scan last 5 minutes
find "$scan_dir" -type f -cmin -5 -fprint "$list_file"
fi
if [ -s "$list_file" ]
then
# Scan files and remove (--remove) infected
clamscan -f "$list_file" --move=/"$virus_vault" >> "$log_file"
rm -f "$list_file"
else
# remove the empty file, contains no info
rm -f "$list_file"
fi
exit 

Quick comment...
Sophos has 'decision caching' to speed up files that haven't changed since the last scan, while also allowing files to be re-checked against the latest threat definitions.

Similar Messages

  • On-demand scanning for only news files or scan a list from a file

    I run a free to use file hosting service and with it are the risks of abuse for malware. In the past I've used ClamAV with a bash script to search for any files that are as old or newer than X minutes, usually about 5 minutes and put the found files listed line by line in a file and ClamAV will scan those files only. Put on a Cron for every 5 minutes to run. ClamAV's detection is pathetic though and has not caught most of the stuff it has needed to find. So switching over to Sophos Linux, it has done a great job already detecting multiple files of the uploaded files folder that ClamAV had already missed in the past. It takes just 3 1/2 minutes for it to scan through 3500+ files and archives totaling 17 gigs. I have it set to scan the whole directory every 5 minutes. This takes a while, even if it is under 3 1/2 mins. Ideally I want Sophos to only scan new files so it can be set to run every minute, or every 5 minutes, whether that be from it's command line or via it reading a file list. This way newly uploaded malware is taken care of as fast as possible for the security of the end users.  Here is the script file I use for Sophos already: #! /bin/bash
    PATH=/home/user:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    if [[ $UID -ne 0 ]]; then sudo "$0"; exit 0; fi
    # Directories to scan
    scan_dir="/home/user/directory/files/"
    # Virus relocation folder
    virus_vault="/home/user/directory/viruses/files/"
    # Create new log folder if it doesn't exist
    mkdir -p /home/user/directory/viruses/logs/$(date +%Y-%m)
    # Location of log file
    tmp_log_file="/home/user/directory/viruses/logs/$(date +%Y-%m)/sophos-scan-$(date +%Y-%m-%d)-tmp.log"
    log_file="/home/user/directory/viruses/logs/$(date +%Y-%m)/sophos-scan-$(date +%Y-%m-%d).log"
    # Scan files and remove (--remove) infected
    savscan $scan_dir -nc -ss -archive -all -suspicious -pua --quarantine -move=$virus_vault -p=$tmp_log_file
    # Format log
    echo " " >> "$log_file"
    echo " " >> "$log_file"
    echo "-----------------" >> "$log_file"
    echo " " >> "$log_file"
    date >> "$log_file"
    echo " " >> "$log_file"
    echo "-----------------" >> "$log_file"
    echo " " >> "$log_file"
    # move consolidate log to daily file
    cat $tmp_log_file >> $log_file
    # remove temporary file
    rm -f $tmp_log_file
    # make sure virus files are right owners
    chown -R user:user $virus_vault Here is what it's based off, what I did for ClamAV to find new files and scan those only. #! /bin/bash
    if [[ $UID -ne 0 ]]; then sudo "$0"; exit 0; fi
    # Directories to scan
    scan_dir="/home/user/example.com/files"
    # Virus relocation folder
    virus_vault="/home/user/example.com/viruses/files"
    # Temporary file
    list_file=$(mktemp -t clamscan.XXXXXX) || exit 1
    # Create new log folder if it doesn't exist
    mkdir -p /home/user/example.com/viruses/logs/$(date +%Y-%m)
    # Location of log file
    log_file="/home/user/example.com/viruses/logs/$(date +%Y-%m)/clamscan-$(date +%Y-%m-%d).log"
    # Make list of new files
    if [ -f "$log_file" ]
    then
    # use newer files then logfile
    find "$scan_dir" -type f -cnewer "$log_file" -fprint "$list_file"
    else
    # scan last 5 minutes
    find "$scan_dir" -type f -cmin -5 -fprint "$list_file"
    fi
    if [ -s "$list_file" ]
    then
    # Scan files and remove (--remove) infected
    clamscan -f "$list_file" --move=/"$virus_vault" >> "$log_file"
    rm -f "$list_file"
    else
    # remove the empty file, contains no info
    rm -f "$list_file"
    fi
    exit 

    Quick comment...
    Sophos has 'decision caching' to speed up files that haven't changed since the last scan, while also allowing files to be re-checked against the latest threat definitions.

  • Junked old macbook for a new one. changed apple id password from a different mac. i want to login and it asks for name and password. no matter what i type i cant seem to login. any way help?

    junked old macbook for a new one. changed apple id password from a different mac. i want to login and it asks for name and password. no matter what i type i cant seem to login. why cant i just enter my apple id and password. or is there a way to change whatever name and password are on the new one from another mac so i can login. anything helps...thanks

    Just open System Preferences>Users & Groups and unlock the preference pane with your root password.
    Set the New Account to be an Administrator and fill in the rest of the data and then click "Create User".
    I would suggest using this user to be YOU with admin capabilities. I wouldn't use the root user - too much damage could occur if you're not sure what you're doing. If you have files, etc., that you want to move to this account, simply but them in the Shared folder - or if you 'rescued' some old files and the like from your 'trashed' MBP, you can put them in your NEW admin account folders.
    Hope I've explained myself well - call back with any questions!
    Clinton

  • I have been using my Apple ID in India and recently i moved to Spain and now i can not see my indian apps.it says my apple ID is valid for only spanish store.how to download apps from Indian store being in Spain.

    I have been using my Apple ID in India and recently i moved to Spain and now i can not see my indian apps.it says my apple ID is valid for only spanish store.how to download apps from Indian store being in Spain.

    Did you try to change the location  in Settings/iTunes & AppStore/AppleID -> view Apple ID, log in ->Country/Region -> India?

  • File reporter questions - pulling data from db / files for o

    I've been trying to find a way to query or pull file and path info for volumes from the file reporter databases without needing to give access to the file reporter app. I have an outside group that I need to provide the file structure to, but don't need to give all of the info to, and need to provide it in the form of a text file. I could script this out, but if file reporter does this also, I don't see the point in duplicating the data out there.
    In reviewing the content of the sqlite databases it doesn't appear that the actual file system info. I see a lot of references to what I think may be files in the directory structure that the databases are located in. looking over the logs and debug files in these directories they look like they may contain what I am looking for, but I'm not sure what can be used to open or extract the data from them. Does anyone know what I would use to open or extract the zcf files located in them?
    so I've made a few attempts at trying to figure out the format these are in, but know they are not sqlite data... not zip or gzip... but definitely some sort of data file.

    On 10/8/2012 4:46 PM, rbgnr111 wrote:
    >
    > I've been trying to find a way to query or pull file and path info for
    > volumes from the file reporter databases without needing to give access
    > to the file reporter app. I have an outside group that I need to provide
    > the file structure to, but don't need to give all of the info to, and
    > need to provide it in the form of a text file. I could script this out,
    > but if file reporter does this also, I don't see the point in
    > duplicating the data out there.
    >
    > In reviewing the content of the sqlite databases it doesn't appear that
    > the actual file system info. I see a lot of references to what I think
    > may be files in the directory structure that the databases are located
    > in. looking over the logs and debug files in these directories they look
    > like they may contain what I am looking for, but I'm not sure what can
    > be used to open or extract the data from them. Does anyone know what I
    > would use to open or extract the zcf files located in them?
    > so I've made a few attempts at trying to figure out the format these
    > are in, but know they are not sqlite data... not zip or gzip... but
    > definitely some sort of data file.
    >
    >
    rbgnr111,
    It sounds like you might be better off exporting a report which suits
    your needs as a CSV file (which can be done from within File Reporter)
    and stripping out unnecessary 'columns' of metadata after the fact. This
    would be a great deal simpler than extracting the data from the database.
    - NFMS Support Team

  • HT4437 how may I add files to time capsule apart from backup files?

    how may I add files to time capsule apart from backup files?
    I'm able to perform backup (time machine). May I add pictures, texts, movies...?
    Thanks

    not sure if this is a spc. appletv question or if you posted it in the wrong forum but there is no way
    for an appletv to access files directly from an time capsule it can only! access a shared lib from itunes from a computer running and running itunes

  • How is it posible to get the File name, size and type from a File out the H

    How is it posible to get the File name, size and type from a File out the HttpServletRequest. I want to upload a File from a client and save it on a server with the client name. I want to conrole before saving the name, type and size of the file.How is it posible to get the File name, size and type from a File out the HttpServletRequest.
    form JSP
    <form name="form" method="post" action="procesuploading.jsp" ENCTYPE="multipart/form-data">
    File: <input type="file" name="filename"/
    Path: <input type="text" readonly="" name="path" value="c:"/
    Saveas: <input type="text" name="saveas"/>
    <input name="submit" type="submit" value="Upload" />
    </form>
    proces JSP
    <%@ page language="java" %>
    <%@ page import="java.util.*" %>
    <%@ page import="FileUploadBean" %>
    <jsp:useBean id="TheBean" scope="page" class="FileUploadBean" />
    <%
    TheBean.doUpload(request);
    %>
    BEAN
    import java.io.*;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletInputStream;
    public class FileUploadBean {
    public void doUpload(HttpServletRequest request) throws IOException
              String melding = "";
              String filename = request.getParameter("saveas");
              String path = request.getParameter("path");
              PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("test.java")));
              ServletInputStream in = request.getInputStream();
              int i = in.read();
              System.out.println("filename:"+filename);
              System.out.println("path:"+path);
              while (i != -1)
                   pw.print((char) i);
                   i = in.read();
              pw.close();
    }

    Thanks it works great.
    Here an excample from my code
    import org.apache.commons.fileupload.*;
    public class FileUploadBean extends Object implements java.io.Serializable{
    String foutmelding = "geen";
    String path;
    String filename;
    public boolean doUpload(HttpServletRequest request) throws IOException
         try
         // Create a new file upload handler
         FileUpload upload = new FileUpload();
         // Set upload parameters
         upload.setSizeMax(100000);
         upload.setSizeThreshold(100000000);
         upload.setRepositoryPath("/");
         // Parse the request
         List items = upload.parseRequest(request);
         // Process the uploaded fields
         Iterator iter = items.iterator();
         while (iter.hasNext())
         FileItem item = (FileItem) iter.next();
              if (item.isFormField())
                   String stringitem = item.getString();
         else
              String filename = "";
                   int temp = item.getName().lastIndexOf("\\");
                   filename = item.getName().substring(temp,item.getName().length());
                   File bestand = new File(path+filename);
                   if(item.getSize() > SizeMax && SizeMax != -1){foutmelding = "bestand is te groot.";return false;}
                   if(bestand.exists()){foutmelding ="bestand bestaat al";return false;}
                   FileOutputStream fOut = new FileOutputStream(bestand);     
                   BufferedOutputStream bOut = new BufferedOutputStream(fOut);
                   int bytesRead =0;
                   byte[] data = item.get();
                   bOut.write(data, 0 , data.length);     
                   bOut.close();
         catch(Exception e)
              System.out.println("er is een foutontstaan bij het opslaan de een bestand "+e);
              foutmelding = "Bestand opsturen is fout gegaan";
         return true;
         }

  • Choose File Form Data Create Spreasheet From Data Files

    I am following the tutorial for LC 8 and when I get to the topic titled "Collecting the data in a spreadsheet" it says to "Choose File > Form Data > Create Spreadsheet From Data Files".
    However, when I try to follow that path I do not see a "Form Data > Create Spreadsheet From Data Files" menu option.
    What am I not doing properly? How do I accomplish this task?
    Thanks!

    Thank you so much Paul. I have been trying all day to locate the method by which I could create a spreadsheet using the pdf submit route. I suppose the tutorial in CS4 should have been changed to reflect the changed explanations, but I guess that would be difficult to do. Anyway it worked and I can now do the analysis I need from my customers (lots of pupils!).
    Best wishes,
    Kevin Palmer

  • I have file with 500 pages created from AutoCad file. In all pages, I have different document numbers.The file is not editable in pdf. How to change all the document numbers using "Comment" feature? Any alternate method?  alternate method? I have Adobe Ac

    I have pdf file with 500 pages created from AutoCad file. In all pages, I have different document numbers.The file is not editable in pdf. How to change all the document numbers using "Comment" feature? Any alternate method?  alternate method? I have Adobe Acrobat X Pro and Windows -7 platform.

    Yes, I just want to cover up all the pages for those particular area of document numbers.
    Nothing sensitive about it. I just want to show the correct document numbers on all pages in print out.
    So, I wanted to cover up by comments, but commenting on each page will be difficult. So, I wanted to comment the same on all pages.

  • TS4036 what if i only want to restore my contact list from backup

    what if i only want to restore my contact list from backup

    Welcome to the Apple community.
    Firstly, you cannot selectively restore content from your iCloud backup. Secondly, your contacts are not part of your iCloud backup.

  • When I select files to archive, they move from my file folder, but then I go to the archive folder and it says Empty? Where are those files?

    When I select files to archive, they move from my file folder, but then I go to the archive folder and it says Empty? Where are those files?

    Your account names are probably different on the two Macs. If you know the UNIX command line, open a terminal window and run:
    $ id 
    You should see a line that starts with something like this:
    uid=501(your_user_id_here)
    now check the owner of the folder you copied over:
    $ ls -ld Music
    drwx------+ 8 some_user_id_here  staff  272 May 14 16:08 Music
    Do the IDs match? If not, you could change the ownership. Say your id is "johnsmith"
    $ chown -R johnsmith Music
    Now try and access it with iTunes.

  • Instead of pointing to local files, re-matched library lists all local files as duplicates

    I've got a mess. I moved my matched local music files from my internal drive to a larger external drive. I deleted the iTunes folder on the internal drive, created a new library by changing the location of my music library in iTunes preferences and adding all of the files on the external drive.
    When I turned match back on, my cloud-based matched files no longer pointed to my local versions. Instead, match listed everything as a duplicate -- a copy in the cloud and a local copy even though the two copies are exactly the same, previously matched files.
    I've added files to my cloud library from numerous computers -- so my cloud library is the most complete --  and I was in the process of creating one local, consolidated library on my new external drive by downloading those files from match. There has to be a way to re-sync both local and match libraries with everything matched as it previously was withouth having to either delete and re-upload or delete and re-download.
    Any tips, instruction or help will be greatly apprieciated.

    You didn't move the library in the right way. In the future, use this Apple KB article to move an iTunes Media folder: http://support.apple.com/kb/ht1449
    To try to clean this up is going to take some work on your part but it isn't impossible. Start off with one album or artist at a time and delete them from the cloud. Then you should be able to select the corrosponding locally stored tracks, right click them, and choose "add to iCloud." This should re-initiate a scan on those tracks and add them to the cloud.

  • How to read a file and pickup some information from  a file

    Hai all,
    I wrote a beloe program to read a file and write it into another file
    import java.io.*;
    public class Rdata {
    /** Creates a new instance of Rdata */
    public Rdata() {
    public static void main(String a[])throws Exception
    FileReader fr=new FileReader("c:\\java\\attach\\attach2\\resume1.doc");
    FileWriter fw=new FileWriter("C:\\java\\attach\\abc2.doc");
    char ch;
    int i;
    while((i=fr.read())!=-1)
    ch=(char)i;
    fw.write(ch);
    fw.close();
    This program reads the content from resume1.doc and write it into abc2.doc . But in my project I want to read the resume1.doc and and write only peace of information like "keyskills are java,jsp,javamail"
    I mean how to read the entaire file and how to write into another file whisc i require
    Thanks&regards
    radhs

    http://java.sun.com/docs/books/tutorial/essential/io/

  • Setting up the File Name of email Attachment from Received File Name

    Hello All,
    I have to send the Received File in attachment to an Email if there is any exception. Here I can attach the file, but I cannot set the file name of attachment as the Received File Name. Is there anyway of doing this without using custom pipeline component.
    Here I am using the Orchestration and SMTP Adapter.Any help is greatly appreciated.
    Thanks

    It might work if you use a custom pipeline component on your send port and in the Execute method populate the MIME.FileName property of the body part.
    Something like:
    public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
    string filename = inmsg.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");
    inmsg.BodyPart.PartProperties.Write( "FileName", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", "filename);
    return inmsg;
    You can take reference from similar post here
    SMTP - Setting attachment filename
    Anther good article with MIME is here
    Setting attachment filename with the SMTP Adapter
    For MIME case your SMTP message construct statement would be like below
    multipartMessage.MessagePart_1= InMSG;
    multipartMessage.MessagePart_2="This is message part2 as a string";
    multipartMessage(SMTP.Subject) ="Email From Dynamic Port";
    multipartMessage(SMTP.From) ="[email protected]";
    multipartMessage(SMTP.SMTPHost) ="yoursmypserver.com";
    multipartMessage.MessagePart_2(MIME.FileName) = "Attachment_Name";
    multipartMessage(SMTP.SMTPAuthenticate) =0;
    Thanks
    Abhishek

  • File-to-file scenario: no mapping, filename from sender file

    Hi all,
    file-to-file without mapping.
    we want to use XI to transport just files from XI file directory to another ftp-server (+ archiving on xi file directory)
    we configered an sender file adapter that picks the file up, but
    we have problems configuring the receiver adapter in that way that the filename or the original file is used
    Is that possible? with which parameter settings
    filename is not content of the XI message content so "message:FileName" doenst work
    Thank you very much
    regards
    Hans

    Hi Hans,
    Check this link:
    How to send any data (even binary) through XI, without using the Integration Repository
    OR
    Copy a file with same filename using XI
    Sachin
    Edited by: Sachin Dhingra on Nov 7, 2008 8:19 PM

Maybe you are looking for

  • Authorization Error  While  Invoking BPEL Process Via RMI

    Hi All, I have been trying to invoke BPEL Process via RMI client. I use the following piece of code for BPEL Process Invocation... public class RMIClient { public RMIClient() { public static void main(String[] args){ Hashtable jndi = new Hashtable ()

  • How to simulate a mobile robot using labview

    Hello, Is it possible to simulate the movement of a mobile robot using labview? I mean, is it possible to have a graphics window to show these movements? Thanks

  • Error data pump import: Worker unexpected fatal error in KUPW$WORKER.MAIN

    Hello. I try to import dump impdp DIRECTORY=data_pump_dir DUMPFILE=04-2013.dmp TRANSFORM=OID:n LOGFILE=04-2013.dmp.log (user - system (tried with sys) , (also with parallel=1 (or 2, or 8))and have following error: Import: Release 11.2.0.1.0 - Product

  • No access wls_spaces

    Hi. I have installed oracle webcenter 11g I have created the domain and started the server without any errors. And wls_services without any problems but I dont can access to localhost:8888/webcnenter. The wls_spaces in a weblogic console finally is r

  • How possibly dust going under the back glass of the phone?

    I see some specs of dust under the back glass of my iPhone4S. How possibly is that? It seems that the glass is perfectly attached to the back, how could they go there? Is there any solution for me to swap them out or how to prevent more dust going un