0

I'm trying to extract DNS queries from a PCAP file with JNetPcap, but i'm only able to get the IP header.

Is there a way to get the data inside the packet with JNetPcap ?

This is a part of my code:

public void nextPacket(PcapPacket packet, String arg1)  
    {           
         if(packet.hasHeader(Ip4.ID))
         {
            packet.getHeader(ip);
            byte[] dIP = new byte[4], sIP = new byte[4];
            byte[] test = new byte[20];
            dIP = arg0.getHeader(ip).destination();
            sIP = arg0.getHeader(ip).source();
            String sourceIP = FormatUtils.ip(sIP);
            String destinationIP = FormatUtils.ip(dIP);

            System.out.printf("tcp.ip_src=%s%n",sourceIP);
            System.out.printf("tcp.ip_dest=%s%n",destinationIP);
         }
    }  

Please Advise..

had0yori
  • 1
  • 2

1 Answers1

0

Did you tried to use UDP header ? Maybe it could help

CDominik
  • 115
  • 1
  • 10