简体   繁体   English

无法使用jnetpcap捕获Google搜索URL

[英]Can't capture google search URL using jnetpcap

I am developing an application to capture all HTTP urls. 我正在开发一个应用程序以捕获所有HTTP URL。 I used pcap.LOOP_INFINATE for persistent capturing, but when i search on google, it does not capture any packets. 我使用pcap.LOOP_INFINATE进行持久捕获,但是当我在Google上搜索时,它不会捕获任何数据包。 Kindly give me a solution for this. 请给我一个解决方案。

This is my sample code: 这是我的示例代码:

int snaplen = 64 * 1024;          
int flags = Pcap.MODE_PROMISCUOUS; 
int timeout = 10*1000;
Pcap pcap =   Pcap.openLive(device.getName(), snaplen, flags, timeout, errbuf);  

PcapPacketHandler<String> jpacketHandler = new PcapPacketHandler<String>() {  
    final Tcp tcp = new Tcp();  

    final Ip4 ip = new Ip4(); Arp arp=new Arp();Payload payload = new Payload();
    Ethernet eth=new Ethernet();Http http = new Http();Udp udp=new Udp(); 

    public void nextPacket(PcapPacket packet, String user) { 

        if (packet.hasHeader(tcp) && packet.hasHeader(http)) {  

            if(tcp.destination() == 80) {

                if(http.hasField(Http.Request.Accept) && http.fieldValue(Http.Request.Accept).contains("text/html")) 
                {

                    String host = http.fieldValue(Http.Request.Host);
                    String url = host + http.fieldValue(Http.Request.RequestUrl);
                    String referer =  http.fieldValue(Http.Request.Referer);
                    System.out.println("Request: " +" - " + url);
                }
            }
        } 
        } 
};  
pcap.loop(pcap.LOOP_INFINATE,jpacketHandler, null);  

google search uses https, eg port 443 and not port 80. And it is encrypted, so you will not get usable data by simple packet capture google搜索使用https,例如端口443,而不是端口80。它是经过加密的,因此您不会通过简单的数据包捕获来获得可用的数据

-- Steffen Ullrich -斯特芬·乌尔里希(Steffen Ullrich)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM