Beispiel #1
0
        public void ScanDhcp(CaptureEventArgs e, string Interface)
        {
            var mypacket = Packet.ParsePacket(e.Packet.LinkLayerType, e.Packet.Data);
            var udp      = (UdpPacket)mypacket.Extract(typeof(UdpPacket));

            if (udp != null)
            {
                if (udp.DestinationPort == 68)
                {
                    var       DestinationHwAddress = EthernetPacket.GetEncapsulated(mypacket).DestinationHwAddress;
                    var       SourceHwAddress      = EthernetPacket.GetEncapsulated(mypacket).SourceHwAddress;
                    var       DestinationipAddress = IpPacket.GetEncapsulated(mypacket).DestinationAddress;
                    var       SourceipAddress      = IpPacket.GetEncapsulated(mypacket).SourceAddress;
                    ado       a  = new ado();
                    DataTable dt = a.selectmac(SourceHwAddress.ToString(), Interface);
                    // if mac address of router excist that mean he is router
                    if (dt.Rows.Count > 0)
                    {
                        Attack = false;
                    }
                    else
                    {
                        Attack         = true;
                        Attack_data[0] = "DHCP spofing";
                        Attack_data[1] = SourceipAddress.ToString();
                        Attack_data[2] = SourceHwAddress.ToString();
                        Attack_data[3] = DateTime.Now.ToShortTimeString();
                    }
                }
            }
        }