Example #1
0
        public JsonResult Save(Domain domain, AntiVirus av)
        {
            #region Демо режим
            if (Platform.IsDemo)
            {
                return(Json(new Text("Операция недоступна в демо-режиме")));
            }
            #endregion

            if (string.IsNullOrWhiteSpace(av.path))
            {
                return(Json(new Text("Укажите каталог для сканирования")));
            }

            // Поиск шаблона
            var FindDomain = FindAndInclude(coreDB.RequestsFilter_Domains, domain.Id);
            if (FindDomain == null)
            {
                return(Json(new Text("Домен не найден")));
            }

            // Обновляем настройки антивируса
            CommonModels.Update(FindDomain.av, av);

            // Сохраняем базу
            coreDB.SaveChanges();

            //
            Trigger.OnChange((domain.Id, "av"));

            // Отдаем сообщение
            return(Json(new Text("Настройки домена сохранены")));
        }
Example #2
0
        public JsonResult Start(AntiVirus av)
        {
            #region Демо режим
            if (Platform.IsDemo)
            {
                return(Json(new Text("Операция недоступна в демо-режиме")));
            }
            #endregion

            #region Проверяем поля
            if (AntiVirus.IsRun(0))
            {
                return(Json(new Text("Антивирус уже запущен")));
            }

            if (string.IsNullOrWhiteSpace(av.path))
            {
                return(Json(new Text("Укажите каталог для сканирования")));
            }

            if (!System.IO.File.Exists(av.php))
            {
                return(Json(new Text($"Отсутствует исполняемый файл '{av.php}'")));
            }
            #endregion

            #region Создаем команду
            StringBuilder comand = new StringBuilder();
            comand.Append($"--path={av.path} ");

            if (!string.IsNullOrWhiteSpace(av.skip))
            {
                comand.Append($"--skip={av.skip} ");
            }

            if (!string.IsNullOrWhiteSpace(av.scan))
            {
                comand.Append($"--scan={av.scan} ");
            }

            comand.Append($"--mode={(av.mode == 1 ? 1 : 2)} ");
            comand.Append($"--memory={av.memory}M ");
            comand.Append($"--size={av.size}K ");
            comand.Append($"--delay={av.delay} ");
            #endregion

            // Имя отчета
            string report = $"{AntiVirus.name}_{AntiVirus.vers}_{DateTime.Now.ToString("HH-mm_dd-MM-yyy")}{av.path.Replace("/", "_-_")}";

            //
            Trigger.OnStart(("0", report));

            // Запускаем процесс bash
            Bash bash = new Bash();
            bash.Run($"{av.php} {Folders.AV}/ai-bolit.php {comand.ToString()} --progress={Folders.AV}/progress_id-0.json --report={Folders.ReportsAV}/{report}.html >/dev/null 2>/dev/null &");
            bash.Run("sleep 3");

            // Отдаем результат
            return(Json(new TrueOrFalse(true)));
        }
Example #3
0
        public JsonResult Save(AntiVirus av, bool IsAPI = false)
        {
            #region Демо режим
            if (Platform.IsDemo)
            {
                return(Json(new Text("Операция недоступна в демо-режиме")));
            }
            #endregion

            if (string.IsNullOrWhiteSpace(av.path))
            {
                return(Json(new Text("Укажите каталог для сканирования")));
            }

            //Обновляем базу
            jsonDB.AntiVirus = av;
            jsonDB.Save();
            Trigger.OnChange((0, 0));

            // Ответ
            if (IsAPI)
            {
                return(Json(new TrueOrFalse(true)));
            }
            return(Json(new Text("Настройки успешно сохранены")));
        }
 public void DefeatBossFight()
 {
     currentTime       = 0;
     _fighting         = false;
     _spawned          = false;
     _currentAntiVirus = null;
     PlanBossFight();
 }
 void BossFight()
 {
     _timer   += Time.deltaTime;
     _fighting = true;
     if (_timer >= delaySpawn)
     {
         _currentAntiVirus = Instantiate(antiVirus, new Vector3(_player.position.x + 24, 0, 0), Quaternion.identity);
         _currentAntiVirus.transform.SetParent(transform);
         _spawned = true;
     }
 }
