Further to my earlier article, I went ahead and developed this application. Here’s a beta!
Title: TCP reassembling client-server application
Date: 17 Aug 13
Author: Adam Palmer <adam [AT] sasdataservices [DOT] com>
Copyright 2009 Adam Palmer
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
This software is a proxy client/server with the advantage that it is able to split a single
incoming connection to the proxy client into multiple TCP streams to the proxy server. The
proxy server will then reassemble these TCP streams into a single outbound connection to
the forward host.
a. Security – data sniffing.
b. Bandwidth – multiple TCP connections over multiple ISPs with iproute2, tc for both outgoing
AND incoming connections.
FTP (Passive), HTTP, SMTP, POP3 and OPENVPN! client/servers have all been tested across this
./configure && make
-L IP:port local listen
-R IP:port remote connect
-c client mode
-s server mode
-tX number of TCP connections
Binding to 0.0.0.0 is supported
A local machine has two equally weighted uplinks: http://www.adampalmer.me/iodigitalsec/
You have a Linux machine online with enough bandwidth, (126.96.36.199)
You want to pull a file from a remote host (188.8.131.52) via SCP (SSH on port 22).
You have access to run the tcp_tun in server mode on 184.108.40.206.
You have no access to 220.127.116.11
On your local machine, run:
tcp_tun -L 127.0.0.1:22 -R 18.104.22.168:1234 -c -t4
On your server (22.214.171.124), run:
tcp_tun -L 126.96.36.199:1234 -R 188.8.131.52:22 -s
Connect your SCP client to 127.0.0.1:22
-t4 should establish 2 TCP connections over each ISP where you have
two equally weighted uplinks. This is controlled by tc/iproute2 however.
The -L and -R modes operate in the same method as SIMPLEPROXY.
5. Benchmarks & Caveats
a. There is CPU processing power required to disassemble and reassemble the stream although this is minimal.
b. If one of the TCP threads is broken, the whole stream will fail
c. The overall connection will run as fast as the slowest of the TCP threads
I will run the client mode (-c) version on Windows XP under CYGWIN on my local PC. (Machine C)
I will run the server mode (-s) version on a remote debian server (217.10.156.X) (Machine X)
I will be attempting to pull a file via WINSCP from server 66.118.142.Y (Machine Y)
Further, I will establish an OPENVPN connection over the proxy.
Running simpleproxy on Machine X to bounce the connection through the same route that the tcp_tun will:
3 averages, download speed is 262.2KB/sec
Local PC: $ ./tcp_tun.exe -L 0.0.0.0:22 -R 217.10.156.X:5555 -c -t2
Machine X: # ./tcp_tun -L 0.0.0.0:5555 -R 66.118.142.Y:22 -s
The code is as follows and should be compiled with:
gcc -Wall -g -O2 -o tcp_tun tcp_tun.c -lpthread
You’ll need ‘getaddrinfo’ in the source directory on certain implications. The tool compiles successfully on Cygwin-latest and Debian Lenny gcc-4.3.2/2.6.28