Пример #1
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);
            }
        }
Пример #2
0
    public void OnClickButtonScan()
    {
        // check if mothod starts or stops scan
        bool isScanning = ScanController.IsScanning;

                #pragma warning disable CS0162
        if (isLogging)
        {
            Debug.Log(TAG + "onClickButtonScan " + (isScanning ? "stop scanning" : "start scanning"));
        }
                #pragma warning restore CS0162
        if (ScanController.IsInitialized)
        {
            if (isScanning)
            {
                ScanController.StopScan();
            }
            else
            {
                ScanController.StartScan();
            }
        }
        else
        {
            Debug.LogError(TAG + "onClickButtonScan, ScanController is NOT initialized. Did you forget to add ScanController object in the scene?");
        }
    }
Пример #3
0
        //Flag to signal interface switching
        //private bool switching = false;
        public FormMain(ScanController scanner)
        {
            // This is for testing localization...
            String culture = String.Empty;

            //culture = "es-es";
            //culture = "zh-TW";
            //culture = "ja-JP";
            //culture = "de-DE";
            //culture = "sv-SE";
            //culture = "ru-RU";

            if (!string.IsNullOrEmpty(culture))
            {
                CultureInfo ci = new CultureInfo(culture);
                // set culture for formatting
                Thread.CurrentThread.CurrentCulture = ci;
                // set culture for resources
                Thread.CurrentThread.CurrentUICulture = ci;
            }

            InitializeComponent();
            var filtersViewController = new FiltersViewController <AccessPoint>(filtersView);

            _scanner = scanner;
            _scanner.InitializeCache(filtersViewController);
            ToolStripManager.Renderer = new GrayToolStripRenderer();

            SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
        }
        public void Initialize(ref ScanController scanner)
        {
            _scanner = scanner;
            if (_scanner == null)
            {
                return;
            }

            //NetworkController.Instance.Initialize();

            // We have to manually check for new interfaces in Windows XP
            if (Utilities.IsXp())
            {
                _myTimer = new System.Timers.Timer {
                    Interval = 5000.0, Enabled = true
                };
                _myTimer.Elapsed += MyTimer_Elapsed;
            }
            else
            {
                InterfaceManager.Instance.InterfaceAdded   += WlanClient_InterfaceAddedEvent;
                InterfaceManager.Instance.InterfaceRemoved += WlanClient_InterfaceRemoveEvent;
            }

            UpdateInterfaceList();

            //If we are not on XP and only have 1 interface, start scanning
            if (!Utilities.IsXp() && InterfaceManager.Instance.Interfaces.Length == 1)
            {
                StartScan();
            }
        }
Пример #5
0
        public static void Scan(ScanLayer scanLayer)
        {
            ScanController controller    = new ScanController(scanLayer);
            var            navController = new PopoverNavigationController(controller)
            {
                ModalPresentationStyle = UIModalPresentationStyle.FormSheet
            };

            navController.SetCloseButton(controller);

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                if (!TouchFactory.TheApp.Style.HeaderColor.IsDefaultColor)
                {
                    navController.NavigationBar.BarTintColor = TouchFactory.TheApp.Style.HeaderColor.ToUIColor();
                }

                if (!TouchFactory.TheApp.Style.HeaderTextColor.IsDefaultColor)
                {
                    navController.NavigationBar.TintColor           = TouchFactory.TheApp.Style.HeaderTextColor.ToUIColor();
                    navController.NavigationBar.TitleTextAttributes = new UIStringAttributes()
                    {
                        ForegroundColor = TouchFactory.TheApp.Style.HeaderTextColor.ToUIColor()
                    };
                }
            }
            else
            {
                navController.NavigationBar.TintColor = TouchFactory.TheApp.Style.HeaderColor.ToUIColor();
            }

            ModalManager.EnqueueModalTransition(TouchFactory.Instance.TopViewController, navController, true);
        }
