コード例 #1
0
ファイル: ArpDosSender.cs プロジェクト: bmuthoga/dipw
        //constructors
        public ArpDosSender(LivePacketDevice device, Target Gateway)
        {
            _device     = device;
            _gateway    = Gateway;
            _ownMacAddr = _device.GetMacAddress();

            _bgWorker = new BackgroundWorker();
            _bgWorker.WorkerSupportsCancellation = true;
            _bgWorker.DoWork += new DoWorkEventHandler(DoWork);

            _targets = new List <Target>();
        }
コード例 #2
0
ファイル: PlayerForm.cs プロジェクト: mosesyap/Player
 private string GetMac(LivePacketDevice device)
 {
     try
     {
         var mac = device.GetMacAddress();
         return(mac.ToString());
     }
     catch
     {
         return(null);
     }
 }
コード例 #3
0
ファイル: ARPSender.cs プロジェクト: bmuthoga/dipw
        //methods
        public void ScanAddresses()
        {
            _ownMacAddrByte = _device.GetNetworkInterface().GetPhysicalAddress().GetAddressBytes();
            _ownMacAddr     = _device.GetMacAddress();
            _ownIpAddrByte  = _device.getIpAddressBytes();

            if (!_bgWorker.IsBusy)
            {
                _bgWorker.RunWorkerAsync();
            }
            else
            {
                throw new Exception("Scanning is still ongoing, cannot start another scan!");
            }
        }
コード例 #4
0
ファイル: ArpPoisoner.cs プロジェクト: bmuthoga/dipw
        //constructors
        public ArpPoisoner(LivePacketDevice device, Target Gateway)
        {
            _device     = device;
            _gateway    = Gateway;
            _ownMacAddr = _device.GetMacAddress();

            _bgWorker = new BackgroundWorker();
            _bgWorker.WorkerSupportsCancellation = true;
            _bgWorker.DoWork += new DoWorkEventHandler(DoWork);

            _targets         = new List <Target>();
            _dnsSpoofingList = new DNSspoofingList();

            _forwardingListener = new Listener.Listener(device, "ip and ( udp or tcp) and ether dst " + _ownMacAddr.ToString() +
                                                        " and not host " + _device.getIpV4Address().Address.ToString());
            _forwardingListener.StartCapture(Forwarder);
        }
コード例 #5
0
        public PacketInject(LivePacketDevice selectedDevice)
        {
            InitializeComponent();
            this.selectedDevice = selectedDevice;
            this.sourceMac      = selectedDevice.GetMacAddress();
            this.gatewayAddy    = selectedDevice.GetNetworkInterface().GetIPProperties().GatewayAddresses[0].Address;
            this.destMac        = new MacAddress(GetMacAddress(gatewayAddy).ToString());
            this.count          = 0;
            this.timer          = new Timer();
            if (selectedDevice == null)
            {
                Visible = false;
                MessageBox.Show("Must select a network interface first!");
                Close();
            }
            else
            {
                Visible = true;
            }

            radPSH.Checked = true;
        }
