Fpipe

FPipe v2.1 - Port redirector.

FPipe is a source port forwarder/redirector. It can create a TCP or UDP stream with a source port of your choice. This is useful for getting past firewalls that allow traffic with source ports of say 23, to connect with internal servers.

Usually a client has a random, high numbered source port, which the firewallpicks off in its filter. However, the firewall might let Telnet traffic through. FPipe can force the stream to always use a specific source port, in this case the Telnet source port. By doing this, the firewall 'sees' the stream as an allowed service and let's the stream through.

FPipe basically works by indirection. Start FPipe with a listening server port, a remote destination port (the port you are trying to reach inside the firewall) and the (optional) local source port number you want. When FPipe starts it will wait for a client to connect on its listening port. When a listening connection is made a new connection to the destination machine and port with the specified local source port will be made - creating the needed stream. When the full connection has been established, FPipe forwards all the data received on its inbound connection to the remote destination port beyond the firewall.

FPipe can run on the local host of the application that you are trying to use to get inside the firewall, or it can listen on a 3rd server somewhere else.

Say you want to telnet to an internal HTTP server that you just compromised with MDAC. A netcat shell is waiting on that HTTP server, but you can't telnet because the firewall blocks it off. Start FPipe with the destination of the netcat listener, a listening port and a source port that the firewall will let through. Telnet to FPipe and you will be forwarded to the NetCat shell. Telnet and FPipe can exist on the same server, or on different servers.

*** IMPORTANT ***
Users should be aware of the fact that if they use the -s option to specify an outbound connection source port number and the outbound connection becomes closed, they MAY not be able to re-establish a connection to the remote machine (FPipe will claim that the address is already in use) until the TCP TIME_WAIT and CLOSE_WAIT periods have elapsed. This time period can range anywhere from 30 seconds to 4 minutes or more depending on which OS and version you are using. This timeout is a feature of the TCP protocol and is not a limitation of FPipe itself.

The reason this occurs is because FPipe tries to establish a new connection to the remote machine using the same local IP/port and remote IP/port combination as in the previous session and the new connection cannot be made until the TCP stack has decided that the previous connection has completely finished up.

Connection illustration

The connection terminology used in the program and in the following documentation can be shown in the form of the following diagram.
Local Machine <----------> FPipe server <---------> Remote machine
Inbound Outbound
connection connection

------------------------------------------------------------------------------

This is the usage line as reported by typing "FPipe", "FPipe -h"or"FPipe -?".

FPipe v2.1 - TCP/UDP port redirector.

FPipe [-hvu?] [-lrs ] [-i IP] IP

-?/-h - shows this help text
-c - maximum allowed simultaneous TCP connections. Default is 32
-i - listening interface IP address
-l - listening port number
-r - remote port number
-s - outbound source port number
-u - UDP mode
-v - verbose mode

Detailed option descriptions
-h or -?
Shows the usage of the program as in the above text.

-c
Specifies the maximum number of simultaneous TCP connections that the program can handle. The default number is 32. If you are planning on using FPipe for forwarding HTTP requests it might be advisable to raise this number.

-i
Specifies the IP interface that the program will listen on. If this option is not used FPipe will listen on whatever interface the operating system determines is most suitable.

-l
Specifies the FPipe listening server port number. This is the port number that listens for connections on the FPipe machine.

-r
Specifies the remote port number. This is the port number on the remote machine that will be connected to.

-s
Specifies the outbound connection local source port number. This is the port number that data sent from the FPipe server machine will come from when sent to the remote machine.

-u
Sets the program to run in UDP mode. FPipe will forward all UDP data sent to and received from either side of the FPipe server (the machine on which FPipe is running). Since UDP is a connectionless protocol the -c option is meaningless with this option.

-v
Verbose mode. Additional information will be shown if you set the program to verbose mode.

IP
Specifies the remote host IP address.

To best illustrate the use of FPipe here is an example.
Example #1:
fpipe -l 53 -s 53 -r 80 192.168.1.101

This would set the program to listen for connections on port 53 and when a local connection is detected a further connection will be made to port 80 of the remote machine at 192.168.1.101 with the source port for that outbound connection being set to 53 also. Data sent to and from the connected machines will be passed through.