Exemple #1
0
        void CreatePlugin()
        {
            if (this.Payloads.Count > this.MaxCountForPayloadsList)
            {
                SavePayloadsToFile();
            }
            string[] PluginCodes = CreatePluginCode();
            string   PyCode      = PluginCodes[0];
            string   RbCode      = PluginCodes[1];

            string PluginCode = PyCode;

            string PluginLang = "py";

            if (PluginLangRubyRB.Checked)
            {
                PluginCode = RbCode;
                PluginLang = "rb";
            }

            bool   PluginCreated = false;
            int    Counter       = 0;
            string FFN           = "";

            while (!PluginCreated)
            {
                string FN = "";
                if (Counter == 0)
                {
                    FN = string.Format("{0}.{1}", PluginName, PluginLang);
                }
                else
                {
                    FN = string.Format("{0}_{1}.{2}", PluginName, Counter, PluginLang);
                }
                FFN = string.Format("{0}\\plugins\\active\\{1}", Config.Path, FN);
                Counter++;
                if (!File.Exists(FFN))
                {
                    File.WriteAllText(FFN, PluginCode);
                    PluginCreated = true;
                    PluginEngine.LoadNewActivePlugins();
                    PluginFileTB.Text = FFN;
                }
            }
        }
Exemple #2
0
        internal static void Check()
        {
            while (On)
            {
                try
                {
                    Session IrSe;
                    lock (CheckRequest)
                    {
                        IrSe = CheckRequest.Dequeue();
                    }
                    if (IrSe != null)
                    {
                        PluginEngine.RunAllRequestBasedOfflinePassivePlugins(IrSe);
                    }
                }
                catch (InvalidOperationException)
                { }
                catch (Exception Exp)
                {
                    IronException.Report("Error Running Offline Plugins on Request", Exp.Message, Exp.StackTrace);
                }

                try
                {
                    Session IrSe;
                    lock (CheckResponse)
                    {
                        IrSe = CheckResponse.Dequeue();
                    }
                    if (IrSe != null)
                    {
                        PluginEngine.RunAllResponseBasedOfflinePassivePlugins(IrSe);
                    }
                }
                catch (InvalidOperationException)
                {
                    Thread.Sleep(500);
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error Running Offline Plugins on Response", Exp.Message, Exp.StackTrace);
                }
            }
        }
Exemple #3
0
 public static void RunAllResponseBasedOfflinePassivePlugins(Session IrSe)
 {
     foreach (string Name in PassivePlugin.List())
     {
         PassivePlugin P = PassivePlugin.Get(Name);
         if ((P.WorksOn == PluginWorksOn.Response) || (P.WorksOn == PluginWorksOn.Both))
         {
             if (P.CallingState == PluginCallingState.Offline)
             {
                 try
                 {
                     PluginEngine.RunPassivePlugin(P, IrSe);
                 }
                 catch (Exception Exp)
                 {
                     IronException.Report("Error executing 'Offline' Passive Plugin : " + Name, Exp.Message, Exp.StackTrace);
                 }
             }
         }
     }
 }
Exemple #4
0
 public static void RunAllRequestBasedInlinePassivePlugins(Session IrSe)
 {
     foreach (string Name in PassivePlugin.GetInLinePluginsForRequest())
     {
         PassivePlugin P = PassivePlugin.Get(Name);
         if ((P.WorksOn == PluginWorksOn.Request) || (P.WorksOn == PluginWorksOn.Both))
         {
             if (P.CallingState == PluginCallingState.Inline)
             {
                 try
                 {
                     PluginEngine.RunPassivePlugin(P, IrSe);
                 }
                 catch (Exception Exp)
                 {
                     IronException.Report("Error executing 'BeforeRequestInterception' Passive Plugin - " + Name, Exp.Message, Exp.StackTrace);
                 }
             }
         }
     }
 }
Exemple #5
0
        internal static Module LoadModule(Module M)
        {
            try
            {
                string FullName = string.Format("{0}\\modules\\{1}\\{2}", Config.RootDir, M.Name, M.FileName);
                if (M.FileName.EndsWith(".dll"))
                {
                    Assembly MA        = System.Reflection.Assembly.LoadFile(FullName);
                    Module   NewModule = (Module)Activator.CreateInstance(MA.GetTypes()[0]);
                    Module.Add(NewModule.GetInstance());
                }
                else
                {
                    Engine = PluginEngine.GetScriptEngine();

                    if (M.FileName.EndsWith(".py"))
                    {
                        Engine.Runtime.TryGetEngine("py", out Engine);
                    }
                    else
                    {
                        Engine.Runtime.TryGetEngine("rb", out Engine);
                    }
                    List <string> ModulePaths = new List <string>();
                    foreach (Module ModuleFromXml in ModuleListFromXml)
                    {
                        ModulePaths.Add(string.Format("{0}\\modules\\{1}\\", Config.RootDir, ModuleFromXml.Name));
                    }
                    Engine.SetSearchPaths(ModulePaths);
                    if (M.FileName.Length == 0)
                    {
                        throw new Exception("Module is missing script files");
                    }
                    ScriptSource        ModuleSource  = Engine.CreateScriptSourceFromFile(FullName);
                    ScriptErrorReporter CompileErrors = new ScriptErrorReporter();
                    string       ErrorMessage         = "";
                    CompiledCode CompiledModule       = ModuleSource.Compile(CompileErrors);
                    ErrorMessage = CompileErrors.GetErrors();
                    if (M.FileName.EndsWith(".py"))
                    {
                        string IndentError = PluginEditor.CheckPythonIndentation(ModuleSource.GetCode())[1];
                        if (IndentError.Length > 0)
                        {
                            ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage);
                        }
                    }
                    if (ErrorMessage.Length == 0)
                    {
                        ModuleSource.ExecuteProgram();
                    }
                    else
                    {
                        throw new Exception(string.Format("Syntax error in module file:{0}\r\n{1}", M.FileName, ErrorMessage));
                    }
                }
            }
            catch (Exception Exp)
            {
                ModuleStartPromptForm PF = GetPromptWindow(M);
                if (PF != null)
                {
                    PF.ShowError("Error Loading Module.");
                }
                IronException.Report(string.Format("Error Loading Module - {0}", M.Name), Exp);
                return(null);
            }
            IronUI.BuildPluginTree();
            ModuleStartPromptForm UsedPF = RemovePromptWindowFromList(M);

            if (UsedPF != null)
            {
                try
                {
                    if (!UsedPF.IsClosed)
                    {
                        UsedPF.CloseForm();
                    }
                }
                catch { }
            }
            return(Get(M.Name));
        }