Esempio n. 1
0
        private void ConfigureControls(ScanToUsbData data)
        {
            usb_TextBox.Text              = data.UsbName;
            quickSet_TextBox.Text         = data.QuickSetName;
            quickSet_RadioButton.Checked  = data.UseQuickset;
            usbName_RadioButton.Checked   = !data.UseQuickset;
            useOcr_CheckBox.Checked       = data.UseOcr;
            pageCount_NumericUpDown.Value = data.ScanOptions.PageCount;

            lockTimeoutControl.Initialize(data.ScanOptions.LockTimeouts);

            assetSelectionControl.AutomationPause = data.AutomationPause;
            assetSelectionControl.UseAdf          = data.ScanOptions.UseAdf;

            // Determine whether the DSS server should be filled in
            if (!string.IsNullOrEmpty(data.DigitalSendServer))
            {
                digitalSendServer_TextBox.Text         = data.DigitalSendServer;
                usesDigitalSendServer_CheckBox.Checked = true;
            }
            else
            {
                usesDigitalSendServer_CheckBox.Checked = false;
            }
            _scanOptions = data.ScanOptions;
            if (data.ApplicationAuthentication)
            {
                radioButton_ScanToUSB.Checked = true;
            }
            else
            {
                radioButton_SignInButton.Checked = true;
            }
            comboBox_AuthProvider.SelectedValue = data.AuthProvider;
        }
        /// <summary>
        /// Processes the activity given to the plugin.
        /// </summary>
        /// <param name="executionData"></param>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Passed);

            _activityData = _pluginExecutionData.GetMetadata <JetAdvantageScanActivityData>();
            _device       = (IDeviceInfo)executionData.Assets.First();
            UpdateStatus("Starting JetAdvantage " + "Scan to Cloud Repository");
            SetDataLogger(_device);

            if (CheckJetAdvantageAvailability())
            {
                ScanOptions scanOptions = new ScanOptions()
                {
                    LockTimeouts = _activityData.LockTimeouts,
                    PageCount    = _activityData.PageCount,
                    UseAdf       = _activityData.UseAdf,
                };
                _controller = new JetAdvantageScanAutoController(executionData, scanOptions);
                _controller.ActivityStatusChanged += UpdateStatus;
                _controller.DeviceSelected        += UpdateDevice;
                UpdateDataLogger(result);
                return(_controller.RunScanActivity());
            }

            else
            {
                result = new PluginExecutionResult(PluginResult.Failed);
                UpdateDataLogger(result);
                return(result);
            }
        }
Esempio n. 3
0
        Import(string iniFile, FieldsToImport?fields = null)
        {
            Core.View.ShowProgressBox(ProgressTasks.ImportFromNDL);
            try
            {
                var(error, fmsToScan) = await ImportInternal(iniFile, fields : fields);

                if (error != ImportError.None)
                {
                    Log("Import error: " + error, stackTrace: true);
                    return(false);
                }

                await FMScan.ScanAndFind(fmsToScan,
                                         ScanOptions.FalseDefault(scanGameType: true, scanCustomResources: true));
            }
            catch (Exception ex)
            {
                Log("Exception in NewDarkLoader import", ex);
                return(false);
            }
            finally
            {
                Core.View.HideProgressBox();
            }

            return(true);
        }
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            AutoStoreActivityData data = executionData.GetMetadata <AutoStoreActivityData>();

            ScanOptions scanOptions = new ScanOptions()
            {
                LockTimeouts = data.ScanOptions.LockTimeouts,
                PageCount    = data.ScanOptions.PageCount,
                FileType     = data.ScanOptions.FileType,
            };

            var manager = new AutoStoreScanManager(executionData);

            UpdateStatus("Starting activity.");

            manager.ActivityStatusChanged += UpdateStatus;
            manager.DeviceSelected        += UpdateDevice;

            PluginExecutionResult executionResult = manager.RunScanActivity();

            UpdateStatus("Finished activity.");
            UpdateStatus($"Result = {executionResult.Result}");

            return(executionResult);
        }
Esempio n. 5
0
        private void btnScan_OnClick()
        {
            try {
                switch (currentScanStatus)
                {
                case Memory.ScanStatus.CanScan:
                    ScanOptions scanOptions = new ScanOptions()
                    {
                        strScanValue                  = txtBoxScanValue.Text,
                        strScanSecondValue            = txtBoxScanSecondValue.Text,
                        isHexValue                    = chkBoxIsHexValue.Checked,
                        strSectionNameInclusionFilter = txtBoxSectionsFilterInclude.Text,
                        strSectionNameExclusionFilter = txtBoxSectionsFilterExclude.Text,
                        sectionPageProtectionFilter   = (librpc.VM_PROT)Enum.Parse(typeof(librpc.VM_PROT), (String)cmbBoxSectionsFilterProtection.SelectedItem),
                        sectionMaxLengthFilter        = Convert.ToInt32(numUpDownSectionMaxLength.Value)
                    };
                    bgWorkerScanner.RunWorkerAsync(scanOptions);
                    break;

                case Memory.ScanStatus.DidScan:
                    listViewResults.Items.Clear();
                    currentScanStatus = Memory.ScanStatus.CanScan;
                    break;

                case Memory.ScanStatus.Scanning:
                    bgWorkerScanner.CancelAsync();
                    break;
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString(), "btnScan");
            }
        }
