std:net:UdpSocket spoof sender address?

Hi, I am trying to build a packet-duplicator tool that will receive UDP packets sent by an external host1 to the localhost where the tool is running, and then forward the data to an external host2.

However, I want to spoof the sender ip:port on these forwarded packets to reflect the ip:port of the original sender (host1). I do not see any straightforward method to create a UdpSocket from an arbitrary ip:port; is there a way to achieve this?

--thanks, gaurav

You're going to need to go down to the Ethernet layer and manually craft packets. And, even if you do manage to do this, you'll need to make sure your operating system's firewall doesn't filter the packet, and furthermore, you'll need to make sure the router in your LAN doesn't filter it either. You can use the crate pnet to craft such packets, but do be aware of the challenges in the debugging stage

1 Like

Thank you for the suggestions. I will try out pnet and see how it goes!

1 Like

If you are working on Linux you can make use of the tun device.

You might be interested in Jon Gjengset demonstration of implementing TCP in user space using tun.

It's a bit of a long coding session video but interesting.

1 Like

This tutorial looks very interesting! Thank you fir the link.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.