示例#1
0
        public static InterfaceData ReturnInterfaceData()
        {
            // Grab only the Network Interfaces that are either wireless OR ethernet and have DHCP enabled.
            var network = NetworkInterface
                          .GetAllNetworkInterfaces()
                          .Where(intf => intf.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
                                 intf.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
                          .Where(interf => interf.GetIPProperties().GetIPv4Properties().IsDhcpEnabled);

            // Loop over all the interfaces to find the one that i'm currently connected to.
            foreach (NetworkInterface enterFace in network)
            {
                var data = enterFace.GetIPProperties();
                if (string.IsNullOrEmpty(data.DnsSuffix)) // noticed that the network you're connected to has a DNSSuffix all other interfaces have nothing.
                {
                    continue;
                }

                //store some data from that interface into an object to be used later.
                InterfaceData interfaceData = new InterfaceData()
                {
                    DnsSuffix            = data.DnsSuffix,
                    DnsAddress           = data.DnsAddresses,
                    IpAddressInformation =
                        data.UnicastAddresses.FirstOrDefault(d => d.Address.AddressFamily == AddressFamily.InterNetwork), //UnicastAddresses has a list of IPAddressInfo. I need just one.
                    MacAddress = enterFace.GetPhysicalAddress()
                };
                return(interfaceData);
            }

            // probably should check if i return null. shouldn't be possible to get null if i'm on the internet though.
            return(null);
        }
示例#2
0
        public FrmSmurf()
        {
            InitializeComponent();
            Instantiations++;
            deviceInfo = Utils.ReturnInterfaceData();
            arpTable   = Utils.GetArpTable();

            //filter the dictionary to only grab the ip/mac of the clients on the same subnet.
            arpTableFiltering();



            // write out some data upon initiliazation.
            txtDnsSuffix.Text = deviceInfo.DnsSuffix;
            txtIp.Text        = deviceInfo.IpAddressInformation.Address.ToString();
            txtMask.Text      = deviceInfo.IpAddressInformation.IPv4Mask.ToString();
            txtClass.Text     = Utils.IdentifyClass(deviceInfo.IpAddressInformation.Address);


            txtMacAddress.Text = MacAddressFormat(deviceInfo.MacAddress);
            cboAttackers.Items.AddRange(arpTable.Keys.ToArray());
        }