Example #1
0
        static void Main(string[] args)
        {
            ICAPNameSpace.ICAP icap = new ICAPNameSpace.ICAP("192.168.1.5", 1344, "avscan");

            String[] files = new String[] {
                @"C:\Users\Mads\Downloads\eicar.com.txt"
                , @"C:\Users\Mads\Downloads\eicar.com2.txt"
                , @"C:\Users\Mads\Downloads\eicar.com.txt"
                , @"C:\Users\Mads\Downloads\eicar.com2.txt"
                , @"C:\Users\Mads\Downloads\eicar.com.txt"
                , @"C:\Users\Mads\Downloads\eicar.com2.txt"
                , @"C:\Users\Mads\Downloads\Git-1.8.4-preview20130916.exe"
            };

            foreach (String file in files)
            {
                try
                {
                    Console.Write(file + ": ");
                    bool result = icap.scanFile(file);
                    Console.Write(result + "\n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Could not scan file " + file + ":" + ex);
                }
            }

            System.Threading.Thread.Sleep(1000);
        }
Example #2
0
        static void Main(string[] args)
        {
            ICAPNameSpace.ICAP icap = new ICAPNameSpace.ICAP("192.168.1.5", 1344, "avscan");


            String[] files = new String[] {
                @"C:\Users\Neel\ScanFolder\Test.txt"
            };

            foreach (String file in files)
            {
                try
                {
                    Console.Write(file + ": ");
                    bool result = icap.scanFile(file);
                    Console.Write(result + "\n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Could not scan file " + file + ":" + ex);
                }
            }

            System.Threading.Thread.Sleep(1000);
        }
Example #3
0
        static void Main(string[] args)
        {
            ICAPNameSpace.ICAP icap = new ICAPNameSpace.ICAP("192.168.1.5",1344,"avscan");

            String[] files = new String[]{
                @"C:\Users\Mads\Downloads\eicar.com.txt"
                ,@"C:\Users\Mads\Downloads\eicar.com2.txt"
                ,@"C:\Users\Mads\Downloads\eicar.com.txt"
                ,@"C:\Users\Mads\Downloads\eicar.com2.txt"
                ,@"C:\Users\Mads\Downloads\eicar.com.txt"
                ,@"C:\Users\Mads\Downloads\eicar.com2.txt"
                ,@"C:\Users\Mads\Downloads\Git-1.8.4-preview20130916.exe"
            };

            foreach (String file in files)
            {
                try
                {
                    Console.Write(file + ": ");
                    bool result = icap.scanFile(file);
                    Console.Write(result + "\n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Could not scan file " + file + ":" + ex);
                }
            }

            System.Threading.Thread.Sleep(1000);
        }
Example #4
0
        /// <summary>
        /// Sends a file using the ICAP class in the ICAPNameSpace.
        /// </summary>
        /// <param name="e">The file to send</param>
        private static void sendFile(object e)
        {
            // Get the current file information
            string fullFilePath = (string)e;
            string dir          = Path.GetDirectoryName(fullFilePath) + @"\";
            string file         = Path.GetFileName(fullFilePath);

            logInformation(String.Format("{0,-3}", filesInTransfer.Count) + "/" + String.Format("{0,5}", filesInQueue.Count) + " Scanning file: " + file, 2);

            if (!File.Exists(fullFilePath) || IsFileLocked(fullFilePath))
            {
                logWarning("File is locked or doesn't exist!\nIt will be retried within " + addAllFilesInterval / 1000 / 60 + " minutes.");
            }
            else
            {
                ExecuteResult fileStatus;
                using (ICAPNameSpace.ICAP icap = new ICAPNameSpace.ICAP("192.168.1.5", 1344, "avscan", 1024))
                {
                    fileStatus = timeoutExecute(() => icap.scanFile(fullFilePath), transferTimeout); //FIXME: What if it is just a VERY large file?

                    if (fileStatus == ExecuteResult.CLEAN)
                    {
                        File.Move(dir + file, dir + cleanSubDir + @"\" + file);
                    }
                    else if (fileStatus == ExecuteResult.INFECTED)
                    {
                        File.Move(dir + file, dir + infectedSubDir + @"\" + file);
                    }
                    else if (fileStatus == ExecuteResult.ERROR)
                    {
                        logWarning("Transfer timedout or failed for: " + file);
                    }
                }
            }

            //removes itself from the queue and starts new transfers.
            filesInTransfer.Remove(fullFilePath);
            startTransfers();
            return;
        }
Example #5
0
        /// <summary>
        /// Sends a file using the ICAP class in the ICAPNameSpace.
        /// </summary>
        /// <param name="e">The file to send</param>
        private static void sendFile(object e)
        {
            // Get the current file information
            string fullFilePath = (string)e;
            string dir = Path.GetDirectoryName(fullFilePath) + @"\";
            string file = Path.GetFileName(fullFilePath);

            logInformation(String.Format("{0,-3}", filesInTransfer.Count) + "/" + String.Format("{0,5}", filesInQueue.Count) + " Scanning file: " + file,2);

            if (!File.Exists(fullFilePath) || IsFileLocked(fullFilePath))
            {
                logWarning("File is locked or doesn't exist!\nIt will be retried within " + addAllFilesInterval / 1000 / 60 + " minutes.");
            }
            else
            {
                ExecuteResult fileStatus;
                using (ICAPNameSpace.ICAP icap = new ICAPNameSpace.ICAP("192.168.1.5", 1344, "avscan", 1024))
                {
                    fileStatus = timeoutExecute(() => icap.scanFile(fullFilePath), transferTimeout); //FIXME: What if it is just a VERY large file?

                    if (fileStatus == ExecuteResult.CLEAN)
                    {
                        File.Move(dir + file, dir + cleanSubDir + @"\" + file);
                    }
                    else if (fileStatus == ExecuteResult.INFECTED)
                    {
                        File.Move(dir + file, dir + infectedSubDir + @"\" + file);
                    }
                    else if (fileStatus == ExecuteResult.ERROR)
                    {
                        logWarning("Transfer timedout or failed for: " + file);
                    }
                }
            }

            //removes itself from the queue and starts new transfers.
            filesInTransfer.Remove(fullFilePath);
            startTransfers();
            return;
        }