I used to code with Scapy
in python. Now I'm going to manipulate packets in a pcap
file using java. For example I need to read the pcap
file and then alter one packet's source ip.
Actually, I've altered one field using jNetStream
library, but I don't know how to write the modified packet to pcap
file
EDIT:
I've just provided some codes which belong to packet modification.
Decoder decoder = new Decoder("fileName.pcap");
while ((packet = decoder.nextPacket()) != null) {
new_saddr = InetAddress.getByName("1.1.1.1").getAddress();
saddr.setAddress(new_saddr);
As it could be seen, the new source Ip Address has been set. Now I want to write the whole packets to a new pcap
file but I don't know how to do it.
Any help would be appreciated.