2

我是否正在使用 JnetPcap API 进行项目,我能够列出成功运行 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;
    }

我现在遇到的问题是我的无线接口没有在接口中列出,所以我可以嗅探 HTTP 数据包。

这是该程序的输出:

        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:
4

1 回答 1

2

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

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

只让你的无线上网,然后在每一个上尝试嗅探器,直到找到哪个是无线接口。

于 2015-07-11T15:04:22.330 回答