Esempio n. 6
0
        private void Awake()
        {
            global::Tweaker.Core.LogManager.Set(new LogManager());
            logger = global::Tweaker.Core.LogManager.GetCurrentClassLogger();
            logger.Info("Logger initialized");
            tweaker = new Tweaker();
            Scanner     scanner     = new Scanner();
            ScanOptions scanOptions = new ScanOptions();

            scanOptions.Assemblies.ScannableRefs = new Assembly[1] {
                typeof(TweakerConsoleTestbed).Assembly
            };
            TweakerOptions tweakerOptions = new TweakerOptions();

            tweakerOptions.Flags = TweakerOptionFlags.ScanForInvokables | TweakerOptionFlags.ScanForTweakables | TweakerOptionFlags.ScanForWatchables | TweakerOptionFlags.DoNotAutoScan | TweakerOptionFlags.IncludeTests;
            tweaker.Init(tweakerOptions, scanner);
            TweakerSerializer serializer = new TweakerSerializer(tweaker.Scanner);

            tweaker.Scanner.Scan(scanOptions);
            console = Object.Instantiate(ConsolePrefab);
            logger.Info("console instatiated: " + console);
            console.GetComponent <RectTransform>().SetParent(GetComponent <RectTransform>(), worldPositionStays: false);
            logger.Info("console parented to testbed canvas");
            console.Init(tweaker, serializer);
        }
Esempio n. 7
0
        public string GenerateResult(ScanOptions scanOptions, DiscoveredScanner scanner)
        {
            try
            {
                string result = "";

                foreach (IFileNamingBlock block in Blocks)
                {
                    result += block.ToString(scanOptions, scanner);
                }

                return(result + ConvertImageScannerFormatToString(scanOptions.Format.TargetFormat));
            }
            catch (Exception exc)
            {
                ILogService       logService       = Ioc.Default.GetService <ILogService>();
                IAppCenterService appCenterService = Ioc.Default.GetService <IAppCenterService>();

                logService.Log.Error(exc, "Generating file name from {pattern} failed", GetSerialized(true));
                appCenterService.TrackError(exc);

                // fallback to rudimentary legacy file naming
                return("SCN" + DateTime.Now.Hour.ToString("00") + DateTime.Now.Minute.ToString("00") + DateTime.Now.Second.ToString("00"));;
            }
        }
Esempio n. 8
0
        static async Task <int> RunScanAndReturnExitCode(ScanOptions opts)
        {
            CancellationTokenSource tokenSource = new CancellationTokenSource();

            var locoClient = new LocoClient();

            locoClient.Log += (sender, args) =>
            {
                Console.WriteLine(args.Log);
            };

            await locoClient.ConnectAsync(tokenSource.Token);

            locoClient.ScanResultFound += (sender, args) =>
            {
                Console.WriteLine($"Locomotive found: {args.RoadNumber}");
            };

            locoClient.ScanAsync(tokenSource.Token);

            // Wait until a key is pressed and then exit.
            await Task.Factory.StartNew(() =>
            {
                Console.ReadKey();
                tokenSource.Cancel();
            });

            await Task.Delay(100);

            return(0);
        }
Esempio n. 9
0
        private void PerformScan()
        {
            TweakerOptionFlags flags = Options.Flags;

            if ((flags & TweakerOptionFlags.ScanInEverything) != 0)
            {
                ScanEverything();
                return;
            }
            if ((flags & TweakerOptionFlags.ScanInNonSystemAssemblies) != 0)
            {
                ScanNonSystemAssemblies();
                return;
            }
            List <Assembly> list = new List <Assembly>();

            if ((flags & TweakerOptionFlags.ScanInExecutingAssembly) != 0)
            {
                list.Add(Assembly.GetCallingAssembly());
            }
            if ((flags & TweakerOptionFlags.ScanInEntryAssembly) != 0)
            {
                list.Add(Assembly.GetEntryAssembly());
            }
            ScanOptions scanOptions = new ScanOptions();

            scanOptions.Assemblies.ScannableRefs = list.ToArray();
            ScanWithOptions(scanOptions);
        }
Esempio n. 10
0
        private void ScanNonSystemAssemblies()
        {
            ScanOptions scanOptions = new ScanOptions();

            scanOptions.Assemblies.NameRegex = "^(?!(System\\.)|System$|mscorlib$|Microsoft\\.|vshost|Unity|Accessibility|Mono\\.).+";
            ScanWithOptions(scanOptions);
        }
