示例#1
0
        static void Main(string[] args)
        {
            ConsoleStyle style = new ConsoleStyle();

            style.StyleChanger("creator");
            Console.WriteLine("Hello, this is my IP range checker \n Please, write your ip-range :");
            style.StyleChanger("");
            string ip_range = Console.ReadLine();


            style.StyleChanger("creator");
            Console.WriteLine("Write your your treads: ");
            style.StyleChanger("");
            Ip_Object.trheadsCount = Convert.ToInt32(Console.ReadLine());



            style.StyleChanger("creator");
            Console.WriteLine("Write your port and we'll start : ");
            style.StyleChanger("");
            int port = Convert.ToInt32(Console.ReadLine());

            style.StyleChanger("creator");

            Console.WriteLine("Put key S to stop or ESC to exit");
            style.StyleChanger("");
            Console.WriteLine("We started!");
            style.StyleChanger("creator");
            string[]  ind = ip_range.Split('-').ToArray();
            Ip_Object ip  = new Ip_Object(ind[0], ind[1], port);



            ConsoleKeyInfo key = new ConsoleKeyInfo();

            do
            {
                key = Console.ReadKey();
                Console.WriteLine("- is not Comand Key \n Put key ESC to exit");
            }while (key.Key != ConsoleKey.Escape);
        }
示例#2
0
        async void rangeChecker(byte[] startIP, byte[] endIP)
        {
            await(Task.Run(() =>
            {
                int count = 0;
                while (startIP[0] != endIP[0] || startIP[1] != endIP[1] || startIP[2] != endIP[2] || startIP[3] != endIP[3])
                {
                    if (startIP[3] != 255)
                    {
                        startIP[3]++;
                    }
                    else
                    {
                        if (startIP[2] != 255)
                        {
                            startIP[2]++;
                        }
                        else
                        {
                            if (startIP[1] != 255)
                            {
                                startIP[1]++;
                            }
                            else
                            {
                                if (startIP[0] != 255)
                                {
                                    startIP[2]++;
                                }
                                else
                                {
                                    break;
                                }
                                startIP[1] = 0;
                            }
                            startIP[2] = 0;
                        }
                        startIP[3] = 0;
                    }
                    string current = (startIP[0] + "." + startIP[1] + "." + startIP[2] + "." + startIP[3]);
                    Console.WriteLine(startIP[0] + "." + startIP[1] + "." + startIP[2] + "." + startIP[3]);
                    while (threadsIsUsed == trheadsCount)
                    {
                    }
                    ;
                    threadsIsUsed++;
                    Thread myThread = new Thread(
                        () =>
                    {
                        CheckPortConection(current, this.port);
                    }
                        );

                    myThread.Start();
                    count++;
                }
                Console.ForegroundColor = ConsoleColor.Black;
                Console.BackgroundColor = ConsoleColor.Blue;
                Console.WriteLine(" /n         Creating txt file ...      /n    ");
                File.WriteAllLines("good.txt", Good);
                cs.StyleChanger("creator");
                Console.WriteLine("Checked IPs : " + count);
                //Создадим текстовый документ
            }));
        }