Example #6
0
        public JsonResult AntiVirus(int Id, AntiVirus av)
        {
            // Поиск домена
            if (coreDB.RequestsFilter_Domains.Where(i => i.Id == Id).Include(i => i.av).FirstOrDefault() is Domain item)
            {
                // Если не указан каталог для сканирования, то любые настройки запрещены
                if (string.IsNullOrWhiteSpace(item.av.path) && string.IsNullOrWhiteSpace(av.path) || (HttpContext.Request.Query.TryGetValue("path", out _) && string.IsNullOrWhiteSpace(av.path)))
                {
                    return(Json(new Text("Укажите каталог для сканирования")));
                }

                return(Edit(Id, item.av, av));
            }

            return(Json(new Text("Домен не найден")));
        }
Example #7
0
        public JsonResult Stop(int Id = 0)
        {
            #region Демо режим
            if (Platform.IsDemo)
            {
                return(Json(new Text("Операция недоступна в демо-режиме")));
            }
            #endregion

            if (AntiVirus.IsRun(Id))
            {
                Bash   bash = new Bash();
                string pid  = bash.Run($"ps ux | grep \"/av/ai-bolit.php\" | grep \"/progress_id-{Id}.json\" " + " | grep -v \"grep\" | awk {'print $2'} | head -n 1");
                if (!string.IsNullOrWhiteSpace(pid))
                {
                    bash.Run($"kill -9 {pid}");
                }

                System.IO.File.Delete($"{Folders.AV}/progress_id-{Id}.json");
            }

            return(Json(new TrueOrFalse(true)));
        }
Example #8
0
 public JsonResult AntiVirus(AntiVirus av)
 {
     CommonModels.Update(av, jsonDB.AntiVirus, HttpContext, updateType: UpdateType.skip);
     return(new SecurityToAntiVirusController().Save(av, IsAPI: true));
 }
Example #9
0
File: k02.cs Project: ecylmz/nyp
 public static void Uygula(AntiVirus anti)
 {
     // anti: AntiVirus sinifindan kalitlayan herhangi bir sinifin
     // nesnesini temsil edebilecek genel amacli bir referans tutacagi
     // Bu tutacagin tipi calisma aninda belli olacak
     anti.Baslat();
     anti.TaramayaDevam();
     anti.Bitti();
     anti.Sonuc();
 }
        private void SaveItembutton_Click(object sender, EventArgs e)
        {
            if (cmbItem.SelectedItem == null)
            {
                MessageBox.Show("Select Item!!");
            }
            else if (cmbBrandName.SelectedItem.ToString() == "")
            {
                MessageBox.Show("Write Brand");
            }

            else
            {
                Item   d        = null;
                string Itemname = cmbItem.SelectedItem.ToString();
                //MessageBox.Show(Itemname);
                if (Itemname == ProductName.Dongle3G.ToString())
                {
                    d = new Dongle3G();
                }
                else if (Itemname == ProductName.Laptop.ToString())
                {
                    d = new Laptop();
                }
                else if (Itemname == ProductName.HeadPhone.ToString())
                {
                    d = new HeadPhone();
                }
                else if (Itemname == ProductName.OS_License.ToString())
                {
                    d = new OS_License();
                }
                else if (Itemname == ProductName.Antivirus.ToString())
                {
                    d = new AntiVirus();
                }
                else if (Itemname == ProductName.Application_License.ToString())
                {
                    d = new ApplicationLicense();
                }
                try
                {
                    d.Brand        = cmbBrandName.SelectedItem.ToString();
                    d.CreationDate = CreationDateTimePicker.Value;

                    // d.ActualExpiryDate = ActualExpiryTimePicker.Value;


                    d.WarrantyExpiration = WarrantyExpiryTimePicker.Value;
                    d.WarrantyExists     = "True";
                    d.IsAssigned         = "False";
                    itemhelper.Save(d, productFilePath);
                    MessageBox.Show("Item Added");
                    // MessageBox.Show();

                    ItInfrastructureManagementLoad(null, null);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Example #11
0
 void Start()
 {
     av = transform.parent.parent.GetComponent <AntiVirus>();
 }