Esempio n. 11
0
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            ScanToWorkflowData data        = executionData.GetMetadata <ScanToWorkflowData>(ConverterProvider.GetMetadataConverters());
            ScanOptions        scanOptions = new ScanOptions()
            {
                LockTimeouts = data.LockTimeouts,
                PageCount    = data.PageCount,
                UseAdf       = data.UseAdf,
            };

            WorkflowScanManager manager;

            if (string.IsNullOrWhiteSpace(data.DigitalSendServer))
            {
                manager = new WorkflowScanManager(executionData, scanOptions);
            }
            else
            {
                manager = new WorkflowScanManager(executionData, scanOptions, data.DigitalSendServer);
            }

            manager.ActivityStatusChanged += UpdateStatus;
            manager.DeviceSelected        += UpdateDevice;
            return(manager.RunScanActivity());
        }
 private void SetValuesOnDeserialized(StreamingContext context)
 {
     if (ScanOptions == null)
     {
         ScanOptions = new ScanOptions();
     }
 }
        private void ConfigureControls(ScanToFolderData data)
        {
            folder_TextBox.Text               = data.FolderPath;
            quickSet_TextBox.Text             = data.QuickSetName;
            quickSet_RadioButton.Checked      = data.UseQuickset;
            networkFolder_RadioButton.Checked = !data.UseQuickset;
            useOcr_CheckBox.Checked           = data.UseOcr;
            applyCredential_Checkbox.Checked  = data.ApplyCredentialsOnVerification;
            pageCount_NumericUpDown.Value     = data.ScanOptions.PageCount;

            OptionalRadioButton.Checked = data.ImagePreviewOptions == 0;
            GenerateRadioButton.Checked = data.ImagePreviewOptions == 1;
            RestrictRadioButton.Checked = data.ImagePreviewOptions == 2;

            lockTimeoutControl.Initialize(data.ScanOptions.LockTimeouts);

            assetSelectionControl.AutomationPause = data.AutomationPause;
            assetSelectionControl.UseAdf          = data.ScanOptions.UseAdf;

            // Determine what logging option should be selected
            if (data.DestinationType == "Folder Multi")
            {
                if (data.DestinationCount > 0)
                {
                    multipleFoldersExact_RadioButton.Checked = true;
                    destinations_NumericUpDown.Value         = data.DestinationCount;
                }
                else
                {
                    multipleFoldersAuto_RadioButton.Checked = true;
                }
            }
            else
            {
                singleFolder_RadioButton.Checked = true;
            }

            // Determine whether the DSS server should be filled in
            if (!string.IsNullOrEmpty(data.DigitalSendServer))
            {
                digitalSendServer_TextBox.Text         = data.DigitalSendServer;
                usesDigitalSendServer_CheckBox.Checked = true;
            }
            else
            {
                usesDigitalSendServer_CheckBox.Checked = false;
            }
            _scanOptions = data.ScanOptions;

            if (data.ApplicationAuthentication)
            {
                radioButton_ScanToFolder.Checked = true;
            }
            else
            {
                radioButton_SignInButton.Checked = true;
            }
            comboBox_AuthProvider.SelectedValue = data.AuthProvider;
        }
Esempio n. 14
0
        private void ScanEntryAssembly()
        {
            ScanOptions scanOptions = new ScanOptions();

            scanOptions.Assemblies.ScannableRefs = new Assembly[1] {
                Assembly.GetEntryAssembly()
            };
            ScanWithOptions(scanOptions);
        }
Esempio n. 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanToFolderActivityData"/> class.
 /// </summary>
 public ScanToUsbData()
 {
     UseQuickset               = false;
     UseOcr                    = false;
     AutomationPause           = TimeSpan.FromSeconds(1);
     ScanOptions               = new ScanOptions();
     ApplicationAuthentication = true;
     AuthProvider              = AuthenticationProvider.Auto;
 }
        /// <summary>
        /// HP JetAdvantage constructor
        /// </summary>
        public JetAdvantageScanAutoController(PluginExecutionData executionData, ScanOptions scanOptions)
            : base(executionData)
        {
            var device = (IDeviceInfo)executionData.Assets.First();

            _device     = new JediWindjammerDevice(device.Address, device.AdminPassword);
            _data       = executionData.GetMetadata <JetAdvantageScanActivityData>();
            _engine     = new OxpdBrowserEngine(_device.ControlPanel);
            ScanOptions = scanOptions;
        }
Esempio n. 17
0
        public Finder(ScanType scanType, FileCompareType fileCompareType, bool includeSubDirectories, string searchPattern = "*")
        {
            var scanOptions = new ScanOptions();
            scanOptions.FileCompareType = fileCompareType;
            scanOptions.IncludeSubDirectories = includeSubDirectories;
            scanOptions.SearchPattern = searchPattern;

            var scannerFactory = new ScannerFactory();
            _scanner = scannerFactory.Create(scanType, scanOptions);
        }
Esempio n. 18
0
 public MyQScanScanManager(PluginExecutionData pluginExecutionData, ScanOptions scanOptions) : base(pluginExecutionData)
 {
     _pluginExecutionData = pluginExecutionData;
     _activityData        = _pluginExecutionData.GetMetadata <MyQScanActivityData>();
     if (ScanLog != null)
     {
         ScanLog.Ocr = false;
     }
     ScanOptions = scanOptions;
 }
 private void ScanPreferences_Button_Click(object sender, EventArgs e)
 {
     using (var scanOptionsForm = new ScanOptionsForm(_scanOptions))
     {
         if (scanOptionsForm.ShowDialog() == DialogResult.OK)
         {
             _scanOptions = scanOptionsForm.ScanOption;
         }
     }
 }
