Example #1
0
        public static void NetworkServiceDiscovery(int computertype, int nhost, int sleep)
        {
            List <Task>     tasklist        = new List <Task>();
            List <Computer> targetcomputers = Lib.Targets.GetHostTargets(computertype, nhost);

            Console.WriteLine("[*] Starting Network Discovery from {0} ", Environment.MachineName);
            if (sleep > 0)
            {
                Console.WriteLine("[*] Sleeping {0} seconds between each scan", sleep);
            }
            foreach (Computer computer in targetcomputers)
            {
                if (!computer.Fqdn.ToUpper().Contains(Environment.MachineName.ToUpper()))
                {
                    Computer temp     = computer;
                    TimeSpan interval = TimeSpan.FromSeconds(5);

                    tasklist.Add(Task.Factory.StartNew(() =>
                    {
                        DiscoveryHelper.PortScan(temp, interval);
                    }));
                    if (sleep > 0)
                    {
                        Thread.Sleep(sleep * 1000);
                    }
                }
            }
            Task.WaitAll(tasklist.ToArray());
        }
Example #2
0
        public static void NetworkServiceDiscovery(int nhost, int tsleep, string log)
        {
            string currentPath = AppDomain.CurrentDomain.BaseDirectory;

            Lib.Logger logger = new Lib.Logger(currentPath + log);
            logger.SimulationHeader("T1046");
            logger.TimestampInfo("Using the System.Net.Sockets .NET namespace to execute this technique");

            try
            {
                var             rand            = new Random();
                int             computertype    = rand.Next(1, 6);
                List <Task>     tasklist        = new List <Task>();
                List <Computer> targetcomputers = Lib.Targets.GetHostTargets(computertype, nhost, logger);
                logger.TimestampInfo(String.Format("Obtained {0} target computers for the scan", targetcomputers.Count));
                if (tsleep > 0)
                {
                    logger.TimestampInfo(String.Format("Sleeping {0} seconds between each network scan", tsleep));
                }
                foreach (Computer computer in targetcomputers)
                {
                    if (!computer.Fqdn.ToUpper().Contains(Environment.MachineName.ToUpper()))
                    {
                        Computer temp     = computer;
                        TimeSpan interval = TimeSpan.FromSeconds(5);

                        tasklist.Add(Task.Factory.StartNew(() =>
                        {
                            logger.TimestampInfo(String.Format("Starting port scan against {0} ({1})", temp.ComputerName, temp.IPv4));
                            DiscoveryHelper.PortScan(temp, interval);
                        }));
                        if (tsleep > 0)
                        {
                            Thread.Sleep(tsleep * 1000);
                        }
                    }
                }
                Task.WaitAll(tasklist.ToArray());
                logger.SimulationFinished();
            }
            catch (Exception ex)
            {
                logger.SimulationFailed(ex);
            }
        }
Example #3
0
        public static void NetworkServiceDiscovery(int computertype, int nhost, int sleep, string log)
        {
            string currentPath = AppDomain.CurrentDomain.BaseDirectory;

            Lib.Logger logger = new Lib.Logger(currentPath + log);
            logger.SimulationHeader("T1046");
            //logger.TimestampInfo(String.Format("Starting T1046 Simulation on {0}", Environment.MachineName));
            //logger.TimestampInfo(String.Format("Simulation agent running as {0} with PID:{1}", System.Reflection.Assembly.GetEntryAssembly().Location, Process.GetCurrentProcess().Id));
            try
            {
                List <Task>     tasklist        = new List <Task>();
                List <Computer> targetcomputers = Lib.Targets.GetHostTargets(computertype, nhost);
                logger.TimestampInfo(String.Format("Obtained {0} target computers for the scan", targetcomputers.Count));
                //Console.WriteLine("[*] Starting Network Discovery from {0} ", Environment.MachineName);
                if (sleep > 0)
                {
                    Console.WriteLine("[*] Sleeping {0} seconds between each scan", sleep);
                }
                foreach (Computer computer in targetcomputers)
                {
                    if (!computer.Fqdn.ToUpper().Contains(Environment.MachineName.ToUpper()))
                    {
                        Computer temp     = computer;
                        TimeSpan interval = TimeSpan.FromSeconds(5);

                        tasklist.Add(Task.Factory.StartNew(() =>
                        {
                            logger.TimestampInfo(String.Format("Starting port scan against {0} ({1})", temp.ComputerName, temp.IPv4));
                            DiscoveryHelper.PortScan(temp, interval);
                        }));
                        if (sleep > 0)
                        {
                            Thread.Sleep(sleep * 1000);
                        }
                    }
                }
                Task.WaitAll(tasklist.ToArray());
                logger.SimulationFinished();
            }
            catch (Exception ex)
            {
                logger.SimulationFailed(ex);
            }
        }