Пример #6
0
        public void Initalize(ref ScanController scanner)
        {
            _scanner = scanner;
            _scanner.ScanComplete += ScannerScanComplete;

            //_sc.StartScanning(_sc.AvalibleWlanInterfaces[0], 1000);
            //_updateTimer.Start();

            timeGraph1.SetScanner(ref _scanner);
            scannerView.SetScanner(ref _scanner);
            scannerView.RequireRefresh += ScannerViewRequireRefresh;
            chanView24.SetScanner(ref _scanner);
            chanView58.SetScanner(ref _scanner);
            networkInterfaceSelector1.Initialize(ref _scanner);
            //networkInterfaceSelector1.NetworkScanStartEvent += NetworkInterfaceSelectorNetworkScanStartEvent;
            //networkInterfaceSelector1.NetworkScanStopEvent += NetworkInterfaceSelectorNetworkScanStopEvent;

            _gpsStatTimer          = new Timer(1000);
            _gpsStatTimer.Elapsed += GpsStatTimerElapsed;

            gpsMon1.SetScanner(ref _scanner);
            UpdateButtonsStatus();

            //Load settings
            SettingsMgr.ApplyScannerViewSettings(scannerView);
        }
Пример #7
0
        public void StartScanningTest()
        {
            ScanController target = new ScanController();

            target.StartScanning();
            Assert.IsNotNull(target);
        }
