At least in Unices and, for example, where raw sockets are used, this is impossible, since the package is copied to user space, and you only work with this copy. In addition, sending a packet back through the raw socket can be considered an โoutgoingโ packet, so that it does not actually redirect to the input path where it should be. The source sockets were - according to the Linux file page - for implementing the new protocols, IOW, raw sockets - this is the "endpoint", not the "end-to-end station".
To modify packets in the input path (as for the passage), each OS has its own set of interfaces. On Linux (you were not specific to what you were targeting), this will be the nfqueue mechanism, which can be used via libnetfilter_queue. And of course, this is how wirehark, if it wants to (I donโt see him doing the package change the last time I checked), would continue to do so.
user562374
source share