public static List <ScanModel> ReadScanModel()
        {
            List <ScanModel> scans = new List <ScanModel>();

            string[] Lines = File.ReadAllLines(ScanFileName);

            foreach (string line in Lines)
            {
                string[] data = line.Split("\t");

                ScanModel scanModel = new ScanModel()
                {
                    BluetoothDevices = new List <BluetoothDeviceModel>(),
                    Configuration    = null,
                    WifiDevices      = new List <WifiDeviceModel>(),
                    DeviceId         = int.Parse(data[0]),
                    DateTime         = DateTime.Parse(data[1]),
                    Kinematics       = new KinematicsModel()
                    {
                        Latitude  = double.Parse(data[2]),
                        Longitude = double.Parse(data[3])
                    },
                    GlobalConfigurationId = int.Parse(data[4])
                };

                scans.Add(scanModel);
            }

            return(scans);
        }
예제 #2
0
        /// <summary>
        ///通知设置
        /// </summary>
        /// <param name="aId"></param>
        /// <param name="storeId"></param>
        /// <returns></returns>
        public ActionResult NoticeSetting(int aId = 0, int storeId = 0)
        {
            if (aId <= 0 || storeId <= 0)
            {
                return(Content("参数错误"));
            }
            string   appId    = Senparc.Weixin.Config.SenparcWeixinSetting.WeixinAppId;//公众号appid
            PinStore pinStore = (PinStore)Request.RequestContext.RouteData.Values["pinStore"];

            if (pinStore == null)
            {
                return(Content("信息错误,请重新登录"));
            }
            UserInfoJson userInfo = null;

            if (!string.IsNullOrEmpty(pinStore.wxOpenId))
            {
                userInfo = UserApi.Info(appId, pinStore.wxOpenId, Language.zh_CN);
            }
            string sessonid = new Random().Next(1, 3) + DateTime.Now.ToString("mmssfffff");

            Session["wxbindqrcodekey"] = sessonid;
            if (null == RedisUtil.Get <ScanModel>("wxbindSessionID:" + sessonid))
            {
                ScanModel model = new ScanModel();
                RedisUtil.Set <ScanModel>("wxbindSessionID:" + sessonid, model, TimeSpan.FromDays(1));
            }
            ViewBag.StoreId = storeId;
            return(View(userInfo));
        }
예제 #3
0
        public Task <IActionResult> AssignScan([FromBody] ScanModel model)
        {
            string msg = null;

            return(this.ResultAsync(async() =>
            {
                if (model.IsModelValid())
                {
                    // await AddService(model);

                    IWorker worker = await Workers.Instance.GetWorker(model);     //çncelikle preReq ve Resource initi edilsin. Sonra zaten scan verip tekrar aldığımızda init olsun kaynaklar.

                    using (var q = Queue.Instance.StartTransaction <ScanModel>()) //Kuyruğa ekliyoruz.
                    {
                        q.Enqueue(model);
                        q.Commit();
                    }

                    msg = "The service has been added to the queue";
                    return AssignScanResult.ServiceStarted;
                }

                return AssignScanResult.ModelIsNotValid;

                // ReliableQueue<int> r
            }, msg));
        }
예제 #4
0
        /// <summary>
        /// 扫码监听
        /// </summary>
        /// <returns></returns>
        public ActionResult CheckScan(string wxkey = "", int storeId = 0)
        {
            PinStore pinStore = (PinStore)Request.RequestContext.RouteData.Values["pinStore"];

            if (pinStore == null)
            {
                result.msg = "信息错误,请重新登录" + storeId;
                return(Json(result));
            }
            if (string.IsNullOrEmpty(wxkey))
            {
                result.msg = "wxkey为空";
                return(Json(result));
            }
            ScanModel model = RedisUtil.Get <ScanModel>("wxbindSessionID:" + wxkey);

            if (model == null || model.userInfo == null)
            {
                result.msg = "未扫码";
                return(Json(result));
            }

            result.obj        = new { userInfo = model.userInfo };
            pinStore.wxOpenId = model.userInfo.openid;
            if (PinStoreBLL.SingleModel.Update(pinStore, "wxopenid"))
            {
                result.msg  = "绑定成功";
                result.code = 1;
            }
            else
            {
                result.msg = "绑定失败";
            }
            return(Json(result));
        }
