Skip to content
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

Clarification of using npcap vs. libpcap when using MinGW/MSYS #1377

Open
eabase opened this issue Oct 23, 2024 · 5 comments
Open

Clarification of using npcap vs. libpcap when using MinGW/MSYS #1377

eabase opened this issue Oct 23, 2024 · 5 comments

Comments

@eabase
Copy link

eabase commented Oct 23, 2024

I'm using Cygwin and MinGW64/MSYS for compiling a ping-like app, which depends on libpcap.

But I am confused whether I have to use this repo, or the Windows specific npcap one from here:

https://github.com/nmap/npcap

Which one should I use?
What are the differences?

Would be great if you could update your README with this as well.

@guyharris
Copy link
Member

Which one should I use?

You will need Npcap.

This project provides source code to a library that uses various mechanisms to perform packet capture and injection ("injection" because if the app is ping-like, it needs to inject packets, not just capture them.)

It does not provide binary packages.

On various UN*Xes, those mechanisms are provided by the operating system; there are several different mechanisms, and libpcap provides a common API, so that programs can work on multiple UN*X platforms without having to have their own code to use those mechanisms.

The providers of those operating systems usually provide their own binary packages for libpcap, as part of the operating system. In the past, they didn't, and people would have to download the source code and compile it in order to use it.

Windows, however, does not have a packet capture mechanism of the sort that UN*Xes have, so a group at the Politecnico di Torino wrote a driver that hooks into the Windows networking stack, and a library that uses that driver, and then added code to libpcap that uses that library. They released that as WinPcap.

However, WinPcap development and support largely stopped; @hsluoyz took the code, wrote a new driver for newer versions of Windows, updated the libpcap code to the current version of libpcap, and that became Npcap.

Npcap is now actively being developed and supported, primarily by @dmiller-nmap. The libpcap code they use is kept up-to-date with the released version of libpcap.

It is possible to take Npcap's driver and library, install its SDK, and compile libpcap from this repository. The only reason to do so would be if either 1) you wanted to use code that hasn't been released yet, to get a bug fix or feature (note that features that are in the main branch but not in any release are subject to changes, including incompatible changes), or 2) you want to make your own modifications to libpcap.

What you need to do is:

  1. install Npcap using its installer - that's at https://npcap.com, not in the Npcap repository (install it with WinPcap API compatibility checked in the installer check box);
  2. install the Npcap SDK, which is also at https://npcap.com;
  3. build the app using the headers and import library from the Npcap SDK.

See the Npcap Developer's Guide for more information.

@infrastation
Copy link
Member

In case it helps, at least some implementations of ping do the job using two layer 3 sockets, which may be possible on Windows, in which case you would not have to capture packets:

ssend = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
srecv = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);

@dmiller-nmap
Copy link
Contributor

@infrastation That is true, but the resulting program must be run as Administrator. Raw sockets on Windows are deliberately limited.

@eabase
Copy link
Author

eabase commented Nov 3, 2024

This is still very confusing and sounds completely backwards:

What you need to do is:

  1. install Npcap using its installer - that's at https://npcap.com/, not in the Npcap repository (install it with WinPcap API compatibility checked in the installer check box);
  2. install the Npcap SDK, which is also at https://npcap.com/;
  3. build the app using the headers and import library from the Npcap SDK.

First you're telling me to install npcap, whiuch for me is exactl building and installing it, which is the origin of my trouble, as it depends on libpcap... :(

Then you tell me to install the SDK (that AFAIKT is a dependency of (1).)

@infrastation
Copy link
Member

30 days ban for verbal abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants