Пример #1
0
 public static void RegisterScanTypes([NotNull] Assembly assembly, ScanTypes types)
 {
     if (!AssemblyToScanTypes.ContainsKey(assembly))
     {
         AssemblyToScanTypes.Add(assembly, types);
     }
 }
Пример #2
0
 public FeatureScanArguments(string vmName, string uuid, int duration, ScanTypes type)
 {
     Vm       = vmName;
     Duration = duration;
     Type     = type;
     Uuid     = uuid;
 }
Пример #3
0
        /// <summary>
        /// Record some scan in the database
        /// </summary>
        /// <param name="wallet">The wallet id</param>
        /// <param name="scanType">The scan type</param>
        /// <returns></returns>
        public bool RecordScan(int wallet, ScanTypes scanType)
        {
            Scan tempScan = new Scan();

            tempScan.Wallet   = wallet;
            tempScan.scanType = scanType;

            repoLayer.InsertScan(connection, tempScan);
            return(true);
        }
Пример #4
0
        public void Register(TypeDefinition type, TypeReference scanType)
        {
            HashSet <TypeDefinition> types;

            if (!ScanTypes.TryGetValue(scanType, out types))
            {
                types = new HashSet <TypeDefinition>();
                ScanTypes.Add(scanType, types);
            }

            types.Add(type);
        }
Пример #5
0
        public void BeforePluginsLoaded(IAppHost appHost)
        {
            if (ScriptContext == null)
            {
                ScriptContext = appHost.AssertPlugin <SharpPagesFeature>();
            }

            if (!ScriptContext.ScriptLanguages.Contains(ScriptLisp.Language))
            {
                ScriptContext.ScriptLanguages.Add(ScriptLisp.Language);
            }
            if (AllowScriptingOfAllTypes != null)
            {
                ScriptContext.AllowScriptingOfAllTypes = AllowScriptingOfAllTypes.Value;
            }

            if (!ScriptMethods.IsEmpty())
            {
                ScriptContext.ScriptMethods.AddRange(ScriptMethods);
            }
            if (!ScriptBlocks.IsEmpty())
            {
                ScriptContext.ScriptBlocks.AddRange(ScriptBlocks);
            }
            if (!ScanTypes.IsEmpty())
            {
                ScriptContext.ScanTypes.AddRange(ScanTypes);
            }
            if (!ScanAssemblies.IsEmpty())
            {
                ScriptContext.ScanAssemblies.AddRange(ScanAssemblies);
            }

            if (!ScriptAssemblies.IsEmpty())
            {
                ScriptContext.ScriptAssemblies.AddRange(ScriptAssemblies);
            }
            if (!ScriptTypes.IsEmpty())
            {
                ScriptContext.ScriptTypes.AddRange(ScriptTypes);
            }
            if (!ScriptNamespaces.IsEmpty())
            {
                ScriptContext.ScriptNamespaces.AddRange(ScriptNamespaces);
            }
        }
Пример #6
0
        public static bool Scan(string read, ScanTypes typeScan, Dictionary <string, MalwareTypes> signatures)
        {
            var isMalware = false;

            switch (typeScan)
            {
            case ScanTypes.Single:
                isMalware = ScanSingle(read, signatures);
                break;

            case ScanTypes.Mutil:
                isMalware = ScanMutil(read, signatures);
                break;

            default:
                break;
            }

            return(isMalware);
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="wiaDevice"></param>
        /// <param name="source"></param>
        /// <param name="scanType"></param>
        /// <param name="quality"></param>
        /// <param name="resolution"></param>
        /// <returns></returns>
        public WiaResult AcquireScan(WiaDevice wiaDevice, DocumentSources source, ScanTypes scanType,
                                     ScanQualityTypes quality = ScanQualityTypes.None, int resolution = 150)
        {
            if (wiaDevice.Type != WIADeviceTypes.Scanner)
            {
                throw new Exception("The selected device is not a scanner.");
            }

            var interim = new List <byte[]>();

            try
            {
                object     index      = wiaDevice.ManagerIndex;
                DeviceInfo deviceInfo = _deviceManager.DeviceInfos[index];
                Device     device     = deviceInfo.Connect();

                int intentValue    = (int)scanType + (int)quality;
                int documentStatus = 0;

                device.Properties.SetProperty(WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_SELECT, source);
                device.Properties.SetProperty(WIA_IPS_XRES, resolution);
                device.Properties.SetProperty(WIA_IPS_YRES, resolution);
                device.Properties.SetProperty(WIA_IPS_CUR_INTENT, intentValue);
                documentStatus = (int)device.Properties.GetProperty(WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_STATUS);

                foreach (Item itm in device.Items)
                {
                    while ((documentStatus & FEED_READY) == FEED_READY)
                    {
                        //Get item flags
                        var flag = (WiaItemFlag)itm.Properties.GetProperty(4101);

                        //This process can only handle images. Everything else is to be ignored.
                        if ((flag & WiaItemFlag.ImageItemFlag) != WiaItemFlag.ImageItemFlag)
                        {
                            continue;
                        }
                        ImageFile image = (ImageFile)itm.Transfer();
                        documentStatus = (int)device.Properties.GetProperty(WIA_PROPERTIES_WIA_DPS_DOCUMENT_HANDLING_STATUS);
                        var bytes = image.ToByte();
                        interim.Add(bytes);

                        if (this.ItemAcquired != null)
                        {
                            this.ItemAcquired(this, new EventArgs());
                        }
                    }
                }
            }
            catch (COMException cx)
            {
                var code = cx.GetWiaErrorCode();
                if (code != 3)
                {
                    throw new WiaException(WiaExtensions.GetErrorCodeDescription(code), code, cx);
                }
            }

            if (this.AcquisitionCompleted != null)
            {
                this.AcquisitionCompleted(this, new EventArgs());
            }

            var result = new WiaResult(interim);

            return(result);
        }