Пример #8
0
        /// <summary>
        ///  Bu fonksiyon ilgili taramayı siler.
        ///  This function deletes the Scan.
        /// </summary>
        /// <param name="manager">W3afManager Object</param>
        public static void DeleteScan(W3afManager manager)
        {
            try
            {
                string response = StopScan(manager);

                if (response == "Tarama Durduruldu")
                {
                    ScanController = new ScanController();
                    string ScanID = GetScanID(manager);
                    response = ScanController.DeleteScan(manager, ScanID);
                    if (response == null)
                    {
                        Console.WriteLine("***\nTarama Durdurulamadı.\n***");
                    }
                    else
                    {
                        Console.WriteLine("Tarama Silindi");
                    }
                }
                else if (response == "Tarama Yok")
                {
                    Console.WriteLine("***\nSilinecek Tarama Yok.\n***");
                }
                else if (response == "Tarama Durdurulamadı")
                {
                    Console.WriteLine("***\nTarama Durdurulamadı.\n***");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("\nScanView::DeleteScan\n Exception: " + ex.Message);
            }
        }
Пример #9
0
        /// <summary>
        /// Bu fonksiyon otomatik (autopilot) veya profile tarama başlatır.
        /// </summary>
        public static void ScanCreate(NetsparkerManager netsparkerManager)
        {
            ScanController scanController = new ScanController();

            string targetUrl, targetLoginUrl, username, password, policyID;

            try
            {
                Console.Write("Site Login bilgilerini girmek istiyor musunuz? (E/H):");
                string loginState = Console.ReadLine();

                if (loginState.ToUpper() == "E")
                {
                    Console.Write("Lütfen Policy Seçiniz.\n");
                    policyID = ChoosePolicy();

                    Console.Write("Hedef Adresi Giriniz: ");
                    targetUrl = Console.ReadLine();

                    Console.Write("Hedef Adresin Login Sayfasını Giriniz: ");
                    targetLoginUrl = Console.ReadLine();

                    Console.Write("Hedef Adres Login username Giriniz: ");
                    username = Console.ReadLine();

                    Console.Write("Hedef Adres Login password Giriniz: ");
                    password = Console.ReadLine();



                    if (scanController.ScanCreate(netsparkerManager, targetUrl, targetLoginUrl, username, password, policyID))
                    {
                        Console.WriteLine("Tarama başarılı bir şekilde tamamlandı. XML Dosyası " + GetReportLocation() + " konumunda oluşturuldu.");
                    }
                    else
                    {
                        Console.WriteLine("Tarama tamamlanamadı.");
                    }
                }
                else if (loginState.ToUpper() == "H")
                {
                    Console.Write("Hedef Adresi Giriniz: ");
                    targetUrl = Console.ReadLine();

                    if (scanController.ScanCreate(netsparkerManager, targetUrl))
                    {
                        Console.WriteLine("Tarama başarılı bir şekilde tamamlandı. XML Dosyası " + GetReportLocation() + " konumunda oluşturuldu.");
                    }
                    else
                    {
                        Console.WriteLine("Tarama tamamlanamadı.");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #10
0
 private void OnApplicationPause(bool pauseStatus)
 {
     if (pauseStatus && ScanController.IsInitialized)
     {
         buttonScan.GetComponentInChildren <TMP_Text>().text = "Start scanning";
         ScanController.StopScan();
     }
 }
Пример #11
0
        public void SetScanner(ref ScanController scanner)
        {
            _scanner = scanner;
            _scanner.GpsControl.GpsStatUpdated += GpsControl_GpsStatUpdated;
            _scanner.GpsControl.GpsMessage     += GpsControl_GpsMessage;

            gpsGraph1.SetScanner(ref scanner);
            UpdateView();
        }
Пример #12
0
    void Awake()
    {
#pragma warning disable CS0162
        if (isLogging)
        {
            Debug.Log(TAG + "Awake");
        }
#pragma warning restore CS0162

        instance = this;
    }
Пример #13
0
        private static void Scanner_ThreatDetected(ScanController sender, ThreatDetectedArgs args)
        {
            // Notify user
            //Console.WriteLine("\nTHREAT DETECT: {0}\n{1}", args.Detection.Definition, args.FilePath);

            // Add threat detection to list
            lock (locker)
            {
                Threats.Add(args);
            }
        }
        public async Task Range_ShouldNotUpdateLastProcessed()
        {
            // Arrange
            var transactionServiceTests = new TransactionTrackingServiceTests();
            var lastProcessed           = 0UL;
            var scanController          = new ScanController(transactionServiceTests.Init(lastProcessed));

            // Act
            await scanController.Range(1, 2);

            // Assert
            Assert.Equal(lastProcessed, transactionServiceTests.LastProcessed);
        }
Пример #15
0
    IEnumerator StartScanning()
    {
        if (ScanController.IsInitialized)
        {
            yield return(0);

            ScanController.StartScan();
        }
        else
        {
            yield return(new WaitForSeconds(0.1F));            // wait for ScanController to be initialized

            ScanController.StartScan();
        }
    }
Пример #16
0
        private void InitScreens()
        {
            _startScreenController = new StartScreenController();
            _startScreenController.OnStartScanPressed += GoFromStartScreenToScanScreen;
            _startScreenViewController = new StartScreenViewController(_startScreenController);

            _scanController = new ScanController();
            _scanController.ScanCanceled            += GoFromScanScreenToStartScreen;
            _scanController.ScanCompletedWithResult += GoFromScanScreenToInfoScreen;
            _scannerViewController = new ZXingScannerViewController(_scanController);

            _exibitInfoController = new ExibitInfoController(_exibitInfoService);
            _exibitInfoController.ShowScanScreen += GoFromInfoScreenToScanScreen;
            _exibitInfoViewController             = new ExibitInfoViewController(_exibitInfoController);
        }
Пример #17
0
 /// <summary>
 ///  Bu fonksiyon Taramaları ekrana yazar.
 ///  This function writes the Scans to screen.
 /// </summary>
 /// <param name="manager">W3afManager Object</param>
 public static void GetScan(W3afManager manager)
 {
     try
     {
         ScanController = new ScanController();
         Scan scans = ScanController.GetScan(manager);
         if (scans.Items.Count > 0)
         {
             Console.WriteLine("Devam Eden Tarama ID: " + scans.Items[0].Id);
         }
         else
         {
             Console.WriteLine("Herhangi bir tarama mevcut değildir.");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("ScanView::PrintScan() Error Message:" + ex.Message);
     }
 }
Пример #18
0
        /// <summary>
        ///  Bu fonksiyon yeni bir Tarama oluşturur ve oluşturulan ID'yi ekrana yazar.
        ///  This function creates a new Scan and created ID writes to the screen.
        /// </summary>
        /// <param name="manager"></param>
        public static void CreateScan(W3afManager manager)
        {
            string currentDir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;

            try
            {
                //Profile Name is scan settings namely it is policy. Profile Adı tarama ayarlarıdır yani policydir.
                string scanProfileName = SelectProfile();
                Console.WriteLine(scanProfileName);

                //Web Site Login Page, Login username and Login Password.
                EditPolicyLoginInformation(currentDir, scanProfileName);


                string scanProfile = System.IO.File.ReadAllText(currentDir + "\\Model\\Policys\\" + scanProfileName);
                string targetURL   = SelectTargetURL();


                ScanCreate scanCreate = new ScanCreate(scanProfile, targetURL);
                ScanController = new ScanController();


                string json         = JsonConvert.SerializeObject(scanCreate);
                string responseJson = ScanController.CreateScan(manager, json);

                if (responseJson == null)
                {
                    Console.WriteLine("Sistemde herhangi bir tarama mevcut ise öncelikle onu siliniz.");
                    return;
                }

                ScanCreateResponse scanCreateResponse = JsonConvert.DeserializeObject <ScanCreateResponse>(responseJson);
                Console.WriteLine("Oluşturulan Tarama ID: " + scanCreateResponse.ID);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ScanView::CreateScan Exception: " + ex.Message);
            }
        }
Пример #19
0
        private static void Scanner_ThreatScanComplete(ScanController sender)
        {
            // stop the watch
            watch.Stop();

            // Notify user
            Console.WriteLine("\n\n\nScan complete...");

            // Calc rate
            double rate = ((double)DetectionCount / (double)TotalFiles) * 100.0;

            // Display detection rate (this is only a valid rating if you are scanning a folder of malware only)
            Console.WriteLine("{0} / {1} Files detected...", DetectionCount, TotalFiles);
            Console.WriteLine("If the files are all malcious, your database is providing a {0:0.00} detection rate.", rate);
            Console.WriteLine("{0} Files Scanned, {1:0.00}MB Processed", TotalFiles, sender.ScannedData);
            Console.WriteLine("Total Time: {0}", watch.Elapsed);

            // If threats were detected
            if (DetectionCount > 0)
            {
                // Advise user
                Console.WriteLine("\n\nPress any key to see the list of threats detected...");
                Console.ReadKey();

                Console.Clear();
                Console.WriteLine("Threats: ");

                // Display list of threats and their locations
                foreach (ThreatDetectedArgs t in Threats)
                {
                    Console.WriteLine("\nTHREAT DETECT: {0}\n{1}", t.Detection.Definition, t.FilePath);
                }

                Console.WriteLine("\n\nYou may now exit...");
            }
        }
Пример #20
0
    public void OnClickButtonSubscriptions()
    {
        if (isButtonSubscriptionsPressed)
        {
            isButtonSubscriptionsPressed = true;
            return;
        }
                #pragma warning disable CS0162
        if (isLogging)
        {
            Debug.Log(TAG + "onClickButtonSubscriptions");
        }
                #pragma warning restore CS0162

        // detach events
        ScanController.Event      -= OnScanControllerCallbackEvent;
        MovesenseController.Event -= OnMovesenseControllerCallbackEvent;

        ScanController.StopScan();

        MovesenseDevice.RemoveUnconnected();

        SceneManager.LoadScene(1);
    }
Пример #21
0
        static void Main(string[] args)
        {
            // Output some information about the program running
            Console.Title = "Berzerk Malware Scanner 2 - Test Client - http://JordanHook.com";

            // Output version of tester
            Console.WriteLine("Berzerk Malware Scanner Test Client 2.0");

            // Scan a folder based on the args
            if (args.Length == 0)
            {
                Console.WriteLine("No scan directory specified...");
                return;
            }

            // Declare some variables for the scan
            string ScanDirectory = args[0];

            // Our controllers...
            SignatureController Signatures = new SignatureController("sigs.sdb");

            // Load the library setting defaults (we will add a settings controller later...)
            BerzerkAPI.Settings.Defaults();

            //Set max file size to 5mb to testing purposes..
            BerzerkAPI.Settings.MaxFileSize = (1024 * 1024) * 5;

            // Try to load the signatures
            if (Signatures.LoadDatabase())
            {
                Console.WriteLine("Signature database was loaded with {0} entries", Signatures.Signatures.Count);
            }
            else
            {
                // If the signatures can't be loaded... we can't scan for anything
                Console.WriteLine("Unable to load signature database...");
                return;
            }

            // Output current task
            Console.WriteLine("\nGathering files to scan...");

            // Now that our controllers have been loaded... we can attempt to start scanning files
            Queue <string> ScanList = BerzerkAPI.IO.File.CreateFileQueue(ScanDirectory, true);

            Threats = new List <ThreatDetectedArgs>();

            // Store total files to scan...
            TotalFiles = ScanList.Count;

            // Output current task
            Console.WriteLine("\nScanning {0} files...", ScanList.Count);

            // Create an instance of the scan controller to work with
            ScanController scanner = new ScanController(ScanList, Signatures);

            // Setup events
            scanner.ThreatDetected     += Scanner_ThreatDetected;
            scanner.ThreatScanComplete += Scanner_ThreatScanComplete;

            // setup watch
            watch = new Stopwatch();

            // Background reporting..
            new Thread(() =>
            {
                Thread.Sleep(1000);

                // Output some information about the current scan...
                while (scanner.Scanning)
                {
                    Console.WriteLine("{0}/{1} Files scanned\t{2:0.00} MB Processed\t{3}", TotalFiles - scanner.TargetFiles.Count, TotalFiles, scanner.ScannedData, watch.Elapsed.ToString());
                    Console.WriteLine("{0} Threads Active", scanner.RunningThreads);
                    Thread.Sleep(1000);
                }
            }).Start();


            // start the watch
            watch.Start();

            // Start the scan
            scanner.Run();

            // Keep the program open
            System.Diagnostics.Process.GetCurrentProcess().WaitForExit();
        }
Пример #22
0
        static void Main(string[] args)
        {
            Debug.WriteLine("inSSIDer 2 version " + Application.ProductVersion + " Starting");
            //TODO: Make conmmand line option to enable logging on debug builds. Like /log
#if DEBUG && LOG
            Log.Start();
#endif
            Debug.WriteLine("Hook exception handlers");
            // Create new instance of UnhandledExceptionDlg:
            // NOTE: this hooks up the exception handler functions
            UnhandledExceptionDlg exDlg = new UnhandledExceptionDlg();
            InitializeExceptionHandler(exDlg);

            Debug.WriteLine("Check .NET configuration system");
            //Check for config system condition here
            if (!Settings.Default.CheckSettingsSystem())
            {
                //The settings system is broken, notify and exit
                MessageBox.Show(
                    Localizer.GetString("ConfigSystemError"),
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if DEBUG && LOG
            frmTest ft          = new frmTest();
            Thread  debugThread = new Thread(() => Application.Run(ft));
            debugThread.Start();
#endif

            //Initialize the scanner object before passing it to any interface
            ScanController scanner = new ScanController();
            Exception      error;

            Debug.WriteLine("Initialize ScanController");
            scanner.Initialize(out error);
            if (error != null)
            {
                //An error!
                scanner.Dispose();
                scanner = null;
                //So the error handler will catch it
                //throw ex;

                //Log it
                Log.WriteLine(string.Format("Exception message:\r\n\r\n{0}\r\n\r\nStack trace:\r\n{1}", error.Message, error.StackTrace));

                if (error is System.ComponentModel.Win32Exception)
                {
                    //The wireless system failed
                    if (Utilities.IsXp())
                    {
                        MessageBox.Show(Localizer.GetString("WlanServiceNotFoundXP"), "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Hand);
                    }
                    else
                    {
                        MessageBox.Show(Localizer.GetString("WlanServiceNotFound7"), "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Hand);
                    }
                }
                else
                {
                    //Any other exceptions
                    MessageBox.Show(error.Message, "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Hand);
                }
            }

            if (scanner == null)
            {
                return;
            }

            //Start the scanning if it was last time and we have the last interface
            //Otherwise, if we only have the interface, but not scanning, just set the interface selector to the last interface.
            //TODO: Actually have the auto-start as an option. :)

            NetworkInterface netInterface = InterfaceManager.Instance.LastInterface;
            if (netInterface != null)
            {
                Debug.WriteLine("We have a last interface, start scanning with it.");
                //Set the interface
                scanner.Interface = netInterface;
                if (Settings.Default.scanLastEnabled)
                {
                    scanner.StartScanning();
                }
            }

            //The main form will run unless mini is specified
            IScannerUi form = null;

            Switching = Settings.Default.lastMini ? Utilities.SwitchMode.ToMini : Utilities.SwitchMode.ToMain;

            //Apply settings now
            SettingsMgr.ApplyGpsSettings(scanner.GpsControl);

            do
            {
                //Check for switching
                switch (Switching)
                {
                case Utilities.SwitchMode.None:
                    //We're not switching, close program
                    break;

                case Utilities.SwitchMode.ToMain:
                    //We're switching to the main form
                    Debug.WriteLine("Switch to main form");
                    form = new FormMain(scanner);
                    SettingsMgr.ApplyMainFormSettings((Form)form);
                    break;
                }
                LastSwitch = Switching;
                //If we've switched, we don't need to get stuck in a loop
                Switching = Utilities.SwitchMode.None;

                form.Initalize(ref scanner);
                try
                {
                    Application.Run(form as Form);
                }
                catch (ObjectDisposedException)
                {
                }
                catch (AccessViolationException)
                {
                    Debug.WriteLine("AccessViolationException, attempt to recover");
                    if (Application.VisualStyleState == System.Windows.Forms.VisualStyles.VisualStyleState.NonClientAreaEnabled)
                    {
                        throw;
                    }
                    // This could be caused by visual styles
                    Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.NonClientAreaEnabled;
                    // Trigger restart
                    Switching = LastSwitch;//Utilities.SwitchMode.ToMain;
                }
            } while (Switching != Utilities.SwitchMode.None);


            if (scanner.GpsControl != null)
            {
                //GPS enabled setting
                Settings.Default.gpsEnabled = scanner.GpsControl.Enabled;
            }

            // Save Filters

            //Save settings before exit
            Settings.Default.Save();

            //Dispose the scanner, we're done with it
            scanner.Dispose();

            Debug.WriteLine("Execution Finished, you may now close this window", "Program.Main()");
        }
Пример #23
0
 void Awake()
 {
     Instance = this;
 }
Пример #24
0
        public Scan() : base()
        {
            zxing = new ZXingScannerView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            zxing.OnScanResult += (result) =>
            {
                while (scanTries <= 5)
                {
                    if (ScanController.ProcessResult(result.Text))
                    {
                        Debug.WriteLine("\nScans Succeed...\n");
                        break;
                    }
                    else
                    {
                        Debug.WriteLine("\nScanfailded...\n");
                        scanTries       = (scanTries + 1);
                        overlay.TopText = "Poging: " + scanTries;
                    }
                }

                if (scanTries <= 5)
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await DisplayAlert("Succes~!", "Je account is succesvol gekoppeld", "Begrepen.");
                    });
                }
                else
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await DisplayAlert("Fout~!", "Je account kan niet worden gekoppeld, controleer je internetverbinding of probeer het later opnieuw.", "Begrepen.");
                    });
                }
                zxing.IsScanning     = false;
                scanTries            = 0;
                App.Current.MainPage = new NavigationPage(new NavMaster());
            };
            overlay = new ZXingDefaultOverlay
            {
                TopText         = "Poging: " + scanTries,
                BottomText      = "Even geduld a.u.b.",
                ShowFlashButton = zxing.HasTorch,
            };
            overlay.FlashButtonClicked += (sender, e) => {
                zxing.IsTorchOn = !zxing.IsTorchOn;
            };
            var grid = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            grid.Children.Add(zxing);
            grid.Children.Add(overlay);

            Content = grid;
        }
Пример #25
0
        /// <summary>
        ///  Bu fonksiyon yeni bir Tarama oluşturur ve oluşturulan ID'yi ekrana yazar.
        ///  This function creates a new Scan and created ID writes to the screen.
        /// </summary>
        /// <param name="manager"></param>
        public static void CreateScan(NexposeManager manager)
        {
            ScanController = new ScanController();
            try
            {
                string selected = "";
                do
                {
                    Console.Write("Yeni  Varlık Oluşturmak İstiyor musunuz? (E/H)");
                    selected = Console.ReadLine();
                    string responseId = "";
                    if (selected.ToUpper() == "E")
                    {
                        //Profile Name is scan settings namely it is policy. Profile Adı tarama ayarlarıdır yani policydir.
                        Console.WriteLine("Varlık Adı Giriniz.");
                        string          siteName        = Console.ReadLine();
                        string          scanProfileName = ListAndSelectTemplate(manager);
                        string          targetURL       = SelectTargetURL();
                        SiteCreateModel siteCreate      = new SiteCreateModel(siteName, targetURL, scanProfileName);
                        responseId = ScanController.CreateSite(manager, siteCreate);
                    }
                    else if (selected.ToUpper() == "H")
                    {
                        //Varlıkları Listele
                        SitesModel sitesModel = ScanController.GetSites(manager);
                        int        counter    = 1;
                        if (sitesModel.Resources.Length == 0)
                        {
                            Console.WriteLine("Herhangi bir varlık bulunmamaktadır. Öncelikle yeni bir varlık oluşturunuz.");
                            break;
                        }

                        foreach (var item in sitesModel.Resources)
                        {
                            Console.WriteLine(counter + ") " + item.Name);
                            counter += 1;
                        }
                        Console.WriteLine("Site Numarasını giriniz: ");
                        int id = Convert.ToInt32(Console.ReadLine());


                        ScanCreate scanCreate = new ScanCreate(null, sitesModel.Resources[id - 1].ScanTemplate);

                        ScanCreateResponse scanCreateResponse = ScanController.CreateScan(manager, id.ToString(), scanCreate);
                        if (scanCreateResponse.Id > 0)
                        {
                            Console.WriteLine("Tarama Oluşturuldu. Tarama ID: " + scanCreateResponse.Id);
                            break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Geçersiz Seçim");
                    }
                } while (selected != "E" & selected != "H");



                //ScanCreate scanCreate = new ScanCreate(scanProfileName, targetURL);
                //string json = JsonConvert.SerializeObject(scanCreate);



                //if (responseJson == null)
                //{
                //    Console.WriteLine("Sistemde herhangi bir tarama mevcut ise öncelikle onu siliniz.");
                //    return;
                //}

                //ScanCreateResponse scanCreateResponse = JsonConvert.DeserializeObject<ScanCreateResponse>(responseJson);
                //Console.WriteLine("Oluşturulan Tarama ID: " + scanCreateResponse.ID);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ScanView::CreateScan Exception: " + ex.Message);
            }
        }
Пример #26
0
 public void SetScanner(ref ScanController scanner)
 {
     _scanner = scanner;
 }
Пример #27
0
 public void SetScanner(ref ScanController s)
 {
     _sc = s;
 }
Пример #28
0
        void httpServer_ProcessRequest(System.Net.HttpListenerContext ctx)
        {
            ActionResult actionResult;

            if (ctx.Request.HttpMethod == "POST")
            {
                var segments = new Uri(ctx.Request.Url.AbsoluteUri).Segments;
                if (segments.Length > 1 && segments[segments.Length - 2] == "TWAIN@Web/" && segments[segments.Length - 1] == "ajax")
                {
                    var scanFormModelBinder = new ModelBinder(GetPostData(ctx.Request));
                    var method         = scanFormModelBinder.BindAjaxMethod();
                    var scanController = new ScanController(_markerAsynchrone);
                    switch (method)
                    {
                    case "GetScannerParameters":
                        actionResult = scanController.GetScannerParameters(_scannerManager, _cacheSettings, scanFormModelBinder.BindSourceIndex());
                        break;

                    case "Scan":
                        actionResult = scanController.Scan(scanFormModelBinder.BindScanForm(), _scannerManager);
                        break;

                    case "RestartWia":
                        actionResult = scanController.RestartWia();
                        break;

                    case "Restart":
                        actionResult = scanController.Restart();
                        break;

                    default:
                        actionResult = new ActionResult {
                            Content = new byte[0]
                        };
                        ctx.Response.Redirect("/TWAIN@Web/");
                        break;
                    }
                }
                else
                {
                    actionResult = new ActionResult {
                        Content = new byte[0]
                    };
                    ctx.Response.Redirect("/TWAIN@Web/");
                }
            }
            else if (ctx.Request.Url.AbsolutePath.Length < 11)
            {
                actionResult = new ActionResult {
                    Content = new byte[0]
                };
                ctx.Response.Redirect("/TWAIN@Web/");
            }
            else
            {
                var contr            = new HomeController();
                var requestParameter = ctx.Request.Url.AbsolutePath.Substring(11);
                if (requestParameter != "download")
                {
                    // /twain@web/ — это 11 символов, а дальше — имя файла
                    if (requestParameter == "")
                    {
                        requestParameter = "index.html";
                    }

                    actionResult = contr.StaticFile(requestParameter);
                }
                else
                {
                    var fileParam = new ModelBinder(GetGetData(ctx.Request)).BindDownloadFile();
                    actionResult = contr.DownloadFile(fileParam);
                }
            }

            if (actionResult.FileNameToDownload != null)
            {
                ctx.Response.AddHeader("Content-Disposition", "attachment; filename*=UTF-8''" + Uri.EscapeDataString(Uri.UnescapeDataString(actionResult.FileNameToDownload)));
            }

            if (actionResult.ContentType != null)
            {
                ctx.Response.ContentType = actionResult.ContentType;
            }

            try
            {
                ctx.Response.OutputStream.Write(actionResult.Content, 0, actionResult.Content.Length);
            }
            catch (Exception)
            {
            }
        }
Пример #29
0
 public void SetScanner(ref ScanController scanner)
 {
     _sc = scanner;
     _sc.Cache.DataReset += Cache_DataReset;
 }
Пример #30
0
        private void httpServer_ProcessRequest(System.Net.HttpListenerContext ctx)
        {
            ActionResult actionResult;

            ctx.Response.AppendHeader("Access-Control-Allow-Origin", "*");
            ctx.Response.AppendHeader("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE, OPTIONS");
            if (ctx.Request.HttpMethod == "POST")
            {
                var segments = new Uri(ctx.Request.Url.AbsoluteUri).Segments;
                if (segments.Length > 1 && segments[segments.Length - 2] == (ServiceName + "/") && segments[segments.Length - 1] == "ajax")
                {
                    var scanFormModelBinder = new ModelBinder(GetPostData(ctx.Request));
                    var method         = scanFormModelBinder.BindAjaxMethod();
                    var scanController = new ScanController(_markerAsynchrone);
                    switch (method)
                    {
                    case "GetScannerParameters":
                        actionResult = scanController.GetScannerParameters(_scannerManager, _cacheSettings, scanFormModelBinder.BindSourceIndex());
                        break;

                    case "Scan":
                        actionResult = scanController.Scan(scanFormModelBinder.BindScanForm(), _scannerManager);
                        break;

                    case "RestartWia":
                        actionResult = scanController.RestartWia();
                        break;

                    case "Restart":
                        actionResult = scanController.Restart();
                        break;

                    default:
                        actionResult = DefaultResponce(ctx);
                        break;
                    }
                }
                else
                {
                    actionResult = DefaultResponce(ctx);
                }
            }
            else if (ctx.Request.HttpMethod == "GET")
            {
                if (ctx.Request.Url.AbsolutePath.Length >= _procesName.Length)
                {
                    var homeCtrl = new HomeController();
                    var method   = ctx.Request.Url.AbsolutePath.Substring(_procesName.Length);

                    switch (method)
                    {
                    case "download":
                        ModelBinder MB        = new ModelBinder(GetGetData(ctx.Request));
                        var         fileParam = MB.BindDownloadFile();

                        if (MB.IsBase64)
                        {
                            actionResult = homeCtrl.ConvertToBase64File(fileParam);
                        }
                        else
                        {
                            actionResult = homeCtrl.DownloadFile(fileParam);
                        }
                        break;

                    case "version":
                        actionResult = homeCtrl.GetVersionProgram(
                            Assembly.GetEntryAssembly().GetName().Version.ToString());
                        break;

                    default:
                        if (method == "")
                        {
                            method = "index.html";
                        }
                        actionResult = homeCtrl.StaticFile(method);
                        break;
                    }
                }
                else
                {
                    actionResult = DefaultResponce(ctx);
                }
            }
            else
            {
                actionResult = DefaultResponce(ctx);
            }


            if (actionResult.FileNameToDownload != null)
            {
                ctx.Response.AddHeader("Content-Disposition", "attachment; filename*=UTF-8''" + Uri.EscapeDataString(Uri.UnescapeDataString(actionResult.FileNameToDownload)));
            }

            if (actionResult.ContentType != null)
            {
                ctx.Response.ContentType = actionResult.ContentType;
            }

            try
            {
                ctx.Response.OutputStream.Write(actionResult.Content, 0, actionResult.Content.Length);
            }
            catch (Exception)
            {
            }
        }