dotpcap / sharppcap

Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets
1.33k stars 268 forks source link

System.EntryPointNotFoundException pcap_findalldevs_ex #60

Closed Fox4148 closed 5 years ago

Fox4148 commented 5 years ago

My runtime env. is kali-linux 2.x with mono, I'm currently making sure everything is up to date prior to leave this open, if you see it open I did not manage to solve it.

I mean I could map the function to the correct one inside libpcap.so but I don't know the right one and did not found relevant documentation on it.

Got the error by trying the code

var devices = AirPcapDeviceList.Instance;

Everytime I step over this line exception is thrown, I have winpcap lib referenced

System.EntryPointNotFoundException: pcap_findalldevs_ex at at (wrapper managed-to-native) SharpPcap.WinPcap.SafeNativeMethods.pcap_findalldevs_ex(string,intptr,intptr&,System.Text.StringBuilder) at SharpPcap.WinPcap.WinPcapDeviceList.Devices (System.String rpcapString, SharpPcap.WinPcap.RemoteAuthentication remoteAuthentication) [0x00031] in /root/_repo/sharppcap/SharpPcap/WinPcap/WinPcapDeviceList.cs:123 at SharpPcap.WinPcap.WinPcapDeviceList.GetDevices () [0x00007] in /root/_repo/sharppcap/SharpPcap/WinPcap/WinPcapDeviceList.cs:170 at SharpPcap.WinPcap.WinPcapDeviceList.Refresh () [0x0000f] in /root/_repo/sharppcap/SharpPcap/WinPcap/WinPcapDeviceList.cs:181 at SharpPcap.WinPcap.WinPcapDeviceList..ctor () [0x0000d] in /root/_repo/sharppcap/SharpPcap/WinPcap/WinPcapDeviceList.cs:77 at SharpPcap.WinPcap.WinPcapDeviceList.get_Instance () [0x0000e] in /root/_repo/sharppcap/SharpPcap/WinPcap/WinPcapDeviceList.cs:51 at SharpPcap.AirPcap.AirPcapDeviceList.Refresh () [0x0000f] in /root/_repo/sharppcap/SharpPcap/AirPcap/AirPcapDeviceList.cs:106 at SharpPcap.AirPcap.AirPcapDeviceList..ctor () [0x0000d] in /root/_repo/sharppcap/SharpPcap/AirPcap/AirPcapDeviceList.cs:72 at SharpPcap.AirPcap.AirPcapDeviceList.get_Instance () [0x0000e] in /root/_repo/sharppcap/SharpPcap/AirPcap/AirPcapDeviceList.cs:45 at mitmp.MainClass.Main (System.String[] args) [0x00001] in /root/_repo/mitmp/Program.cs:14

Fox4148 commented 5 years ago

I did not manage to solve, impossible to me to use AirPcap, I am however able to use Libpcap freely. The only other issue I have is that I am not able to cast a WinPcap device

The more I think about it, and probably mono users should abstain from using any other lib than Libpcap, even with the mapping I have trouble with some functions.

lextm commented 5 years ago

The namespace AirPcap and WinPcap should be Windows only, so you should avoid using them on non-Windows platforms. The basic functionality based on libpcap should work though.

chmorgan commented 5 years ago

Hi @Fox4148. Do you have airpcap hardware? The product was discontinued by Riverbed a year or more ago. I'm actually thinking we should remove airpcap support from sharppcap given that there isn't hardware for it anymore. Any reason to keep it? If so please open this back up so I know not to remove it.