예제 #5
0
        /// <summary>
        ///  Bu fonksiyon Taramaları ekrana yazar.
        ///  This function writes the Scans to screen.
        /// </summary>
        /// <param name="manager">W3afManager Object</param>
        public static void GetScans(NexposeManager manager)
        {
            try
            {
                ScanController = new ScanController();
                ScanModel scans = ScanController.GetScan(manager);
                if (scans.Resources.Length > 0)
                {
                    int counter = 1;
                    foreach (var item in scans.Resources)
                    {
                        Console.WriteLine(counter + ") ID: " + item.ID + "  " + "Tarama Adı: " + item.ScanName);
                        counter += 1;
                    }

                    int selected = ScanView.SelectScan();
                    ScanInformations(selected - 1, scans);
                }
                else
                {
                    Console.WriteLine("Herhangi bir tarama mevcut değildir.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ScanView::GetScans Error Message:" + ex.Message);
            }
        }
        public async Task GoBackWithScanData(ScanModel scanModel)
        {
            await _rootPage.PopAsync();

            var page      = _rootPage.Navigation.NavigationStack.Last();
            var viewModel = page.BindingContext as ViewModelBase;
            await viewModel?.NavigateToAsync(scanModel);
        }
        private List <ScanModel> GetNearbyScans(ScanModel scan)
        {
            var builder = new FilterDefinitionBuilder <ScanModel>();
            var filter  = builder.Near(S => S.Kinematics.Location, scan.Kinematics.Location, minDistance: 0.0, maxDistance: DistanceThreshold);

            var nearby_scans = m_scanCollection.Find(filter).ToList();

            return(nearby_scans);
        }
예제 #8
0
        public async Task SaveScanTest()
        {
            int result = 0;
            await RestClient.Instance.SignIn();

            ScanModel model;

            //model = new ScanModel();
            //model.Asset = "https://www.w3.org/";
            //model.Period = 5000;
            //model.ResourceName = "WebPageHtmlSource";
            //result = await RestClient.Instance.PostAsync<int>("Scan/SaveScan", model);


            //model = new ScanModel();
            //model.Asset = "https://odatv.com/";
            //model.Period = 10000;
            //model.ResourceName = "WebPageScreenshotWorker";
            //result = await RestClient.Instance.PostAsync<int>("Scan/SaveScan", model);


            model              = new ScanModel();
            model.Asset        = "http://toastytech.com/evil/";//"https://demos.telerik.com/aspnet-mvc/tripxpert/";
            model.Type         = ScanModel.ScanType.Once;
            model.ResourceName = "WebPageSpider";
            result             = await RestClient.Instance.PostAsync <int>("Scan/SaveScan", model);


            //model = new ScanModel();
            //model.Asset = "get-process -ComputerName ANKARA";
            //model.SaveType = ScanModel.ScanSaveType.Upsert;
            //model.ResourceName = "TerminalWorker";
            //model.Period = 10000;

            //dynamic dyn = new ExpandoObject();
            //dyn.userName = "******";
            //dyn.password = "******";
            //model.Args = dyn;

            //result = await RestClient.Instance.PostAsync<int>("Scan/SaveScan", model);


            //model = new ScanModel();
            //model.Asset = "Dollars";
            //model.Period = 5000;
            //model.ResourceName = "Dollars";
            ////model.MaxInstance = 1000000;
            //result = await RestClient.Instance.PostAsync<int>("Scan/SaveScan", model);

            //model = new ScanModel();
            //model.Asset = "-PS 127.0.0.1";
            //model.Period = 10000;
            //model.ResourceName = "nmap_windows";
            //result = await RestClient.Instance.PostAsync<int>("Scan/SaveScan", model);

            Assert.AreEqual(result, 1);
        }
예제 #9
0
        private ScanModel getScanModel()
        {
            var       line     = txtLine.Text;
            var       quantity = txtQuantity.Text;
            ScanModel model    = new ScanModel {
                scan = txtInput.Text, shift = comboBoxShift.Text, date = DateTime.Now.ToString("dd/MM/yyyy HH:mm"), code = txtCode.Text, quantity = Convert.ToDecimal(quantity), line = Convert.ToInt32(line), model = txtModel.Text, table = table
            };

            return(model);
        }
예제 #10
0
        internal static async Task <DirectoryInfo> GetResourceDirectory(ScanModel model)
        {
            await _semaphoreSlim.WaitAsync();

            DirectoryInfo resourceFolder = null;

            try
            {
                DirectoryInfo preReqFolder       = null;
                string        resourceFolderPath = null;
                if (!String.IsNullOrEmpty(model.PrerequisiteName))
                {
                    if (!IsScanPrereqExist(model.PrerequisiteName))
                    {
                        ScanPrerequisiteModel prerequisiteModel = await KamajiClient.Instance.Scans.GetScanPrerequisiteBy(model.PrerequisiteName);

                        preReqFolder = await CreateScanPrereqFolder(prerequisiteModel.Name, prerequisiteModel.Resources);
                    }
                    else
                    {
                        preReqFolder = GetExistPrereq(model.PrerequisiteName);
                    }

                    resourceFolderPath = preReqFolder.FullName + "\\" + model.ResourceName;
                }
                else
                {
                    resourceFolderPath = ScanResourcesPath + model.ResourceName;//if it has no prereq, just copy to the root folder.
                }
                if (!Directory.Exists(resourceFolderPath))
                {
                    ScanResourceModel resourceModel = await KamajiClient.Instance.Scans.GetScanResourceBy(model.ResourceName);

                    if (null != resourceModel)
                    {
                        byte[] resources = resourceModel.Resources;
                        resourceFolder = Directory.CreateDirectory(resourceFolderPath);

                        await ExtractZip(resourceFolderPath, resources);
                    }
                }
                else
                {
                    resourceFolder = new DirectoryInfo(resourceFolderPath);
                }
            }
            finally
            {
                _semaphoreSlim.Release();
            }

            return(resourceFolder);
        }
예제 #11
0
        //Burada Scan' e NanoServiceBase' in proportylerini ata.
        protected WorkerServiceBase(Kamaji.Worker.IWorker worker, ScanModel model)
            : base(false, WorkerObserver.Instance)
        {
            this.Model  = model ?? throw new ArgumentNullException(nameof(model));
            this.Worker = worker ?? throw new ArgumentNullException(nameof(worker));

            this.Interval = TimeSpan.FromMilliseconds(model.Period);

            this.NotifyInfoProvider = new Func <NotifyInfo>(() => new NotifyInfo {
                Key = this.GetType().Name, Args = this.Model
            });
        }
예제 #12
0
            public async Task <int> EditScan(ScanModel model)
            {
                try
                {
                    return(await RestClient.Instance.PostAsync <int>($"{KamajiScanActions.EditScan}", model));
                }
                catch (Exception ex)
                {
                    await OfflineData.From(model, nameof(EditScan), ex).SaveAsync();

                    return(-1);
                }
            }
예제 #13
0
        internal async Task <IWorker> GetWorker(ScanModel model)
        {
            if (!_workers.TryGetValue(model.ResourceName, out IWorker worker))
            {
                await _semaphoreSlim.WaitAsync();

                try
                {
                    DirectoryInfo resourceFolder = await ScanResourceManager.GetResourceDirectory(model);

                    Type             IWorkerType = typeof(IWorker);
                    HashSet <string> assemblies  = new HashSet <string>(AppDomain.CurrentDomain.GetAssemblies().Select(i => new AssemblyName(i.FullName).Name));
                    foreach (FileInfo fi in resourceFolder.GetFiles())
                    {
                        if (fi.Extension == ".dll")
                        {
                            string assemblyName = fi.Name.Substring(0, fi.Name.Length - 4);
                            if (!assemblies.Contains(assemblyName))
                            {
                                Assembly asm = Assembly.UnsafeLoadFrom(fi.FullName);//her türlü yüklenmeyen assembly' ler appdomain' e yüklensin diyte break ile çıkmıyoruz
                                if (null == worker)
                                {
                                    foreach (Type type in asm.GetTypes())
                                    {
                                        if (!type.IsAbstract && IWorkerType.IsAssignableFrom(type))
                                        {
                                            worker = (IWorker)Activator.CreateInstance(type);
                                            await worker.SetupEnvironment();

                                            _workers.Add(model.ResourceName, worker);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                finally
                {
                    _semaphoreSlim.Release();
                }

                if (null == worker)
                {
                    throw new InvalidOperationException();
                }
            }

            return(worker);
        }
예제 #14
0
        /// <summary>
        /// 启动频谱分析
        /// </summary>
        private void StartScan()
        {
            numericUpDownSpe.Enabled = false;
            comboBoxRbw.Enabled      = false;

            float centerFreq = (float)numericUpDownSpe.Value;
            int   rbw        = (int)comboBoxRbw.SelectedValue;
            int   vbw        = rbw;

            if (type == 1)
            {
                vbw = (int)comboBoxVbw.SelectedValue;
            }
            object o;

            SpectrumLib.Models.ScanModel ScanModel;
            ScanModel             = new ScanModel();
            ScanModel.StartFreq   = centerFreq - App_Settings.pim.Scanband;
            ScanModel.EndFreq     = centerFreq + App_Settings.pim.Scanband;
            ScanModel.Unit        = CommonDef.EFreqUnit.MHz;
            ScanModel.Att         = 0;
            ScanModel.Rbw         = rbw;
            ScanModel.Vbw         = vbw;
            ScanModel.EnableTimer = true;
            ScanModel.Continued   = true;
            ScanModel.TimeSpan    = App_Settings.spc.SampleSpan;
            if (type == 1)
            {
                ScanModel.FullPoints = true;
            }
            else
            {
                ScanModel.FullPoints = false;
            }

            ScanModel.Deli_averagecount = 6;
            ScanModel.Deli_detector     = "AVERage";
            ScanModel.Deli_ref          = -50;//REF
            ScanModel.Deli_refoffset    = 0;
            ScanModel.Deli_startspe     = 1;
            ScanModel.DeliSpe           = CommonDef.SpectrumType.Deli_SPECTRUM;
            ScanModel.Deli_isSpectrum   = true;

            o           = ScanModel;
            thdAnalysis = new Thread(ISpectrumObj.StartAnalysis);
            thdAnalysis.IsBackground = true;
            thdAnalysis.Start(o);
        }
예제 #15
0
        public void Run()
        {
            IDictionary <int, DeviceModel> _currentDeviceModels = new Dictionary <int, DeviceModel>();
            IList <ScanModel> _scanModels = new List <ScanModel>();

            List <GowallaCheckIn> CheckIns = FileParser.ReadGowallaCheckIns(DATA_SIZE);

            foreach (GowallaCheckIn CheckIn in CheckIns)
            {
                if (!_currentDeviceModels.ContainsKey(CheckIn.Id))
                {
                    DeviceModel model = new DeviceModel()
                    {
                        Id            = CheckIn.Id,
                        Model         = GetFakeModel(),
                        BluetoothName = GetFakeBleName(),
                        MacAddress    = GetFakeMacAddress(),
                        Manufacturer  = GetFakeManufacturer()
                    };

                    _currentDeviceModels.Add(CheckIn.Id, model);
                }

                ScanModel scanModel = new ScanModel()
                {
                    BluetoothDevices      = new List <BluetoothDeviceModel>(),
                    WifiDevices           = new List <WifiDeviceModel>(),
                    GlobalConfigurationId = 1,
                    DateTime   = CheckIn.DateTime,
                    DeviceId   = CheckIn.Id,
                    Kinematics = new KinematicsModel
                    {
                        Latitude  = CheckIn.Latitude,
                        Longitude = CheckIn.Longitude
                    }
                };

                _scanModels.Add(scanModel);
            }

            FileParser.WriteDevices(_currentDeviceModels.Values);

            FileParser.WriteScans(_scanModels);

            Console.WriteLine("Found {0} devices", _currentDeviceModels.Count);
            Console.WriteLine("Found {0} scans", _scanModels.Count);
        }
예제 #16
0
        internal static WorkerServiceBase Create(IWorker worker, ScanModel model)
        {
            switch (model.Type)
            {
            case ScanModel.ScanType.Simple:
                return(new SimpleWorkerService(worker, model));

            case ScanModel.ScanType.NoDelay:
                return(new NoDelayWorkerService(worker, model));

            case ScanModel.ScanType.Once:
                return(new OnceWorkerService(worker, model));

            default:
                throw new NotSupportedException(model.Type.ToString());
            }
        }
예제 #17
0
        // işte şimdi node' a scan leri göndermemiz için bu çift raraflı dublex' i kullanacağız.

        public Task <int> AssignScan(INodeModel node, string prerequisiteName, string scanResourceName, IScanModel scan)
        {
            RestClient client = new RestClient(node.Address);

            ScanModel model = new ScanModel();

            model.CopyPropertiesFrom(scan);

            model.Type             = scan.Type.Cast <int>().Cast <ScanModel.ScanType>();
            model.PrerequisiteName = prerequisiteName;
            model.ResourceName     = scanResourceName;
            //model.State = scan.State.Cast<int>().Cast<ScanModel.ScanState>();
            model.SaveType       = scan.SaveType.Cast <int>().Cast <ScanModel.ScanSaveType>();
            model.Args           = scan.Args;
            model.SaveNullResult = scan.SaveNullResult;

            return(client.PostAsync <int>(NodesActions.AssignScan, model));
        }
예제 #18
0
파일: ScanService.cs 프로젝트: soon14/vzan
        public ResponseMessageText SetNotice(string openId, string key)
        {
            ResponseMessageText response = null;

            try
            {
                ScanModel lcode = RedisUtil.Get <ScanModel>("wxbindSessionID:" + key);
                if (lcode == null)
                {
                    return(response);
                }
                lcode.userInfo = UserApi.Info(appId, openId, Language.zh_CN);
                lcode.isUse    = 0;
                RedisUtil.Set <ScanModel>("wxbindSessionID:" + key, lcode, TimeSpan.FromMinutes(3));
            }
            catch (Exception ex)
            {
                log4net.LogHelper.WriteError(this.GetType(), ex);
            }
            return(response);
        }
예제 #19
0
        internal async Task<int> EditScan(ScanModel model)
        {
            int ret = 0;
            if (model.IsModelValid())
            {
                IScanModel scan = await this.GetScanBy(model.ResourceName, model.Asset);

                scan.Period = model.Period;
                scan.Type = model.Type.Cast<int>().Cast<ScanType>();
                if (model.State.HasValue)
                    scan.State = model.State.Value.Cast<int>().Cast<ScanState>();

                await this.Db.Scans.Edit(scan);

                ret = 1;

                ConsoleObserver.Instance.Notify(nameof(ScanWorks) + "_" + nameof(EditScan), "Scan has been edit.", model);
            }

            return ret;
        }
예제 #20
0
        public MainWindow()
        {
            var m = new ScanModel();

            Application.Current.Properties["Model"]            = m;
            Application.Current.Properties["CamerasManagerVM"] = new CamerasManagerVM(m);
            Application.Current.Properties["ScanManagerVM"]    = new ScanManagerVM(m);
            InitializeComponent();

            controls = new Dictionary <string, UserControl>();

            var item0 = new ItemMenu("Home", new HomeControl(), PackIconKind.ViewDashboard);

            controls.Add("Home", new HomeControl());

            var menuConfig = new List <SubItem>();

            menuConfig.Add(new SubItem("Edit Configurations", new EditConfigControl()));
            menuConfig.Add(new SubItem("Load Configurations", new LoadConfigControl()));
            menuConfig.Add(new SubItem("Save Configurations", new SaveConfigControl()));
            var item1 = new ItemMenu("Configurations", menuConfig, PackIconKind.FileReport);

            var menuRegister = new List <SubItem>();

            menuRegister.Add(new SubItem("View Cameras", new CamerasControl()));
            menuRegister.Add(new SubItem("Reload"));
            var item2 = new ItemMenu("Cameras", menuRegister, PackIconKind.Register);

            var item3 = new ItemMenu("About", new UserControl(), PackIconKind.ViewDashboard);

            controls.Add("About", new AboutControl());

            Menu.Children.Add(new UserControlMenuItem(item0, this));
            Menu.Children.Add(new UserControlMenuItem(item1, this));
            Menu.Children.Add(new UserControlMenuItem(item2, this));
            Menu.Children.Add(new UserControlMenuItem(item3, this));

            this.SwitchPage("Home");
        }
예제 #21
0
        public Task <IActionResult> SaveScan(ScanModel model)
        {
            return(this.ResultAsync(async() =>
            {
                int ret = 0;
                if (model.IsModelValid())
                {
                    IScanModel entity = this.Db.ModelFactory.CreateScanModel();
                    entity.Asset = model.Asset;
                    entity.Type = model.Type.Cast <int>().Cast <ScanType>();
                    entity.CreatedDate = await this.Db.GetDbDateTime();
                    entity.LastModifiedDate = entity.CreatedDate;
                    entity.Enabled = true;
                    entity.Period = model.Period;
                    entity.State = ScanState.NotStarted;
                    entity.MaxErrorLimit = model.MaxErrorLimit;
                    entity.MaxOperationLimit = model.MaxOperationLimit;
                    entity.SaveType = model.SaveType.Cast <int>().Cast <ScanSaveType>();
                    entity.Args = model.Args;
                    entity.SaveNullResult = model.SaveNullResult;
                    entity.MaxInstance = model.MaxInstance;

                    if (!String.IsNullOrEmpty(model.ResourceName))
                    {
                        entity.ScanResourceId = await this.Db.ScanResources.GetScanResourceIdBy(model.ResourceName);
                    }

                    if (!String.IsNullOrEmpty(model.NodeAddress))
                    {
                        entity.SelectedNodeId = await this.Db.Nodes.GetIdBy(model.NodeAddress);
                    }

                    await this.Db.Scans.Save(entity);
                    ret = 1;
                }

                return ret;
            }));
        }
예제 #22
0
        protected override async Task Execute(IObserver observer, CancellationToken cancellationToken)
        {
            ScanModel scan = null;

            using (var tran = Queue.Instance.StartTransaction <ScanModel>())
            {
                scan = tran.Dequeue();
                // observer.Notify("QueueService", "Kuyruktan scan seçildi.", null);

                if (null != scan)                                                          //Yani kuyrukta veri varsa.
                {
                    Kamaji.Worker.IWorker worker = await Workers.Instance.GetWorker(scan); //öncelikle preReq ve Resource initi edilsin. Sonra zaten scan verip tekrar aldığımızda init olsun kaynaklar.

                    observer.Notify("QueueService", "Worker Alındı", null);

                    WorkerServiceBase service = WorkerServiceList.Instance.Find(scan);
                    if (null == service)
                    {
                        service = WorkerServiceFactory.Create(worker, scan);
                        WorkerServiceList.Instance.Add(service);
                        observer.Notify("QueueService", "Servis ilk defa oluşturuldu", null);
                    }
                    if (service.IsRunning)
                    {
                        tran.Enqueue(scan);//running ise tekrardan kuyruğa ekle.
                        observer.Notify("QueueService", "Servis Runnig olduğu için tekrara kuyruğa eklendi. ", null);
                    }
                    else
                    {
                        _ = service.Start();//başlat bir an önceki commit yapabilelim. like Python.
                    }
                }
                //else
                // observer.Notify("QueueService", "Kuyrukta Scan yok.", null);

                tran.Commit();
            }
        }
예제 #23
0
        public Task <IActionResult> StopService(string resourceName, string asset)
        {
            string msg = null;

            return(this.ResultAsync(async() =>
            {
                ScanModel scan = new ScanModel {
                    ResourceName = resourceName, Asset = asset
                };
                WorkerServiceBase worker = WorkerServiceList.Instance.Find(scan);
                if (null != worker)
                {
                    await worker.Stop();
                    return !worker.IsRunning;
                }
                else
                {
                    msg = "The service not found.";
                }

                return false;
            }, msg));
        }
예제 #24
0
 /// <summary>
 /// Bu fonksiyon ilgili tarama ile ilgili bilgileri ekrana yazar.
 /// This function writes to screen related Scan informations.
 /// </summary>
 /// <param name="id">Scan ID</param>
 /// <param name="scan">ScanModel Object</param>
 private static void ScanInformations(int id, ScanModel scan)
 {
     try
     {
         if (id <= scan.Resources.Length)
         {
             Console.WriteLine("\nStart Time: " + scan.Resources[id].StartTime
                               + "\nEnd Time: " + scan.Resources[id].EndTime
                               + "\nStatus: " + scan.Resources[id].Status
                               + "\nVulnerabilities"
                               + "\n\tCriticial: " + scan.Resources[id].Vulnerabilities.Critical.ToString()
                               + "\n\tModerate: " + scan.Resources[id].Vulnerabilities.Moderate.ToString()
                               + "\n\tSevere: " + scan.Resources[id].Vulnerabilities.Severe.ToString());
         }
         else
         {
             Console.WriteLine("Lütfen Geçerli bir değer giriniz.");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("ScanView::ScanInformations Exception: " + ex.Message);
     }
 }
예제 #25
0
 private static string GetKey(ScanModel model) => model.ResourceName + model.Asset;
예제 #26
0
        protected override string User_CommandPcs(string cmd)
        {
            cmd = cmd.ToUpper();

            string returnValue = "+1";

            float value = base.CommandSetAnaylzer(cmd);

            ScanModel scanModel = new ScanModel();

            if (cmd.Contains("CENT"))
            {

            }
            else if (cmd.Contains("SPAN"))
            {

            }
            else if (cmd.Contains("BWID"))
            {

            }
            else if (cmd.Contains("RES"))
            {

            }
            else if (cmd.Contains("VID"))
            {

            }
            else if (cmd.Contains("STAT"))
            {

            }
            else if (cmd.Contains("STOP"))
            {

            }
            else if (cmd.Contains("CALC:X"))
            {

            }
            else if (cmd.Contains("CALC:Y?"))
            {
                EventHandler eh = new EventHandler(delegate {
                    base.ClsSRE();

                    //Operation

                    base.SetSRE();
                });

                eh.BeginInvoke(null,null,null,null);

                returnValue = (-178.5).ToString();
            }

            Console.WriteLine(value.ToString());

            return returnValue;
            //return base.User_CommandPcs(cmd);
        }
예제 #27
0
 internal SimpleWorkerService(IWorker worker, ScanModel model)
     : base(worker, model)
 {
 }
예제 #28
0
 public frmApplyScan(IDBQuery dbQuery)
 {
     InitializeComponent();
     _dbQuery   = dbQuery;
     _scanModel = new ScanModel(_dbQuery);
 }
예제 #29
0
        //public void Clear() => this.dic.Clear();

        public WorkerServiceBase Find(ScanModel model)
        {
            this.dic.TryGetValue(GetKey(model), out WorkerServiceBase service);
            return(service);
        }
예제 #30
0
 public ScanManagerVM(ScanModel model)
 {
     this.Model1 = model;
 }
예제 #31
0
        public IList <ScanModel> Run(DeviceModel device,
                                     IList <WifiDeviceModel> wifiDevices,
                                     IList <BluetoothDeviceModel> bluetoothDevices,
                                     ClusterGraphSettings settings = null)
        {
            if (settings == null)
            {
                settings = s_defaultSettings;
            }

            IList <ScanModel> scanModels = new List <ScanModel>();

            IDictionary <string, int> MACClusterMap = new Dictionary <string, int>();

            /// Go though each device and randomly assign them to a cluster
            foreach (var wifiDevice in wifiDevices)
            {
                int Cluster = 1;
                MACClusterMap.Add(wifiDevice.BSSID, Cluster);
            }

            foreach (var bluetoothDevice in bluetoothDevices)
            {
                int Cluster = 1;
                MACClusterMap.Add(bluetoothDevice.Address, Cluster);
            }


            /// Go Through each day, incrementing in duration, assign the devices that should be found
            /// at that time interval, according to a normal distrubution.
            for (DateTime currentDay = settings.StartDate.Date;
                 currentDay < settings.EndDate.Date;
                 currentDay += TimeSpan.FromDays(1))
            {
                foreach (var period in settings.ActivePeriods)
                {
                    DateTime periodStartTime = currentDay + period.Item1.TimeOfDay;

                    for (DateTime currentDateTime = periodStartTime;
                         currentDateTime < periodStartTime + period.Item2;
                         currentDateTime += settings.ScanningDuration)
                    {
                        ScanModel scanModel = new ScanModel()
                        {
                            DeviceId         = device.Id,
                            DateTime         = currentDateTime,
                            BluetoothDevices = bluetoothDevices.Where(B =>
                                                                      IsInCluster(settings.Clusters[MACClusterMap[B.Address]], currentDateTime)).ToList(),
                            WifiDevices = wifiDevices.Where(W =>
                                                            IsInCluster(settings.Clusters[MACClusterMap[W.BSSID]], currentDateTime)).ToList(),
                            Configuration         = null,
                            GlobalConfigurationId = 1,
                            Kinematics            = new KinematicsModel()
                            {
                            }
                        };

                        scanModels.Add(scanModel);
                    }
                }
            }

            return(scanModels);
        }