Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JnetPcap无线接口_Java_Libpcap_Winpcap_Jpcap_Jnetpcap - Fatal编程技术网

Java JnetPcap无线接口

Java JnetPcap无线接口,java,libpcap,winpcap,jpcap,jnetpcap,Java,Libpcap,Winpcap,Jpcap,Jnetpcap,我正在使用JNETPCAPAPI进行项目工作,我能够列出成功运行ClassicPcapExample的步骤 public class ClassicPcapExample { /** * Main startup method * * @param args * ignored */ public static void main(String[] args) { List<PcapIf> alldevs = new ArrayList<

我正在使用JNETPCAPAPI进行项目工作,我能够列出成功运行ClassicPcapExample的步骤

public class ClassicPcapExample {

/**
 * Main startup method
 * 
 * @param args
 *          ignored
 */
public static void main(String[] args) {
    List<PcapIf> alldevs = new ArrayList<PcapIf>(); // Will be filled with NICs
    StringBuilder errbuf = new StringBuilder(); // For any error msgs

    /***************************************************************************
     * First get a list of devices on this system
     **************************************************************************/
    int r = Pcap.findAllDevs(alldevs, errbuf);
    if (r == Pcap.NOT_OK || alldevs.isEmpty()) {
        System.err.printf("Can't read list of devices, error is %s", errbuf
            .toString());
        return;
    }

    System.out.println("Network devices found:");

    int i = 0;
    for (PcapIf device : alldevs) {
        String description =
            (device.getDescription() != null) ? device.getDescription()
                : "No description available";
        System.out.printf("#%d: %s [%s]\n", i++, device.getName(), description);
    }

    PcapIf device = alldevs.get(0); // We know we have atleast 1 device
    System.out
        .printf("\nChoosing '%s' on your behalf:\n",
            (device.getDescription() != null) ? device.getDescription()
                : device.getName());

    /***************************************************************************
     * Second we open up the selected device
     **************************************************************************/
    int snaplen = 64 * 1024;           // Capture all packets, no trucation
    int flags = Pcap.MODE_PROMISCUOUS; // capture all packets
    int timeout = 10 * 1000;           // 10 seconds in millis
    Pcap pcap =
        Pcap.openLive(device.getName(), snaplen, flags, timeout, errbuf);

    if (pcap == null) {
        System.err.printf("Error while opening device for capture: "
            + errbuf.toString());
        return;
    }

jnetpcap没有像wireshark那样将您的无线接口列为“无线”

它被列为Microsoft,因此您的界面是该列表中的Microsoft设备之一


仅允许您的无线网络访问网络,然后在每个网络上尝试嗅探器,直到找到哪个是无线接口。

尝试修改PcapIf device=alldevs.get(0);通过在alldevs.get中输入不同的值(#控制台中显示的设备编号)
        Network devices found:
#0: \Device\NPF_{273EF1C6-92B4-446F-9D88-553E18695A27} [VMware Virtual Ethernet Adapter]
#1: \Device\NPF_{C69FC3BE-1E6C-415B-9AAC-36D4654C7AD8} [Microsoft]
#2: \Device\NPF_{46AC6814-0644-4B81-BAC9-70FEB2002E07} [VMware Virtual Ethernet Adapter]
#3: \Device\NPF_{037F3BF4-B510-4A1D-90C0-1014FB3974F7} [Microsoft]
#4: \Device\NPF_{CA7D4FF0-B88B-4D0D-BBDC-A1923AF8D4B3} [Realtek PCIe GBE Family Controller]
#5: \Device\NPF_{3E2983E7-11F8-415A-BC81-E1B99CA8B092} [Microsoft]

Choosing 'VMware Virtual Ethernet Adapter' on your behalf: