Example #1
0
        public static void SocketThread()
        {
            TcpClient socketForServer;

            while (isRun)
            {
                try
                {
                    Thread.Sleep(500);
                    socketForServer = new TcpClient("localHost", 10);
                }
                catch
                {
                    continue;
                }
                NetworkStream networkStream = socketForServer.GetStream();
                streamWriter = new StreamWriter(networkStream);
                streamReader = new StreamReader(networkStream);
                string message = streamReader.ReadLine();
                MailSlotServerMethods.CheckMessage(message);
                networkStream.Close();
            }
        }
Example #2
0
        public static void Scan(Object obj)
        {
            if (MailSlotServerMethods.ScanStatus == false)
            {
                Console.WriteLine("****************************");
                return;
            }
            Console.WriteLine("Start");
            object[]      data          = obj as object[];
            byte[]        byteArray     = data[0] as byte[];
            List <string> signatureList = data[1] as List <string>;
            string        filePath      = data[2] as string;


            for (int i = 0; i < byteArray.Length; i++)
            {
                if (MailSlotServerMethods.ScanStatus == false)
                {
                    Console.WriteLine("****************************");
                    return;
                }
                //string temp = ByteToString(byteArray, i, 4);

                foreach (string str in signatureList)
                {
                    if (byteArray.Length - i - 1 >= str.Length / 2)
                    {
                        string temp = ByteToString(byteArray, i, str.Length / 2);


                        if (temp.Equals(str))
                        {
                            string type = AntivirusLibrary.DataBaseMethods.DataBaseGetVirusType(str);
                            string date = DateTime.Now.ToString("MM/dd/yyyy");
                            string time = DateTime.Now.ToString("H:mm");
                            AntivirusLibrary.DataBaseMethods.AddNote("SCAN", "PATH,VIRUSTYPE,DATE,TIME", $"'{filePath}','{type}','{date}','{time}'");
                            AntivirusLibrary.DataBaseMethods.AddNote("SCANREPORT", "PATH,VIRUSTYPE,DATE,TIME", $"'{filePath}','{type}','{date}','{time}'");
                            Console.WriteLine("Virus");
                            EndScan++;
                            if (MailSlotServerMethods.FilesForScanCount == EndScan)
                            {
                                EndScan = 0;
                                MailSlotServerMethods.WriteMail("Всего просканированно " + MailSlotServerMethods.FilesForScanCount + "файлов");
                                MailSlotServerMethods.FilesForScanCount = 0;
                                MailSlotServerMethods.ScanStatus        = false;
                                MailSlotServerMethods.WriteMail("Завершено");
                            }
                            MailSlotServerMethods.CreateClientConnection();
                            MailSlotServerMethods.WriteMail("Scaned " + filePath);
                            int b = (int)((double)EndScan / MailSlotServerMethods.FilesForScanCount * 100);
                            MailSlotServerMethods.WriteMail("Выполнено " + b);
                            Console.WriteLine(MailSlotServerMethods.ScanStatus + " SCANSTATUS");
                            Console.WriteLine("End");
                            return; //DataBaseMethods.DataBaseGetVirusType(str); //выход это вирус уиии
                        }
                    }
                }
            }
            EndScan++;
            if (MailSlotServerMethods.FilesForScanCount == EndScan)
            {
                EndScan = 0;
                MailSlotServerMethods.WriteMail("Всего просканированно " + MailSlotServerMethods.FilesForScanCount + "файлов");
                MailSlotServerMethods.FilesForScanCount = 0;
                MailSlotServerMethods.ScanStatus        = false;
                MailSlotServerMethods.WriteMail("Завершено");
            }
            MailSlotServerMethods.CreateClientConnection();
            MailSlotServerMethods.WriteMail("Scaned " + filePath);
            int a = (int)((double)EndScan / MailSlotServerMethods.FilesForScanCount * 100);

            MailSlotServerMethods.WriteMail("Выполнено " + a);
            // MailSlotServerMethods.WriteMail("Выполнено " + EndScan +" M "+ MailSlotServerMethods.FilesForScanCount + "%");
            Console.WriteLine(MailSlotServerMethods.ScanStatus + " SCANSTATUS");
            Console.WriteLine("End");
            return; //это не вирус =(
        }