private void GetTargetMacButtonClick(object sender, RoutedEventArgs e) { string a; try { a = DosController.GetMacFromIp(TargetIpAddress.Text).ToString(); } catch (Exception exception) { MessageBox.Show(exception.Message, "Packet Cannon", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (a == "00:00:00:00:00:00") { if (DosController.PingAddress(TargetIpAddress.Text)) { TargetMacAddress.Text = DosController.GetMacFromIp(DosController.GetDefaultGateway().ToString()).ToString(); return; } MessageBox.Show("INVALID IP ADDRESS GIVEN", "Packet Cannon", MessageBoxButton.OK, MessageBoxImage.Error); } else { TargetMacAddress.Text = a; } }
public static MacAddress GetMacFromIp(string ipAdress) { var hostIpAddress = IPAddress.Parse(ipAdress); var ab = new byte[6]; int len = ab.Length, r = DosController.SendARP((int)hostIpAddress.Address, srcIp: 0, pMacAddr: ab, phyAddrLen: ref len); return(new MacAddress(BitConverter.ToString(ab, 0, 6).Replace("-", ":"))); }
public MainWindow() { this.Dispatcher.UnhandledException += OnDispatcherUnhandledException; Setup = new DosController(); InitializeComponent(); this.DataContext = Setup; ResetAllAdditionalSettingsFields(); ShutdownMode = ShutdownMode.OnLastWindowClose; }