Esempio n. 1
0
        private static void RunScan(IEnumerable <string> range, IPhelper ipHelper)
        {
            //using (countdown = new CountdownEvent(1))
            //{
            foreach (string ip in range)
            {
                if (ipHelper.Ping(ip))
                {
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    _writter.WriteLine($"Starting scan for IP: {ip} @ {DateTime.Now:yyyy.MM.dd HH:mm:sss}");
                    //countdown.TryAddCount();

                    using (PortScanner pScanner = new PortScanner(ip, StartPort, EndPort, _writter))
                    {
                        pScanner.StartWork(_maxThread);
                    }
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    _writter.WriteLine($"Host {ip} is not active @ {DateTime.Now:yyyy.MM.dd HH:mm:sss}");
                }
            }

            //    while (countdown.Signal())
            //    {
            //        countdown.Wait();
            //    }
            //}
        }
Esempio n. 2
0
        private static void RunScanParallel(IEnumerable <string> range, IPhelper ipHelper)
        {
            //using (countdown = new CountdownEvent(1))
            //{
            Parallel.ForEach(range, ip =>
            {
                if (ipHelper.Ping(ip))
                {
                    //countdown.TryAddCount();
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    _writter.WriteLine($"Starting scan for IP: {ip} @ {DateTime.Now:yyyy.MM.dd HH:mm:sss}");

                    PortScanner pScanner = new PortScanner(ip, StartPort, EndPort, _writter);
                    pScanner.StartWork(_maxThread);
                }