0

I would like to send a captured packet sniffed from network device 1 and will inject it to network device 2 without altering its contents (will act as a wire)

So far I have tried

 byte[] buf = new byte[packet.getTotalSize()];

   System.out.println(packet); // packet is the captured/sniffed packet
   System.out.println(packet.transferStateAndDataTo(buf));//packet contents to buffer

   ByteBuffer b = ByteBuffer.wrap(buf);   

   Injector injector = new Injector(b); //Injector contains the pcap.sendPacket(b) method

   injector.run(); 
poohdedoo
  • 1,258
  • 1
  • 18
  • 42
  • Unless you alter the IP address, nothing is likely to hear the packet you sent. Do you also want to retransmit corrupt packets? – Peter Lawrey Sep 22 '13 at 10:49
  • @peterlawrey thanks for the response. I don't want to change the IP address because my computer will act as a wire from left and right requests from both network devices. – SENTINEL PROJECT Sep 22 '13 at 10:59
  • Okay, and you have isolated networks connected on each network adapter? i.e. the only way for the two endpoints to communicate is via your machine? – Peter Lawrey Sep 22 '13 at 11:05
  • @peterlawrey yes, that is all correct peter. The question is, is that possible to do with jnetpcap? the pcap.sendpacket doesn't seem to be working. – SENTINEL PROJECT Sep 22 '13 at 11:08
  • I believe it should work, but it has been years since I used it so I can't remember the details and I have only a laptop to test software. How do you know it is not working. Have you tried tracing all the message coming in and out of both interfaces to see what happens. – Peter Lawrey Sep 22 '13 at 11:10
  • I have used wireshark to see if the exact packet coming from the left is forwarded to the right, but I wasn't able to find it. Is there a method where I could put a network device as a destination for the packet? or the pcap.sendpacket already does it? – SENTINEL PROJECT Sep 22 '13 at 11:15
  • If you haven't specified the network interface to use, I would assume normal routing rules have been applied which won't work as the same IP addresses appear on both interfaces. You usually get around this by using NAT, but it appears you want to avoid that. I would try to get a NAT working first in any case as it will b less confusing all round. – Peter Lawrey Sep 22 '13 at 11:26
  • Would normal routing rules work if my left network interface is connected to the internet and the right is not connected (static IP address)? I would test it in a way that my computer will act as a bridge/wire and the machine connected to my right interface will have internet connection. – SENTINEL PROJECT Sep 22 '13 at 11:41

0 Answers0