public JCaptureDevice GatherNetworkDeviceInfo() { CaptureDeviceList devices = CaptureDeviceHelpers.FindCaptureDevices(); foreach (var dev in devices) { string deviceDescription = dev.ToString().Replace(" ", ""); string deviceIpAddress = NetworkRegularExpressions.GetIpAddressString(deviceDescription); //Select the NIC if (IPHelpers.IpIsInOurSubnet(deviceIpAddress)) { string macAddress = NetworkRegularExpressions.GetMatchString(deviceDescription); JCaptureDevice jDev = new JCaptureDevice { CaptureDevice = dev, OurIpAddress = IPHelpers.GetIpAddress(deviceDescription), GatewayIpAddess = IPHelpers.GetGatewayIp(deviceDescription), SubnetMask = IPHelpers.GetNetMask(deviceDescription), OurMacAddress = new PhysicalAddress(macAddress.Split(':').Select(x => Convert.ToByte(x, 16)).ToArray()) }; return(jDev); } } return(null); }
public bool ValidateTargets(IWin32Window owner, string ipTxtBoxTxt, string macTxtBoxTxt, JCaptureDevice device) { if (string.IsNullOrEmpty(ipTxtBoxTxt) || string.IsNullOrEmpty(macTxtBoxTxt)) { MessageBox.Show(owner, "Please enter values into both IP and MAC text boxes before sending JArps", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else if (ipTxtBoxTxt.Equals(device.OurIpAddress.ToString()) || macTxtBoxTxt.Equals(device.OurMacAddress.ToString())) { MessageBox.Show(owner, "Don't target your own device.The values shown are supposed to be an example\n\nScan for targets first", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); }