Esempio n. 20
0
        public async Task <EsclJob> CreateJob(ScanOptions options)
        {
            string request  = scanRequestGenerator.Generate(options);
            var    response = await esclClient.PostAsync(endpoint, request);

            string jobUri        = response.Location.PathAndQuery;
            var    statusChecker = new JobStatusChecker(esclClient, host, jobUri);

            return(new EsclJob(statusChecker));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanToJobStorageData"/> class.
 /// </summary>
 public ScanToJobStorageData()
 {
     JobName                   = string.Empty;
     IsPinRequired             = false;
     Pin                       = string.Empty;
     AutomationPause           = TimeSpan.FromSeconds(1);
     ScanOptions               = new ScanOptions();
     ApplicationAuthentication = true;
     AuthProvider              = AuthenticationProvider.Auto;
 }
Esempio n. 22
0
            public override Status Scan <Serial_Device>(out List <Serial_Device> device_list,
                                                        ScanOptions scan_opt = ScanOptions.None)
            {
                device_list = new List <Serial_Device>();
                devices.Clear();


                int i = 1;
                //var allcom = SerialPortStream.GetPortNames();
                var desc = SerialPortStream.GetPortDescriptions();

                if (desc != null && desc.Length > 0)
                {
                    foreach (PortDescription com in desc)
                    {
                        string device_name = com.Port.ToUpper().Replace(" ", String.Empty).Trim();
                        if (!device_name.Contains(DEVICE_PREFIX) || !device_name.Any(c => char.IsDigit(c)))
                        {
                            device_name = DEVICE_PREFIX + i;
                        }
                        while (devices.ContainsKey(device_name))
                        {
                            device_name += "0";
                        }

                        Comm.Serial_Device nod = new Comm.Serial_Device
                                                 (
                            com.Port,
                            device_name,
                            com.Description,
                            "",
                            Mode.UART_Serial
                                                 );
                        nod.FormattedDescription = nod.ToString();
                        devices.Add(device_name.ToLower(), nod);
                        i++;
                    }

                    try
                    {
                        device_list = devices.Select(pair => pair.Value)
                                      .Cast <Serial_Device>()
                                      .Select(s => new { key = Int32.Parse(Regex.Match(s.Name, @"\d+").Value), value = s })
                                      .OrderBy(p => p.key)
                                      .Select(p => p.value)
                                      .ToList();
                    }
                    catch (Exception)
                    {
                        device_list = devices.Select(pair => pair.Value).Cast <Serial_Device>().ToList();
                    }
                }
                return(Utils.StatusCreate(0));
            }
Esempio n. 23
0
 private void FaxOptions_Button_Click(object sender, EventArgs e)
 {
     _faxOptions.ScanJobType = "ScanToFax";
     using (var scanOptionsForm = new ScanOptionsForm(_faxOptions))
     {
         if (scanOptionsForm.ShowDialog() == DialogResult.OK)
         {
             _faxOptions = scanOptionsForm.ScanOption;
         }
     }
 }
Esempio n. 24
0
 /// <summary>
 /// Initializes a new instance of the FaxActivityData class.
 /// </summary>
 public FaxActivityData()
 {
     EnableNotification        = false;
     AutomationPause           = TimeSpan.FromSeconds(1);
     FaxType                   = FaxConfiguration.AnalogFax;
     FaxOperation              = FaxTask.SendFax;
     FaxNumber                 = null;
     FaxReceiveTimeout         = new TimeSpan(0, 1, 0);
     UseSpeedDial              = false;
     ScanOptions               = new ScanOptions();
     ApplicationAuthentication = true;
     AuthProvider              = AuthenticationProvider.Auto;
 }
Esempio n. 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanToFolderData"/> class.
 /// </summary>
 public ScanToFolderData()
 {
     UseQuickset                    = false;
     UseOcr                         = false;
     AutomationPause                = TimeSpan.FromSeconds(1);
     DestinationType                = "Folder";
     DestinationCount               = 1;
     ImagePreviewOptions            = 0;
     ApplyCredentialsOnVerification = false;
     ScanOptions                    = new ScanOptions();
     AuthProvider                   = AuthenticationProvider.Auto;
     ApplicationAuthentication      = true;
 }
Esempio n. 26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScanToEmailData"/> class.
        /// </summary>
        public ScanToEmailData()
        {
            UseQuickset   = false;
            QuickSetName  = string.Empty;
            UseOcr        = false;
            AddressSource = string.Empty;

            AutomationPause           = TimeSpan.FromSeconds(1);
            ImagePreviewOptions       = 0;
            ScanOptions               = new ScanOptions();
            ApplicationAuthentication = true;
            AuthProvider              = AuthenticationProvider.Auto;
        }
Esempio n. 27
0
        /// <summary>
        /// Regenerates the cached data of the add-in registry.
        /// </summary>
        /// <param name="monitor">
        /// Progress monitor to keep track of the rebuild operation.
        /// </param>
        public void Rebuild(IProgressStatus monitor)
        {
            var context = new ScanOptions();

            context.CleanGeneratedAddinScanDataFiles = true;
            database.Repair(monitor, currentDomain, context);

            // A full rebuild may cause the domain to change
            if (!string.IsNullOrEmpty(startupDirectory))
            {
                currentDomain = database.GetFolderDomain(null, startupDirectory);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HpcrScanManager"/> class.
        /// </summary>
        public HpcrScanManager(PluginExecutionData executionData, ScanOptions scanOptions)
            : base(executionData)
        {
            _pluginExecutionData = executionData;
            _activityData        = _pluginExecutionData.GetMetadata <ScanToHpcrActivityData>();

            _documentName = FilePrefix.ToString();

            if (ScanLog != null)
            {
                ScanLog.Ocr = false;
            }
            ScanOptions = scanOptions;
        }
Esempio n. 29
0
        public static int Main(string [] args)
        {
            ProcessProgressStatus monitor = new ProcessProgressStatus(int.Parse(args [0]));

            try {
                string registryPath = Console.In.ReadLine();
                string startupDir   = Console.In.ReadLine();
                string addinsDir    = Console.In.ReadLine();
                string databaseDir  = Console.In.ReadLine();

                AddinDatabase.RunningSetupProcess = true;
                AddinRegistry reg = new AddinRegistry(registryPath, startupDir, addinsDir, databaseDir);

                switch (args [1])
                {
                case "scan": {
                    string folder = args.Length > 2 ? args [2] : null;
                    if (folder.Length == 0)
                    {
                        folder = null;
                    }

                    var context = new ScanOptions();
                    context.Read(Console.In);
                    reg.ScanFolders(monitor, folder, context);
                    break;
                }

                case "pre-scan": {
                    string folder = args.Length > 2 ? args [2] : null;
                    if (folder.Length == 0)
                    {
                        folder = null;
                    }
                    var recursive = bool.Parse(Console.In.ReadLine());
                    reg.GenerateScanDataFilesInProcess(monitor, folder, recursive);
                    break;
                }

                case "get-desc":
                    var outFile = Console.In.ReadLine();
                    reg.ParseAddin(monitor, args [2], args [3]);
                    break;
                }
            } catch (Exception ex) {
                monitor.ReportError("Unexpected error in setup process", ex);
                return(1);
            }
            return(0);
        }
Esempio n. 30
0
        public Scanner Create(ScanType scanType, ScanOptions scanOptions)
        {
            switch (scanType)
            {
                case ScanType.Simple:
                    return new SimpleScanner(scanOptions);

                case ScanType.Smart:
                    return new SmartScanner(scanOptions);

                default:
                    return null;
            }
        }
Esempio n. 31
0
        private static int ProcessScan(ScanOptions option)
        {
            var targetPath = option.Path;

            if (Directory.Exists(targetPath))
            {
                var searchString = string.Empty;
                var pathList     = new List <string>();

                switch (option.FileType)
                {
                case FileType.Assemblies:
                {
                    pathList = ScanAssembly(targetPath, option.Recursive);
                    break;
                };

                case FileType.Nuget:
                {
                    pathList = ScanNuget(targetPath, option.Recursive);
                    break;
                };

                case FileType.Project:
                {
                    ConsoleOutput.Message($"Searching {targetPath} for files ending with '.csproj'");
                    pathList.Add(targetPath);
                    break;
                };

                default: break;
                }

                if (pathList.Count <= 0)
                {
                    ConsoleOutput.ErrorMessage($"No {searchString} files found under {targetPath}");

                    return(1);
                }
                FindDotNetVulnerabilities(pathList, option.Recursive);

                return(0);
            }
            else
            {
                ConsoleOutput.ErrorMessage($"'{targetPath}' is not a valid path");
            }

            return(1);
        }
        private void ConfigureControls(ScanToEmailData data)
        {
            email_ComboBox.Text = data.EmailAddress;

            useOcr_CheckBox.Checked       = data.UseOcr;
            pageCount_NumericUpDown.Value = data.ScanOptions.PageCount;

            assetSelectionControl.AutomationPause = data.AutomationPause;
            assetSelectionControl.UseAdf          = data.ScanOptions.UseAdf;

            quickSet_TextBox.Text              = data.QuickSetName;
            quickSet_RadioButton.Checked       = data.UseQuickset;
            launchFromApp_RadioButton.Checked  = data.LaunchQuicksetFromApp;
            launchFromHome_RadioButton.Checked = !data.LaunchQuicksetFromApp;
            OptionalRadioButton.Checked        = data.ImagePreviewOptions == 0;
            GenerateRadioButton.Checked        = data.ImagePreviewOptions == 1;
            RestrictRadioButton.Checked        = data.ImagePreviewOptions == 2;

            email_ComboBox.Items.Clear();

            // Populate the list of email addresses
            foreach (string email in ConfigurationServices.EnvironmentConfiguration.GetOutputMonitorDestinations("OutputEmail"))
            {
                email_ComboBox.Items.Add(email);
            }

            // Determine whether the DSS server should be filled in
            if (!string.IsNullOrEmpty(data.DigitalSendServer))
            {
                usesDigitalSendServer_CheckBox.Checked = true;
                digitalSendServer_TextBox.Text         = data.DigitalSendServer;
            }
            else
            {
                usesDigitalSendServer_CheckBox.Checked = false;
            }
            // Check AddressSource
            addressSource_comboBox.SelectedIndex = string.IsNullOrEmpty(data.AddressSource) ? 0 : addressSource_comboBox.Items.IndexOf(data.AddressSource);
            _scanOptions = data.ScanOptions;
            if (data.ApplicationAuthentication)
            {
                radioButton_ScanToEmail.Checked = true;
            }
            else
            {
                radioButton_SignInButton.Checked = true;
            }
            comboBox_AuthProvider.SelectedValue = data.AuthProvider;
        }
Esempio n. 33
0
 /// <summary>
 /// Asynchronously scans a directory for viruses, recursing into subdirectories.
 /// </summary>
 /// <param name="engine">ClamAV engine instance.</param>
 /// <param name="path">Path to scan.</param>
 /// <param name="options">Scan options.</param>
 /// <returns>The task object representing the asynchronous operation. The Result property on the task returns the scan results.</returns>
 public static async Task<IEnumerable<FileScanResult>> ScanDirectoryAsync(this ClamEngine engine, string path, ScanOptions options)
 {
     return await engine.ScanDirectoryAsync(path, options, true, 0);
 }
Esempio n. 34
0
        public Vtero Scanit(ScanOptions op)
        {
            bool SkipVMCS = false;
            
#if TESTING

            foreach (var sx in op.DisabledScans)
            {
                var spec = sx.ToLower();

                if (spec.Contains("vmcs"))
                    SkipVMCS = true;
                if (spec.Contains("obsd"))
                    Version = Version & ~PTType.OpenBSD;
                if (spec.Contains("nbsd"))
                    Version = Version & ~PTType.NetBSD;
                if (spec.Contains("fbsd"))
                    Version = Version & ~PTType.FreeBSD;
                if (spec.Contains("lin"))
                    Version = Version & ~PTType.LinuxS;
                if (spec.Contains("hv"))
                    Version = Version & ~PTType.HyperV;
                if (spec.Contains("gen"))
                    Version = Version & ~PTType.GENERIC;
                if (spec.Contains("win"))
                    Version = Version & ~PTType.Windows;

            }
                if((Version & PTType.VALUE) == PTType.VALUE)
                {
                    bool Parsed = false;
                    do
                    {
                        if(args.Length < 2)
                        {
                            WriteLine($"Specify value");
                            return;
                        }

                        Parsed = uint.TryParse(args[2],NumberStyles.HexNumber, CultureInfo.CurrentCulture, out valuI);
                        if (!Parsed)
                        {
                            Parsed = ulong.TryParse(args[2], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out valuL);
                            if (Parsed)
                                Is64Scan = true;
                            else {
                                WriteLine($"Unable to parse input {args[2]}");
                                return;
                            }
                        }
                        else
                            valuL = (ulong)valuI;

                    } while (!Parsed);
                }
#endif
            string Filename = null;
            Vtero vtero = null;
            PTType Version = PTType.Windows;
            
            // this instance is temporally used for loading state
            // i.e. don't set properties or fields here

            var saveStateFile = $"{Filename}.inVtero.net";

            if (File.Exists(saveStateFile))
            {
                if (todo.Key != ConsoleKey.D )
                {
                    vtero = vtero.CheckpointRestoreState(saveStateFile);
                    vtero.OverRidePhase = true;
                }
                else
                    File.Delete(saveStateFile);
            }

            if (vtero.Phase < 2)
                vtero = new Vtero(Filename);

            //Mem.InitMem(parsed.FileName, null, vtero.DetectedDesc);
            ProgressBarz.Bar.Message = "First pass, looking for processes";

            ForegroundColor = ConsoleColor.Cyan;

#if TESTING
            Timer = Stopwatch.StartNew();

                if ((Version & PTType.VALUE) == PTType.VALUE)
                {
                    var off = vtero.ScanValue(Is64Scan, valuL, 0);
                    
                    WriteLine(FormatRate(vtero.FileSize, Timer.Elapsed));
                    using (var dstream = File.OpenRead(vtero.MemFile))
                    {
                        using (var dbin = new BinaryReader(dstream))
                        {
                            foreach (var xoff in off)
                            {
                                WriteLine($"Checking Memory Descriptor @{(xoff + 28):X}");
                                if (xoff > vtero.FileSize)
                                {
                                    WriteLine($"offset {xoff:X} > FileSize {vtero.FileSize:X}");
                                    continue;
                                }

                                dstream.Position = xoff + 28;
                                var MemRunDescriptor = new MemoryDescriptor();
                                MemRunDescriptor.NumberOfRuns = dbin.ReadInt64();
                                MemRunDescriptor.NumberOfPages = dbin.ReadInt64();

                                Console.WriteLine($"Runs: {MemRunDescriptor.NumberOfRuns}, Pages: {MemRunDescriptor.NumberOfPages} ");

                                if (MemRunDescriptor.NumberOfRuns < 0 || MemRunDescriptor.NumberOfRuns > 32)
                                {
                                    continue;
                                }
                                for (int i = 0; i < MemRunDescriptor.NumberOfRuns; i++)
                                {
                                    var basePage = dbin.ReadInt64();
                                    var pageCount = dbin.ReadInt64();

                                    MemRunDescriptor.Run.Add(new MemoryRun() { BasePage = basePage, PageCount = pageCount });
                                }
                                WriteLine($"MemoryDescriptor {MemRunDescriptor}");
                            }
                        }
                    }
                    WriteLine("Finished VALUE scan.");
                    return;
                }
                if ((Version & PTType.VALUE) == PTType.VALUE)
                    return;
#endif
            // basic perf checking
            QuickOptions.Timer = Stopwatch.StartNew();
            var procCount = vtero.ProcDetectScan(Version);

            WriteColor(ConsoleColor.Blue, ConsoleColor.Yellow, $"{procCount} candidate process page tables. Time so far: {QuickOptions.Timer.Elapsed}, second pass starting. {QuickOptions.FormatRate(vtero.FileSize, QuickOptions.Timer.Elapsed)}");

            //BackgroundColor = ConsoleColor.Black;
            //ForegroundColor = ConsoleColor.Cyan;

            if (procCount < 3)
            {
                WriteColor(ConsoleColor.Red,"Seems like a fail. Try generic scanning or implement a state scan like LinuxS");
                return null;
            }
            // second pass
            // with the page tables we acquired, locate candidate VMCS pages in the format
            // [31-bit revision id][abort indicator]
            // the page must also have at least 1 64bit value which is all set (-1)
            // Root-HOST CR3 will have uniform diff
            // unless an extent based dump image is input, some .DMP variations
            // TODO: Add support for extent based inputs
            // Guest VMCS will contain host CR3 & guest CR3 (hCR3 & gCR3)
            // sometimes CR3 will be found in multiple page tables, e.g. system process or SMP 
            // if I have more than 1 CR3 from different file_offset, just trim them out for now
            // future may have a reason to isolate based on original locationAG

            if (SkipVMCS)
                return vtero;

            ProgressBarz.Bar.Message = "Second pass, correlating for VMCS pages";

            var VMCSCount = vtero.VMCSScan();
            //Timer.Stop();

            WriteColor(ConsoleColor.Blue, ConsoleColor.Yellow, $"{VMCSCount} candidate VMCS pages. Time to process: {QuickOptions.Timer.Elapsed}, Data scanned: {vtero.FileSize:N}");

            // second time 
            WriteColor(ConsoleColor.Blue, ConsoleColor.Yellow,  $"Second pass done. {QuickOptions.FormatRate(vtero.FileSize * 2, QuickOptions.Timer.Elapsed)}");

            // each of these depends on a VMCS scan/pass having been done at the moment
            WriteColor(ConsoleColor.Cyan, ConsoleColor.Black, "grouping and joining all memory");

            // After this point were fairly functional
            vtero.GroupAS();

            // sync-save state so restarting is faster
            if (!File.Exists(saveStateFile))
            {
                Write($"Saving checkpoint... ");
                saveStateFile = vtero.CheckpointSaveState();
                WriteColor(ConsoleColor.White, saveStateFile);
            }
            return vtero;
        }
Esempio n. 35
0
        /// <summary>
        /// Asynchronously scans a file for viruses.
        /// </summary>
        /// <param name="engine">ClamAV engine instance.</param>
        /// <param name="path">Path to the file to be scanned.</param>
        /// <param name="options">Scan options.</param>
        /// <returns>The task object representing the asynchronous operation. The Result property on the task returns a scan result.</returns>
        public static async Task<FileScanResult> ScanFileAsync(this ClamEngine engine, string path, ScanOptions options)
        {
            var virusName = string.Empty;
            var scanResult = await Task.Factory.StartNew(() => engine.ScanFile(path, options, out virusName));

            return new FileScanResult(path, scanResult == ScanResult.Virus, virusName);
        }
Esempio n. 36
0
 public SimpleScanner(ScanOptions scanOptions)
     : base(scanOptions)
 {
 }
Esempio n. 37
0
 protected Scanner(ScanOptions scanOptions)
 {
     var fileComparerFactory = new FileComparerFactory();
     _options = scanOptions;
     _fileComparer = fileComparerFactory.Create(scanOptions.FileCompareType);
 }
Esempio n. 38
0
        /// <summary>
        /// Scans a file for viruses.
        /// </summary>
        /// <param name="filePath">Path to the file to be scanned.</param>
        /// <param name="scanOptions">Scan options.</param>
        /// <param name="virusName">Output variable for the virus name, if detected.</param>
        /// <returns>File status.</returns>
        public ScanResult ScanFile(string filePath, ScanOptions scanOptions, out string virusName)
        {
            // Validate arguments.
            if (string.IsNullOrEmpty(filePath))
                throw new ArgumentNullException("filePath");

            IntPtr virusNamePtr = IntPtr.Zero;

            ulong scanned = 0;
            uint options = 0;

            // Convert ScanOptions parameter.
            options = (uint)scanOptions;

            // Perform scan
            var result = (UnsafeNativeMethods.cl_error_t)UnsafeNativeMethods.cl_scanfile(filePath, ref virusNamePtr, ref scanned, _engine, options);

            if (result == UnsafeNativeMethods.cl_error_t.CL_CLEAN)
            {
                // File is clean.
                virusName = string.Empty;

                return ScanResult.Clean;
            }
            else if (result == UnsafeNativeMethods.cl_error_t.CL_VIRUS)
            {
                // We've detected a virus.
                virusName = Marshal.PtrToStringAnsi(virusNamePtr);

                return ScanResult.Virus;
            }
            else
            {
                // Probably an error condition.
                throw new ClamException((int)result, ErrorString((int)result));
            }
        }
Esempio n. 39
0
 /// <summary>
 /// Scan a directory for viruses with custom scan options, recursing into subdirectories.
 /// </summary>
 /// <param name="directoryPath">Path to scan.</param>
 /// <param name="scanOptions">Scan options.</param>
 /// <param name="fileScannedCallback">Called after a file has been scanned.</param>
 public void ScanDirectory(string directoryPath, ScanOptions scanOptions, FileScannedCallback fileScannedCallback)
 {
     ScanDirectory(directoryPath, ScanOptions.StandardOptions, fileScannedCallback, true, 0);
 }
Esempio n. 40
0
        /// <summary>
        /// Scan a directory for viruses, optionally recursing into subdirectories.
        /// </summary>
        /// <param name="directoryPath">Path to scan.</param>
        /// <param name="scanOptions">Scan options.</param>
        /// <param name="fileScannedCallback">Called after a file has been scanned.</param>
        /// <param name="recurse">Enter subdirectories.</param>
        /// <param name="maxDepth">Maximum depth to scan, or zero for unlimited.</param>
        public void ScanDirectory(string directoryPath, ScanOptions scanOptions, FileScannedCallback fileScannedCallback, bool recurse, int maxDepth)
        {
            // Validate arguments.
            if (string.IsNullOrEmpty(directoryPath))
                throw new ArgumentNullException("directoryPath");

            if (fileScannedCallback == null)
                throw new ArgumentNullException("fileScannedCallback");

            var pathStack = new Stack<Tuple<string /* path */, int /* depth */>>();

            // Push the starting directory onto the stack.
            pathStack.Push(Tuple.Create(directoryPath, 1));

            while (pathStack.Count > 0)
            {
                var stackState = pathStack.Pop();

                var currentPath = stackState.Item1;
                var currentDepth = stackState.Item2;

                var attributes = File.GetAttributes(currentPath);

                // If we're in a directory, push all files and subdirectories to the stack.
                if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    // Check if we're not about to go too deep.
                    if (maxDepth == 0 || currentDepth < maxDepth)
                    {
                        var subFiles = Directory.GetFiles(currentPath);
                        foreach (var file in subFiles)
                        {
                            pathStack.Push(Tuple.Create(file, currentDepth + 1));
                        }

                        var subDirectories = Directory.GetDirectories(currentPath);
                        foreach (var directory in subDirectories)
                        {
                            pathStack.Push(Tuple.Create(directory, currentDepth + 1));
                        }
                    }
                }
                // If this is a file, scan it.
                else
                {
                    var virusName = string.Empty;
                    var scanResult = ScanFile(currentPath, scanOptions, out virusName);

                    fileScannedCallback(currentPath, scanResult, virusName);
                }
            }
        }
Esempio n. 41
0
        /// <summary>
        /// Asynchronously scans a directory for viruses, optionally recursing into subdirectories.
        /// </summary>
        /// <param name="engine">ClamAV engine instance.</param>
        /// <param name="path">Path to scan.</param>
        /// <param name="options">Scan options.</param>
        /// <param name="recurse">Whether to enter subdirectories.</param>
        /// <param name="maxDepth">Maximum depth to scan, or zero for unlimited.</param>
        /// <returns>The task object representing the asynchronous operation. The Result property on the task returns the scan results.</returns>
        public static async Task<IEnumerable<FileScanResult>> ScanDirectoryAsync(this ClamEngine engine, string path, ScanOptions options, bool recurse, int maxDepth)
        {
            var scanQueue = new Queue<string>();
            
            var pathStack = new Stack<Tuple<string /* path */, int /* depth */>>();

            // Push the starting directory onto the stack.
            pathStack.Push(Tuple.Create(path, 1));

            while (pathStack.Count > 0)
            {
                var stackState = pathStack.Pop();

                var currentPath = stackState.Item1;
                var currentDepth = stackState.Item2;

                var attributes = File.GetAttributes(currentPath);

                // If we're in a directory, push all files and subdirectories to the stack.
                if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    // Check if we're not about to go too deep.
                    if (maxDepth == 0 || currentDepth < maxDepth)
                    {
                        var subFiles = Directory.GetFiles(currentPath);
                        foreach (var file in subFiles)
                        {
                            pathStack.Push(Tuple.Create(file, currentDepth + 1));
                        }

                        var subDirectories = Directory.GetDirectories(currentPath);
                        foreach (var directory in subDirectories)
                        {
                            pathStack.Push(Tuple.Create(directory, currentDepth + 1));
                        }
                    }
                }
                // If this is a file, enqueue it for scanning.
                else
                {
                    scanQueue.Enqueue(currentPath);
                }
            }

            var scanTasks = scanQueue.Select(engine.ScanFileAsync);
            var scanResults = await Task.WhenAll(scanTasks);

            return scanResults;
        }