我已经向 Jnetpcap 论坛提出了这个问题。并且没有得到任何回应。我一直在尝试从请求/响应数据包中获取网站名称。这是我尝试过的:
PcapPacketHandler<String> jpacketHandler = new PcapPacketHandler<String>() {
final Tcp tcp = new Tcp();
final Http http = new Http();
final Ip4 ip = new Ip4();
public void nextPacket(PcapPacket packet, String user) {
if (packet.hasHeader(http)) {
packet.getHeader(http);
final String content_length = http.fieldValue(Response.Content_Length);
final String response_code = http.fieldValue(Response.ResponseCode);
//Find if the given packet is a Request/Response Pkt : First get the TCP header
packet.getHeader(tcp);
Integer int_tcp_source = new Integer(tcp.source());
Integer int_tcp_destination = new Integer(tcp.destination());
if(int_tcp_source!=80 && content_length==null){
//It is a Request pkt :
packet.getHeader(http);
final String ref = http.fieldValue(Request.Referer);
final String req_url = http.fieldValue(Request.RequestUrl);
String page_url = http.fieldValue(Request.Host);
System.out.printf("\n Referer " +ref +req_url );//Get the URL
System.out.printf("\nHost " +page_url);
}
}
}
};
但它甚至没有进入:
if (packet.hasHeader(http)) {
我正在使用 Windows 笔记本电脑和无线连接。
如果我尝试:
if (packet.hasHeader(ip)) {//Ip4
我可以进入if 块并可以检索源和目标 IP 地址。
我基本上需要做与http://jnetpcap.com/?q=node/937相同的事情。
我真的被困住了,真的需要别人的帮助。
或者只是有人可以帮我弄清楚如何从数据包中获取网站名称吗?一些代码片段会很棒。
任何人都可以请帮忙。
提前致谢。