nmap / npcap

Nmap Project's Windows packet capture and transmission library
https://npcap.com
Other
2.97k stars 514 forks source link

[Question] Can Npcap replace Winpcap in `genet`? #336

Closed tan-wei closed 3 years ago

tan-wei commented 4 years ago

When I use genet which requries Winpcap installed, in this case, can Npcap replece Winpcap?

I read the source code of genet, I find it uses some steps to verify whether Winpcap:

  1. Try to load wpcap.dll (It's OK for Npcap):
    let lib = libloading::Library::new("Wpcap.dll").map_err(|_| super::Error::DLLNotFound)?;
  2. Try to load all the sympbols in the source code:
    unsafe {
                    pcap_findalldevs_ = lib
                        .get(b"pcap_findalldevs")
                        .map_err(|_| super::Error::DLLFuncNotFound)?;
                    pcap_freealldevs_ = lib
                        .get(b"pcap_freealldevs")
                        .map_err(|_| super::Error::DLLFuncNotFound)?;
                    pcap_open_live_ = lib
                        .get(b"pcap_open_live")
                        .map_err(|_| super::Error::DLLFuncNotFound)?;
                    pcap_datalink_ = lib
                        .get(b"pcap_datalink")
                        .map_err(|_| super::Error::DLLFuncNotFound)?;
                    pcap_loop_ = lib
                        .get(b"pcap_loop")
                        .map_err(|_| super::Error::DLLFuncNotFound)?;
                    pcap_close_ = lib
                        .get(b"pcap_close")
                        .map_err(|_| super::Error::DLLFuncNotFound)?;
                    pcap_breakloop_ = lib
                        .get(b"pcap_breakloop")
                        .map_err(|_| super::Error::DLLFuncNotFound)?;
                }
  3. If any step fails, it will fail to load Winpcap and then notify users to install Winpcap

I try to copy wpcap.dll and packet.dll to the installation directory, but it doesn't work. Hope you can help me. Thanks!

dmiller-nmap commented 4 years ago

Thanks for your interest! In most cases, WinPcap can be simply replaced with Npcap if you check the "Install Npcap in WinPcap API-compatible Mode" checkbox in the installer. If you have problems running any software, you should address it with the developers of that software so that they can work on updating it to be compatible with Npcap directly.