java - JnetPcap无线接口(interface)

标签 java libpcap winpcap jpcap jnetpcap

我正在使用 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;
    }

我现在遇到的问题是我的无线接口(interface)未在接口(interface)中列出,因此我可以嗅探 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:

最佳答案

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

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

仅让您的无线设备访问网络,然后在每个无线设备上尝试嗅探器,直到找到哪个是无线接口(interface)。

关于java - JnetPcap无线接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22454563/

相关文章:

Hibernate 的 Java 类型转换

c# - 如何在 C# 中打开 pcap-ng 文件

java - 少了一步? loadLibrary() 的参数需要填写什么

java - ORA-00904 : : invalid identifier Issue with Hibernate Dependent objects program

Java 泛型和静态工厂方法——语法

c++ - 更快地从文件中读取数据

c++ - 将私有(private)方法类成员作为指向函数的指针传递

c - 内存 C 中的 IP 查找表

perl - 如何在 Windows 7 中安装适用于 Strawberry Perl 的 Net::Pcap?