gpt4 book ai didi

java - JnetPcap 无线接口(interface)

转载 作者:行者123 更新时间:2023-11-30 09:10:39 27 4
gpt4 key购买 nike

我是否正在使用 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)上尝试嗅探器,直到找到无线接口(interface)。

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com