I would like to ask if there is a way to capture packets, that are about to send from my computer to others through the network.. Is it possible with some java libraries, to design sth like that?
edit
i dont want a programme.. i want a way to create such a programme, written in java… I can send packets with jpcap but i dont want to create the packets, i want to take the packets that my computer will send and edit them before sending them.
I guess, in theory, you could create an alternative “SocketImpl” class and configure your application to use it by configuring a custom socket factory as the default. This approach cannot capture the TCP/IP packets, but it could capture the data before it is written to the OS-level socket.
If you want to capture the network packets and edit them on the way through, you’ll probably need to use the host OS’es IP filtering infrastructure. It will be non-portable, technically complicated, and a pain in the nether regions to configure. And even more so if you try to implement it in Java (using JNI or JNA).
(AFAIK, tools like Wireshark only allow you to see the packets and what’s in them. They can’t change the packets.)