-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to activate the adapter (NpcapRemoteCapture Example) #491
Comments
Npcap broke the remote capture support when they took over the WinPcap project, see nmap/npcap#312 and nmap/npcap#74 this is not an issue with sharppcap itself. To use remote pcap, use libpcap (depending on disto, it could be disabled by default), or WinPcap |
Just to get some clarity, is libpcap option usable on Windows platform for this library or is only for Linux platforms? It wasn't clear looking at the README file. I haven't used this library myself so haven't looked through any documentation. Asking as winpcap is kind of deprecated/obsolete with newer versions of Windows? So really users are left with npcap or libpcap. And npcap offers an installer, on Windows I assume user will have to build libpcap from source? And then i'm wondering where might the user have to place or register the built libpcap sources (some DLLs), perhaps under C:\Windows\system32? like packet.dll, assuming that is one of the outputs of libpcap on Windows - because winpcap and ncpap have that. Based on reading https://omnine.blogspot.com/2020/08/wireshark-remote-capture-with-rpcapd.html. |
libpcap is Linux/macos only, Npcap is a commercial port of libpcap, WinPcap is the predecessor of Npcap, and abandoned by its maintainers. Libpcap can be compiled to work on Windows, but then you would only have offline api (read/write pcap), with no network access due to the lack of a driver. |
For anyone interested in this further, and still having issues, I'd be interested how it is working on Wireshark but not here. Because latest Wireshark uses Npcap by default, and remote pcap (client) works there. I'm assuming this issue may go away if user upgrades to a newer or latest npcap version? Per the referenced npcap issue link for client side rpcap, the fix was in npcap v0.9983+, and there was upgrade of libpcap used by npcap in v1.31+. |
Wireshark have its own rpcap imlimentation it does not use libpcap or npcap for remote capture. |
That is... not the case. Wireshark calls |
The 1.10 branch of libpcap supports:
The main branch has dropped support for many of the code-rotted platforms.
...based on the most recent 1.10.x release of libpcap.
...and has never been updated to a recent version of libpcap (and "abandoned by its maintainers" means it almost certainly will never be updated).
Unless you install WinPcap and the WinPcap SDK, or Npcap and the Npcap SDK, and configure and build libpcap as described above. |
For compiling libpcap without Npcap/WinPcap, look at the conan recipe of libpcap https://github.com/conan-io/conan-center-index/blob/master/recipes/libpcap/all/conanfile.py there is no sdk steps involved there. For wireshark, it could have been that I was looking at the wrong files. It could be that client support was fixed since I last tested npcap, if it's working in wireshark then it should also work in sharppcap. try passing a non null credentials object. |
If you mean "try connecting with a username and password", if I run rpcapd as root on Linux, it "works" to the extent that libpcap, as run by Wireshark, can connect and enumerate devices, but attempting to capture on one of those devices fails because rpcapd starts running with the user ID for the username, and that user doesn't have sufficient privileges to capture. It doesn't work on macOS, but that's because macOS requires you to go down the rathole of PAM to do user/password authentication, and nobody's written that code yet (it's On My List(TM)). |
You don't have to pass a username/password, just a non null credentials object The credentials object can still use null authentication with no username / password. reason is that sharppcap decides to use pcap_create instead of pcap_open based on the presence of a credentials object, and as far as I know, libpcap support remote pcap only with pcap_open See https://github.com/dotpcap/sharppcap/blob/master/SharpPcap/LibPcap/LibPcapLiveDevice.cs#L129 |
Which is, currently, a mistake when doing remote capture. Properly suporting the
Yes. The |
what's the "correct" logic then?
Any plans to add remote capture support to pcap_create? |
What tcpdump does is
Wireshark's logic is similar, although the "is this a remote capture?" test is done separately and earlier and the device's information has that as an attribute attached to it. |
Plans, yes; scheduled plans, no, but it won't be in 1.10.x. Note that there will be additional return values from |
I'm trying to connect to a remote computer and get its interfaces, the IP address of which is entered in the command line arguments, and the port is set to default 2002:
var remoteInterfaces = PcapInterface.GetAllPcapInterfaces(new IPEndPoint(ipAddress, port), null);
I get the remote computer interface in the line above and in the line below I try to open the device to capture:
device.Open(new DeviceConfiguration { ReadTimeout = 500 });
on this line I get an exception:
SharpPcap.PcapException: "Unable to activate the adapter (rpcap://[#Remote IP#]/\Device\NPF_{#SOME_GUID#}). (Error Code: Generic)".
WinPcap is installed on the local computer, as well as Npcap version 0.991, because I read that this error disappears with this version (On the latest version, I didn’t even get the remote computer’s interfaces! There were only mine for some reason). The rpcap.exe daemon is running on the remote computer on port 2002.
Using Wireshark I was able to get the same interface of the remote computer and start intercepting packets, but using the library I can't do it.
How can I fix that?
The text was updated successfully, but these errors were encountered: