static void Main(string[] args) { // Get a list of all of the IPv4 interfaces on the host, stored as: // { Interface_Display_Name, Interface_IP_Address } Dictionary <string, IPAddress> networkInterfaces = PacketSniffer.GetIpv4NetworkInterfaces(); // Simple way of having the user select the Network Interface / IP Address IPAddress targetIp = PromptUserForNetworkInterface(networkInterfaces); // Create a socket listening to the above IP Address PacketSniffer.CreateSocket(targetIp); // Start sniffer with the specified callback PacketSniffer.StartSniffer(callback); Console.ReadLine(); }
public static void Main(string[] args) { PacketSniffer Foo = new PacketSniffer(); Foo.parseArguments(args); var devices = CaptureDeviceList.Instance; if (!Foo.i) { foreach (var dev in devices) { Console.WriteLine("{0}", dev.Name); } return; } Foo.device = Foo.checkIfDeviceExists(Foo.deviceName, devices); Foo.device.Open(); Foo.device.Filter = Foo.createFilter(); Foo.device.OnPacketArrival += Foo.gotPacket; Foo.device.Capture(); }