Tag: sharppcap

C#

Create your own ARP packet using SharpPcap

SharpPcap library project EthernetPacket MakeArpRequest( PhysicalAddress InterfaceMacAddress, IPAddress destinationIP, IPAddress senderIP) { try { PhysicalAddress fakeBroadcastMAC = PhysicalAddress.Parse("FFFFFFFFFFFF");   EthernetPacket ethernetpacket = new EthernetPacket(InterfaceMacAddress, fakeBroadcastMAC, EthernetPacketType.Arp);   ARPPacket arppacket = new ARPPacket(ARPOperation.Request, fakeBroadcastMAC, destinationIP, InterfaceMacAddress, senderIP);   ethernetpacket.PayloadPacket = arppacket;   return ethernetpacket; } catch { return null; } }EthernetPacket MakeArpRequest( PhysicalAddress InterfaceMacAddress, IPAddress destinationIP, …

C#

Obtain devices list with SharpPcap

SharpPcap is a cross-platform packet capture framework for the .NET environment, based on the famous pcap / WinPcap libraries. It provides an API for capturing, injecting, analyzing and building packets using any .NET language such as C# and VB.NET.   CaptureDeviceList cdevices = CaptureDeviceList.Instance; if (cdevices.Count >= 1) { foreach (ICaptureDevice dev in cdevices) { …