In a previous article, I did comment on a nice opensource library (Windivert) and shared a basic freepascal demo to use it.
This time I used this library to redirect (or reuse) a local port used by another application or service to another local port.
It could be handy to fool firewalls or to hijack traffic going to a service.
One of the best example that come to my mind is to redirect local port 445 to a an application/shell of your own listening on local port 1337.
Something you could not achieve like netsh port redirect as the port is already in use and/or used by a kernel service (SMB in our case).
The command line would then be tcpredir 445 1337.
Source code and binaries on Github.
One possible application example:
-divert local port 445 to port 1337
-set up a smb server on port 1337