コード例 #6
0
        public static PacketCommunicator OpenLiveDevice()
        {
            NetworkInterface networkInterface =
                NetworkInterface.GetAllNetworkInterfaces().FirstOrDefault(
                    ni => !ni.IsReceiveOnly && ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet && ni.OperationalStatus == OperationalStatus.Up);
            LivePacketDevice device = networkInterface.GetLivePacketDevice();

            MoreAssert.IsMatch(@"Network adapter '.*' on local host", device.Description);
            Assert.AreEqual(DeviceAttributes.None, device.Attributes);
            Assert.AreNotEqual(MacAddress.Zero, device.GetMacAddress());
            Assert.AreNotEqual(string.Empty, device.GetPnpDeviceId());
            MoreAssert.IsBiggerOrEqual(1, device.Addresses.Count);
            foreach (DeviceAddress address in device.Addresses)
            {
                if (address.Address.Family == SocketAddressFamily.Internet)
                {
                    MoreAssert.IsMatch("Address: " + SocketAddressFamily.Internet + @" [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ " +
                                       "Netmask: " + SocketAddressFamily.Internet + @" 255\.[0-9]+\.[0-9]+\.[0-9]+ " +
                                       "Broadcast: " + SocketAddressFamily.Internet + @" 255.255.255.255",
                                       address.ToString());
                }
                else
                {
                    Assert.AreEqual(SocketAddressFamily.Internet6, address.Address.Family);
                    MoreAssert.IsMatch("Address: " + SocketAddressFamily.Internet6 + @" (?:[0-9A-F]{4}:){7}[0-9A-F]{4} " +
                                       "Netmask: " + SocketAddressFamily.Unspecified + @" " + IpV6Address.Zero + " " +
                                       "Broadcast: " + SocketAddressFamily.Unspecified + @" " + IpV6Address.Zero,
                                       address.ToString());
                }
            }

            PacketCommunicator communicator = device.Open();

            try
            {
                MoreAssert.AreSequenceEqual(new[] { DataLinkKind.Ethernet, DataLinkKind.Docsis }.Select(kind => new PcapDataLink(kind)), communicator.SupportedDataLinks);
                PacketTotalStatistics totalStatistics = communicator.TotalStatistics;
                Assert.AreEqual <object>(totalStatistics, totalStatistics);
                Assert.AreNotEqual(null, totalStatistics);
                Assert.AreEqual(totalStatistics.GetHashCode(), totalStatistics.GetHashCode());
                Assert.IsTrue(totalStatistics.Equals(totalStatistics));
                Assert.IsFalse(totalStatistics.Equals(null));
                Assert.AreNotEqual(null, totalStatistics);
                Assert.AreNotEqual(totalStatistics, 2);
                MoreAssert.IsSmallerOrEqual <uint>(1, totalStatistics.PacketsCaptured, "PacketsCaptured");
                Assert.AreEqual <uint>(0, totalStatistics.PacketsDroppedByDriver, "PacketsDroppedByDriver");
                Assert.AreEqual <uint>(0, totalStatistics.PacketsDroppedByInterface, "PacketsDroppedByInterface");
                MoreAssert.IsSmallerOrEqual <uint>(1, totalStatistics.PacketsReceived, "PacketsReceived");
                Assert.IsNotNull(totalStatistics.ToString());
                communicator.SetKernelBufferSize(2 * 1024 * 1024); // 2 MB instead of 1
                communicator.SetKernelMinimumBytesToCopy(10);      // 10 bytes minimum to copy
                communicator.SetSamplingMethod(new SamplingMethodNone());
                Assert.AreEqual(DataLinkKind.Ethernet, communicator.DataLink.Kind);
                communicator.DataLink = communicator.DataLink;
                Assert.AreEqual("EN10MB (Ethernet)", communicator.DataLink.ToString());
                Assert.AreEqual(communicator.DataLink, new PcapDataLink(communicator.DataLink.Name));
                Assert.IsTrue(communicator.IsFileSystemByteOrder);
                Assert.AreEqual(PacketCommunicatorMode.Capture, communicator.Mode);
                Assert.IsFalse(communicator.NonBlocking);
                Assert.AreEqual(PacketDevice.DefaultSnapshotLength, communicator.SnapshotLength);
                return(communicator);
            }
            catch (Exception)
            {
                communicator.Dispose();
                throw;
            }
        }
コード例 #7
-1
ファイル: ArpDosSender.cs プロジェクト: bmuthoga/dipw
        //constructors
        public ArpDosSender(LivePacketDevice device, Target Gateway)
        {
            _device = device;
            _gateway = Gateway;
            _ownMacAddr = _device.GetMacAddress();

            _bgWorker = new BackgroundWorker();
            _bgWorker.WorkerSupportsCancellation = true;
            _bgWorker.DoWork += new DoWorkEventHandler(DoWork);

            _targets = new List<Target>();
        }
コード例 #8
-1
ファイル: ArpPoisoner.cs プロジェクト: bmuthoga/dipw
        //constructors
        public ArpPoisoner(LivePacketDevice device, Target Gateway)
        {
            _device = device;
            _gateway = Gateway;
            _ownMacAddr = _device.GetMacAddress();

            _bgWorker = new BackgroundWorker();
            _bgWorker.WorkerSupportsCancellation = true;
            _bgWorker.DoWork += new DoWorkEventHandler(DoWork);

            _targets = new List<Target>();
            _dnsSpoofingList = new DNSspoofingList();

            _forwardingListener = new Listener.Listener(device, "ip and ( udp or tcp) and ether dst " + _ownMacAddr.ToString() +
                " and not host " + _device.getIpV4Address().Address.ToString());
            _forwardingListener.StartCapture(Forwarder);
        }