Ejemplo n.º 1
0
        public int Detect(AssemblySettings asm)
        {
            int d = 0;

            mod = asm.NativeImage;

            var lastSec = mod.ImageSectionHeaders.Last();

            var eofOffset = lastSec.PointerToRawData + lastSec.SizeOfRawData;

            using (var pe = mod.CreateFullStream())
            {
                // Check whether it's got EOF anyway
                if (pe.Length <= eofOffset)
                {
                    return(d);
                }
                if (pe.Length > eofOffset + 8)
                {
                    pe.Position = eofOffset;
                    byte[] eof = pe.ReadBytes(8);

                    d += eof.SigDetection(asm, "End of File");
                }
                asm.AddDetection("End of File", new Reason("End of File", "End of File data detected, could be storage for malicious content or settings"));
                d++;
            }

            return(d);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Init with Custom ImagePara and StiLib Configuration
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="imagepara"></param>
 public Image(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, ImagePara imagepara)
     : base(gd, slconfig)
 {
     Para = imagepara;
     LoadContent(service, path, Para.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize log verbosity
        /// Called from static class constructor
        /// </summary>
        private static void InitConfigureLogLevel(AssemblySettings settings)
        {
            _logLevel = LOG_LEVEL.None;
            string str = settings["LogLevel"];

            _logLevel = ReadLogLevelFromString(str, LOG_LEVEL.None);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Init Grating with Custom GratingPara, StiLib Configuration File and Default: "Technique1"
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="gratingpara"></param>
 public Grating(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, GratingPara gratingpara)
     : base(gd, slconfig)
 {
     Para = gratingpara;
     LoadContent(service, path, gratingpara.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Init SLQuad with Custom Quad Parameters and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="quad"></param>
 public SLQuad(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, Quad quad)
     : base(gd, slconfig)
 {
     Para = quad;
     LoadContent(service, path, quad.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 6
0
        static void Process(AppSettings config)
        {
            var rootType = GetRootType(config);

            if (rootType == null)
            {
                throw new Exception($"Failed to find root type {config.RootType.Name} in assembly {config.RootType.AssemblyPath}");
            }
            DeleteFiles(config.Properties, outputDirectory);
            DeleteFiles(config.Components, outputDirectory);
            if (config.RootType.IsOutput)
            {
                CreateProperties(rootType, isRoot: true, outputDirectory, config.Namespace, config);
                CreateComponents(rootType, isRoot: true, outputDirectory, config);
            }
            if (config.TemplateBasedAssemblies?.Names.Length > 0)
            {
                var templateSettings = config.TemplateBasedAssemblies;
                foreach (var name in templateSettings.Names)
                {
                    var assemblySettings = new AssemblySettings
                    {
                        Path = templateSettings.Template.Replace("[NAME]", name).Replace("[VERSION]", templateSettings.Version)
                    };
                    WriteLine($"Expanded template {name} to {assemblySettings.Path}");
                    ProcessAssembly(config, rootType, assemblySettings);
                }
            }
            foreach (var assemblySettings in config.Assemblies)
            {
                WriteLine($"{assemblySettings.Path}");
                ProcessAssembly(config, rootType, assemblySettings);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Init with Custom TextPara and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="textpara"></param>
 public Text(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, TextPara textpara)
     : base(gd, slconfig)
 {
     Para = textpara;
     LoadContent(service, path, textpara.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes the control, creating the ContentManager
 /// and using it to load a SpriteFont.
 /// </summary>
 protected override void Initialize()
 {
     config      = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
     content     = new ContentManager(Services, config["content"]);
     spriteBatch = new SpriteBatch(GraphicsDevice);
     font        = content.Load <SpriteFont>("Arial");
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Init with Custom ModelPara and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="modelpara"></param>
 public SLModel(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, ModelPara modelpara)
     : base(gd, slconfig)
 {
     Para = modelpara;
     LoadContent(service, path, modelpara.modelname);
     Init(gd);
 }
Ejemplo n.º 10
0
        public int Detect(AssemblySettings asm)
        {
            _asm = asm;
            int d = 0;


            //asm.NativeImage.UnsafeDisableMemoryMappedIO();
            try
            {
                byte[] file = File.ReadAllBytes(asm.NativeImage.FileName);

                foreach (SignatureEntry sig in DetectionDatabase.Signatures)
                {
                    long sigIndex = ((Sig)sig.Tag).Scan(file);
                    if (sigIndex == -1)
                    {
                        continue;
                    }
                    // Should I insert the sig Category here instead of "Signature"?
                    asm.AddDetection("Signature", new Reason("Signature", string.Format("Matched {0} ({2}) at offset 0x{1}", sig.Trigger, sigIndex.ToString("X2"), sig.Description)));
                    d++;
                }
            }
            catch (Exception)
            {
                // File access issue?
                asm.AddDetection("Signature", new Reason("Signature", "Error when processing signatures"));
                d++;
            }

            return(d);
        }
Ejemplo n.º 11
0
        private void StartBeating()
        {
            if (_timer != null)
            {
                // already started
                return;
            }
            AssemblySettings settings = new AssemblySettings();

            _offlineTimeoutSeconds = StringToInt(settings.GetValue("ServerOnlineTimeoutSeconds", "30"), 30);

            int dllProcessId = System.Diagnostics.Process.GetCurrentProcess().Id;

            _gameToLauncherFilepath = FileLocations.GetGameHeartbeatFilepath(dllProcessId);

            int intervalMilliseconds = 1000 * TIMER_SECONDS;

            _timer          = new System.Timers.Timer();
            _timer.Interval = intervalMilliseconds;
            _timer.Elapsed += _timer_Elapsed;
            _timer.Enabled  = true;
            _timer.Start();
            StartChannelFileWatcher();
            AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes the control, creating the ContentManager
 /// and using it to load a SpriteFont.
 /// </summary>
 protected override void Initialize()
 {
     config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
     content = new ContentManager(Services, config["content"]);
     spriteBatch = new SpriteBatch(GraphicsDevice);
     font = content.Load<SpriteFont>("Arial");
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Init with Custom VideoPara and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="videopara"></param>
 public SLVideo(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, VideoPara videopara)
     : base(gd, slconfig)
 {
     Para = videopara;
     LoadContent(service, path, videopara.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 14
0
        public void TestMethod1()
        {
            //AppSettings appSettings = new AppSettings();
            //Console.WriteLine($"Environment: {AppSettings.EnvironmentName}");

            //public static string EnvironmentName { get { return AssemblySettings.GetConfig()["envirName"].ToString(); } }
            Console.WriteLine($"Environment: {AssemblySettings.GetConfig()["envirName"].ToString()}");
        }
Ejemplo n.º 15
0
        public static ILocaleProvider GetLocaleProvider(Assembly assembly)
        {
            if (AssemblySettings.TryGetValue(assembly, out var localeSettings))
            {
                return(localeSettings.LocaleProvider);
            }

            return(Configure(assembly, null).LocaleProvider);
        }
Ejemplo n.º 16
0
        public static AssemblyLocaleSettings Configure(Assembly assembly, Action <AssemblyLocaleSettings> configurator)
        {
            return(AssemblySettings.AddOrUpdate(assembly, AddValueFactory, (assembly1, settings) =>
            {
                configurator?.Invoke(settings);

                return settings;
            }));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Initialize log settings
        /// Called from static class constructor
        /// </summary>
        private static void InitConfiguration()
        {
            // Get config settings from dll config
            // This is not provided OOB with .NET, so this AssemblySettings class performs this task
            AssemblySettings settings = new AssemblySettings();

            InitConfigureLogLocation(settings);
            InitConfigureLogLevel(settings);
        }
Ejemplo n.º 18
0
        public static List <Detection> Scan(string file, out int detectionCount)
        {
            AssemblySettings asmSettings = new AssemblySettings();
            bool             isNet       = true;

            try
            {
                asmSettings.Module = ModuleDefMD.Load(file);
            }
            catch (Exception)
            {
                isNet = false;
            }

            if (!isNet)
            {
                try
                {
                    asmSettings.NativeImage = new PEImage(file);
                }
                catch (Exception ex)
                {
                    // Cannot continue execution
                    Console.WriteLine(ex);
                    Console.ReadLine();
                    detectionCount = 0;
                    return(new List <Detection>());
                }
            }
            else
            {
                asmSettings.NativeImage = asmSettings.Module.MetaData.PEImage as PEImage;
            }

            List <IDetectionProcess> dp = new List <IDetectionProcess>();

            if (isNet)
            {
                dp.Add(new ResourceDetection());
                dp.Add(new StringDetection());
                dp.Add(new ReflectionDetection());
                dp.Add(new PInvokeDetection());
            }

            dp.Add(new EOFDetection());
            dp.Add(new SectionDetection());
            dp.Add(new SignatureDetection());

            int totalDetections = dp.Sum(x => x.Detect(asmSettings));

            DetectionDatabase.Save();

            detectionCount = totalDetections;

            return(asmSettings.TotalDetections);
        }
Ejemplo n.º 19
0
        // gère les champs de recherche
        public static List <Login> GetLogin(string search, DateTime?searchDateMin,
                                            DateTime?searchDateMax, string state)
        {
            List <Login> outList1 = new List <Login>();

            using (DataBase db = AssemblySettings.getConnection(AssemblySettings.ShCatalog.SecurehWS))
            {
                //retourne les données à l'ouverture de la page web

                var byDesc = "ORDER BY Now DESC";
                var sql    = @"SELECT Login, IpAddress, Now, WebServiceMethod, Status FROM [SecurehWS].[dbo].[WebServiceLogin] where 1=1 ";


                //retourne la donnée des champs date
                if (searchDateMin != null && searchDateMax != null)
                {
                    sql = sql + " and Now between @searchDateMin and @searchDateMax ";
                }

                //retourne la donnée du champ search uniquement
                if (search != null)
                {
                    sql = sql + " and ( Login like @search or  IpAddress like @search or Now like @search or WebServiceMethod like @search or Status like @search ) ";
                }

                //retourne la donnée du champ etat uniquement
                if (state != null)
                {
                    sql = sql + " and Status = @state ";
                }

                db.Requete = sql + byDesc;
                db.addParameter("@state", state);
                db.addParameter("@searchDateMin", searchDateMin);
                db.addParameter("@searchDateMax", searchDateMax);
                db.addParameter("@search", $"%{search}%");
                db.execute_reader();


                while (db.NextLine())
                {
                    var   login      = db.GetDataOrDefault <string>("Login");
                    var   addresse   = db.GetDataOrDefault <string>("IpAddress");
                    var   dateNow    = db.GetDataOrDefault <DateTime>("Now");
                    var   webservice = db.GetDataOrDefault <string>("WebServiceMethod");
                    var   Status     = db.GetDataOrDefault <string>("Status");
                    Login tr1        = new Login {
                        addresse = addresse, date = dateNow, login = login, state = Status, webservice = webservice
                    };
                    outList1.Add(tr1);
                }
            }
            return(outList1);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Initialize log location
        /// Called from static class constructor
        /// </summary>
        private static void InitConfigureLogLocation(AssemblySettings settings)
        {
            string filepath = settings["LogFilepath"];

            // If no log path specified, default to our normal app logs folder
            if (string.IsNullOrEmpty(filepath))
            {
                filepath = FileLocations.AppLogsFolder + @"\Mag-Filter_%PID%_log.txt";
            }
            _logFilepath = FileLocations.ExpandFilepath(filepath);
            // Create any needed folders
            FileLocations.CreateAnyNeededFoldersOfFile(_logFilepath);
        }
Ejemplo n.º 21
0
        static ProtocolInitiation()
        {
            AssemblySettings settings = new AssemblySettings();

            string openAMQ = settings["OpenAMQ1d4Compatibility"];

            /*
             * if (openAMQ.Equals("true"))
             * {
             *  _log.Warn("Starting in OpenAMQ-1.0d4 compatibility mode. ProtocolMajorVersion is 7 and Basic.Qos will not be sent.");
             *  CURRENT_PROTOCOL_VERSION_MAJOR = 7;
             * }
             */
        }
Ejemplo n.º 22
0
        //efface la ligne en entière
        public static void Delete(string LockType, string LockedValue)
        {
            using (DataBase db = AssemblySettings.getConnection(AssemblySettings.ShCatalog.SecurehWS))
            {
                var sql = @"delete  FROM WebServiceLoginLock 
                           where LockType=@LockType and LockedValue=@LockedValue";

                db.Requete = sql;
                db.addParameter("@LockType", LockType);
                db.addParameter("@LockedValue", LockedValue);

                db.execute_non_query();
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Init Each Element of Collection According to StiLib Configuration, Custom Vision Stimulus Type and Parameters Object
        /// </summary>
        /// <param name="count"></param>
        /// <param name="vstype"></param>
        /// <param name="gd"></param>
        /// <param name="slconfig"></param>
        /// <param name="service"></param>
        /// <param name="path"></param>
        /// <param name="vspara"></param>
        public virtual void Init(int count, VSType vstype, GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, object vspara)
        {
            vsType temp = null;

            try
            {
                switch (vstype)
                {
                case VSType.Bar:
                    temp = new Bar(gd, slconfig, (BarPara)vspara) as vsType;
                    break;

                case VSType.Grating:
                    temp = new Grating(gd, slconfig, service, path, (GratingPara)vspara) as vsType;
                    break;

                case VSType.Image:
                    temp = new Image(gd, slconfig, service, path, (ImagePara)vspara) as vsType;
                    break;

                case VSType.Primitive:
                    temp = new Primitive(gd, slconfig, (PrimitivePara)vspara) as vsType;
                    break;

                case VSType.SLModel:
                    temp = new SLModel(gd, slconfig, service, path, (ModelPara)vspara) as vsType;
                    break;

                case VSType.SLQuad:
                    temp = new SLQuad(gd, slconfig, service, path, (Quad)vspara) as vsType;
                    break;

                case VSType.SLVideo:
                    temp = new SLVideo(gd, slconfig, service, path, (VideoPara)vspara) as vsType;
                    break;

                case VSType.Text:
                    temp = new Text(gd, slconfig, service, path, (TextPara)vspara) as vsType;
                    break;
                }

                Init(count, gd, temp);
            }
            catch (Exception e)
            {
                SLConstant.ShowException(e);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Init Using StiLib Configuration File
        /// </summary>
        /// <param name="configfile">empty/null to load default StiLib.dll.config file, otherwise indicate full file path</param>
        public SLGame(string configfile)
        {
            if (string.IsNullOrEmpty(configfile))
            {
                config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
            }
            else
            {
                config = new AssemblySettings(configfile);
            }

            SetSLGame(Convert.ToBoolean(config["isshowcursor"]), Convert.ToBoolean(config["issizable"]));
            SetGraphicsDevice(Convert.ToInt32(config["buffercount"]), Convert.ToInt32(config["width"]), Convert.ToInt32(config["height"]),
                                         Convert.ToInt32(config["refreshrate"]), Convert.ToInt32(config["updaterate"]), Convert.ToBoolean(config["isvsync"]));
            this.gamma = new Vector3(Convert.ToSingle(config["gammaR"]), Convert.ToSingle(config["gammaG"]), Convert.ToSingle(config["gammaB"]));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Init Using StiLib Configuration File
        /// </summary>
        /// <param name="configfile">empty/null to load default StiLib.dll.config file, otherwise indicate full file path</param>
        public SLGame(string configfile)
        {
            if (string.IsNullOrEmpty(configfile))
            {
                config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
            }
            else
            {
                config = new AssemblySettings(configfile);
            }

            SetSLGame(Convert.ToBoolean(config["isshowcursor"]), Convert.ToBoolean(config["issizable"]));
            SetGraphicsDevice(Convert.ToInt32(config["buffercount"]), Convert.ToInt32(config["width"]), Convert.ToInt32(config["height"]),
                              Convert.ToInt32(config["refreshrate"]), Convert.ToInt32(config["updaterate"]), Convert.ToBoolean(config["isvsync"]));
            this.gamma = new Vector3(Convert.ToSingle(config["gammaR"]), Convert.ToSingle(config["gammaG"]), Convert.ToSingle(config["gammaB"]));
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Set SLGame State
 /// </summary>
 /// <param name="isshowcursor"></param>
 /// <param name="issizable"></param>
 public void SetSLGame(bool isshowcursor, bool issizable)
 {
     if (config == null)
     {
         config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
     }
     if (gdm == null)
     {
         gdm                          = new GraphicsDeviceManager(this);
         pp                           = new PresentationParameters();
         input                        = new SLInput();
         freecamera                   = new SLFreeCamera();
         Content.RootDirectory        = config["content"];
         gdm.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(gdm_PreparingDeviceSettings);
     }
     this.IsMouseVisible           = isshowcursor;
     this.Window.AllowUserResizing = issizable;
 }
Ejemplo n.º 27
0
        public int Detect(AssemblySettings asm)
        {
            _asm = asm;
            int d = 0;

            foreach (TypeDef td in asm.Module.GetTypes())
            {
                foreach (MethodDef md in td.Methods)
                {
                    if (!md.HasBody)
                    {
                        continue;
                    }
                    d += ProcessMethod(md);
                }
            }

            return(d);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Set SLForm State
 /// </summary>
 /// <param name="isshowcursor"></param>
 /// <param name="isborder"></param>
 /// <param name="issizable"></param>
 public void SetSLForm(bool isshowcursor, bool isborder, bool issizable)
 {
     if (config == null)
     {
         config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
     }
     if (services == null)
     {
         services = new ServiceContainer();
         // Register the service, so components like ContentManager can find it.
         services.AddService <IGraphicsDeviceService>(this);
         cm = new ContentManager(services, config["content"]);
         // Hook the idle event to constantly redraw, getting a game style loop as default.
         Application.Idle += delegate { Invalidate(); };
         this.KeyDown     += new KeyEventHandler(SLForm_KeyDown);
         this.MouseDown   += new MouseEventHandler(SLForm_MouseDown);
         this.MouseMove   += new MouseEventHandler(SLForm_MouseMove);
         this.MouseWheel  += new MouseEventHandler(SLForm_MouseWheel);
     }
     // Cursor State
     if (!isshowcursor)
     {
         Cursor.Hide();
     }
     // Border and Sizable States
     if (isborder)
     {
         if (issizable)
         {
             this.Resize += new EventHandler(SLForm_Resize);
         }
         else
         {
             this.MaximizeBox     = false;
             this.FormBorderStyle = FormBorderStyle.FixedSingle;
         }
     }
     else
     {
         this.FormBorderStyle = FormBorderStyle.None;
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Init Using StiLib Configuration File
        /// </summary>
        /// <param name="configfile">empty/null to load default StiLib.dll.config file, otherwise indicate full file path</param>
        public SLForm(string configfile)
        {
            if (string.IsNullOrEmpty(configfile))
            {
                config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
            }
            else
            {
                config = new AssemblySettings(configfile);
            }

            SetGraphicsDevice(Convert.ToInt32(config["buffercount"]), Convert.ToInt32(config["width"]), Convert.ToInt32(config["height"]), Convert.ToInt32(config["refreshrate"]), Convert.ToBoolean(config["isvsync"]));
            SetGamma(new Vector3(Convert.ToSingle(config["gammaR"]), Convert.ToSingle(config["gammaG"]), Convert.ToSingle(config["gammaB"])));
            SetSLForm(Convert.ToBoolean(config["isshowcursor"]), Convert.ToBoolean(config["isborder"]), Convert.ToBoolean(config["issizable"]));

            // Give derived classes a chance to load content.
            LoadContent();
            // Give derived classes a chance to initialize themselves.
            Initialize();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Init Using StiLib Configuration File
        /// </summary>
        /// <param name="configfile">empty/null to load default StiLib.dll.config file, otherwise indicate full file path</param>
        public SLForm(string configfile)
        {
            if (string.IsNullOrEmpty(configfile))
            {
                config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
            }
            else
            {
                config = new AssemblySettings(configfile);
            }

            SetGraphicsDevice(Convert.ToInt32(config["buffercount"]), Convert.ToInt32(config["width"]), Convert.ToInt32(config["height"]), Convert.ToInt32(config["refreshrate"]), Convert.ToBoolean(config["isvsync"]));
            SetGamma(new Vector3(Convert.ToSingle(config["gammaR"]), Convert.ToSingle(config["gammaG"]), Convert.ToSingle(config["gammaB"])));
            SetSLForm(Convert.ToBoolean(config["isshowcursor"]), Convert.ToBoolean(config["isborder"]), Convert.ToBoolean(config["issizable"]));

            // Give derived classes a chance to load content.
            LoadContent();
            // Give derived classes a chance to initialize themselves.
            Initialize();
        }
Ejemplo n.º 31
0
        static void ProcessAssembly(AppSettings config, Type rootType, AssemblySettings settings)
        {
            var ignoredTypes = new HashSet <string>(settings.IgnoredTypes ?? new string[0]);

            if (config.TemplateBasedAssemblies?.IgnoredTypes?.Length > 0)
            {
                foreach (string it in config.TemplateBasedAssemblies.IgnoredTypes)
                {
                    ignoredTypes.Add(it);
                }
            }
            string assemblyPath = GetAssemblyPath(config.RootAssemblyPath, settings.Path);
            var    assembly     = LoadAssembly(assemblyPath, !config.UseCustomAssemblyResolver);
            var    types        = from t in assembly.GetTypes()
                                  where t.IsPublic && t.IsSubclassOf(rootType) && !ignoredTypes.Contains(t.FullName)
                                  select t;

            foreach (var type in types)
            {
                ProcessType(config, type);
            }
        }
Ejemplo n.º 32
0
        public static int SigDetection(this byte[] array, AssemblySettings _asm, string type)
        {
            string singular = type;

            if (type.EndsWith("s"))
            {
                singular = type.Remove(type.Length - 2);
            }
            int d = 0;

            // GZip
            if (array[0] == 0x1f && array[1] == 0x8b)
            {
                _asm.AddDetection(type, new Reason(type, singular + " has GZip magic number. Could be malicious packed content."));
                d++;
            }
            // Pkzip .zip
            if (array[0] == 0x50 && array[1] == 0x4b && array[2] == 0x03 && array[3] == 0x04)
            {
                _asm.AddDetection(type, new Reason(type, singular + " has PKZip magic number. Could be malicious packed content."));
                d++;
            }
            // Rar
            if (array[0] == 0x52 && array[1] == 0x61 && array[2] == 0x72 && array[3] == 0x21 && array[4] == 0x1A && array[5] == 0x07 && array[6] == 0x00)
            {
                _asm.AddDetection(type, new Reason(type, singular + " has RAR magic number. Could be malicious packed content."));
                d++;
            }
            // Exe
            if (array[0] == 0x4D && array[1] == 0x5A)
            {
                _asm.AddDetection(type, new Reason(type, singular + " has EXE magic number. Could be malicious content."));
                d++;
            }
            return(d);
        }
Ejemplo n.º 33
0
        // récupère la l'ensemble des champs de la table WebServiceLoginLock
        public static List <LoginLock> GetLockList()
        {
            List <LoginLock> outList1 = new List <LoginLock>();

            using (DataBase db = AssemblySettings.getConnection(AssemblySettings.ShCatalog.SecurehWS))
            {
                var sql = @"select LockType, LockedValue, LockExpiration FROM WebServiceLoginLock ";

                db.Requete = sql;

                db.execute_reader();
                while (db.NextLine())
                {
                    var Type       = db.GetDataOrDefault <string>("LockType");
                    var Value      = db.GetDataOrDefault <string>("LockedValue");
                    var Expiration = db.GetDataOrDefault <DateTime>("LockExpiration");

                    LoginLock tr1 = new LoginLock(Type, Value, Expiration);

                    outList1.Add(tr1);
                }
            }
            return(outList1);
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Init with Custom ModelPara and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="modelpara"></param>
 public SLModel(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, ModelPara modelpara)
     : base(gd, slconfig)
 {
     Para = modelpara;
     LoadContent(service, path, modelpara.modelname);
     Init(gd);
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Set SLForm State
 /// </summary>
 /// <param name="isshowcursor"></param>
 /// <param name="isborder"></param>
 /// <param name="issizable"></param>
 public void SetSLForm(bool isshowcursor, bool isborder, bool issizable)
 {
     if (config == null)
     {
         config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
     }
     if (services == null)
     {
         services = new ServiceContainer();
         // Register the service, so components like ContentManager can find it.
         services.AddService<IGraphicsDeviceService>(this);
         cm = new ContentManager(services, config["content"]);
         // Hook the idle event to constantly redraw, getting a game style loop as default.
         Application.Idle += delegate { Invalidate(); };
         this.KeyDown += new KeyEventHandler(SLForm_KeyDown);
         this.MouseDown += new MouseEventHandler(SLForm_MouseDown);
         this.MouseMove += new MouseEventHandler(SLForm_MouseMove);
         this.MouseWheel += new MouseEventHandler(SLForm_MouseWheel);
     }
     // Cursor State
     if (!isshowcursor)
     {
         Cursor.Hide();
     }
     // Border and Sizable States
     if (isborder)
     {
         if (issizable)
         {
             this.Resize += new EventHandler(SLForm_Resize);
         }
         else
         {
             this.MaximizeBox = false;
             this.FormBorderStyle = FormBorderStyle.FixedSingle;
         }
     }
     else
     {
         this.FormBorderStyle = FormBorderStyle.None;
     }
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Init with Custom VideoPara and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="videopara"></param>
 public SLVideo(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, VideoPara videopara)
     : base(gd, slconfig)
 {
     Para = videopara;
     LoadContent(service, path, videopara.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Init SLQuad with Custom Quad Parameters and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="quad"></param>
 public SLQuad(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, Quad quad)
     : base(gd, slconfig)
 {
     Para = quad;
     LoadContent(service, path, quad.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Initialize Vision Stimulus Using StiLib Configuration File, Current GraphicsDevice Fullscreen Resolution and Viewport, 
 /// and Default Settings -- Unit: Deg and Set Internal GraphicsDevice Reference
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 public VisionStimulus(GraphicsDevice gd, AssemblySettings slconfig)
     : this(Convert.ToSingle(slconfig["distance2display"]), Convert.ToSingle(slconfig["displayratio"]), Convert.ToSingle(slconfig["displaysize"]), gd.DisplayMode.Width, gd.DisplayMode.Height, new SLCamera(gd), Unit.Deg)
 {
     gdRef = gd;
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Initialize Vision Stimulus Using StiLib Configuration File, 
 /// and Default Settings -- Fullscreen_w_pixel: 800, Fullscreen_h_pixel: 600, Camera: Default, Unit: Deg
 /// </summary>
 /// <param name="slconfig"></param>
 public VisionStimulus(AssemblySettings slconfig)
     : this(Convert.ToSingle(slconfig["distance2display"]), Convert.ToSingle(slconfig["displayratio"]), Convert.ToSingle(slconfig["displaysize"]), 800, 600, new SLCamera(), Unit.Deg)
 {
 }
Ejemplo n.º 40
0
Archivo: Bar.cs Proyecto: babaq/StiLib
 /// <summary>
 /// Init Bar with Custom BarPara and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="barpara"></param>
 public Bar(GraphicsDevice gd, AssemblySettings slconfig, BarPara barpara)
     : base(gd, slconfig)
 {
     Para = barpara;
     Init(gd);
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Init with Custom ImagePara and StiLib Configuration
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="imagepara"></param>
 public Image(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, ImagePara imagepara)
     : base(gd, slconfig)
 {
     Para = imagepara;
     LoadContent(service, path, Para.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 42
0
 /// <summary>
 /// Set SLGame State
 /// </summary>
 /// <param name="isshowcursor"></param>
 /// <param name="issizable"></param>
 public void SetSLGame(bool isshowcursor, bool issizable)
 {
     if (config == null)
     {
         config = new AssemblySettings(Assembly.GetAssembly(typeof(AssemblySettings)));
     }
     if (gdm == null)
     {
         gdm = new GraphicsDeviceManager(this);
         pp = new PresentationParameters();
         input = new SLInput();
         freecamera = new SLFreeCamera();
         Content.RootDirectory = config["content"];
         gdm.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(gdm_PreparingDeviceSettings);
     }
     this.IsMouseVisible = isshowcursor;
     this.Window.AllowUserResizing = issizable;
 }
Ejemplo n.º 43
0
Archivo: Text.cs Proyecto: babaq/StiLib
 /// <summary>
 /// Init with Custom TextPara and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="service"></param>
 /// <param name="path"></param>
 /// <param name="textpara"></param>
 public Text(GraphicsDevice gd, AssemblySettings slconfig, IServiceProvider service, string path, TextPara textpara)
     : base(gd, slconfig)
 {
     Para = textpara;
     LoadContent(service, path, textpara.BasePara.contentname);
     Init(gd);
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Set Internal GraphicsDevice Reference,
 /// and Initialize Vision Stimulus Configuration According to StiLib Configuration File, 
 /// Current GraphicsDevice Fullscreen Resolution and Viewport. 
 /// This method needs to be called before any derived stimulus initialization.
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 public void InitVS(GraphicsDevice gd, AssemblySettings slconfig)
 {
     gdRef = gd;
     InitVS(Convert.ToSingle(slconfig["distance2display"]), Convert.ToSingle(slconfig["displayratio"]), Convert.ToSingle(slconfig["displaysize"]), gd.DisplayMode.Width, gd.DisplayMode.Height, globalCamera.Clone(gd) as SLCamera, unit);
 }
Ejemplo n.º 45
0
 /// <summary>
 /// Init with Custom PrimitivePara and StiLib Configuration File
 /// </summary>
 /// <param name="gd"></param>
 /// <param name="slconfig"></param>
 /// <param name="primitivepara"></param>
 public Primitive(GraphicsDevice gd, AssemblySettings slconfig, PrimitivePara primitivepara)
     : base(gd, slconfig)
 {
     Para = primitivepara;
     Init(gd);
 }