Using Netcat as a proxy has been well documented and is pretty straightforward on *nix:
> mkfifo backpipe > nc -l 3000 0<backpipe | nc www.google.com 80 1>backpipe
However, I'm running Windows and the concept of named pipes (mkfifo) is a bit different. There isn't a Windows command to create a named pipe; rather, it must be programmatically done. Also, it operates a bit different so even with a Windows named pipe, the above command didn't work for me.
There are workarounds, using the '-e' option but I couldn't get those to send data back to me. So I figured it was time to find out how named pipes work and see what I could do with that.
It was pretty easy to find some examples on Microsoft Developer's Network of named pipe implementations. The question for me was what was the difference. The easy answer was to code them all up in a single program with a command line switch to select the implementation.
I did that and you can find the results on my software page. Testing was pretty easy with PipeList and Named Pipe TCP Proxy.
Now for Netcat testing. For the test, I'll create the pipe, set-up the Netcat proxy to listen on TCP:4000 and forward connections to Google (www.google.com:80). So when I connect to the local proxy on TCP:4000, I should be able to issue the HTTP 'GET /' command and get back a status 200 along with the Google homepage. Let's try...
First create the pipe:
C:\> pipe -n netcat Pipe Server: Multithreading - client connect \\.\pipe\netcat
Next, start the Netcat proxy:
C:\> nc -L -p 4000 -e "nc www.google.com 80 > \\.\pipe\netcat" < \\.\pipe\netcat
Finally, try to connect to the proxy and issue the 'GET /' command:
C:\> nc localhost 4000 GET / HTTP/1.0 200 OK [...]
It works! Now that we can experiment, let's next look at using Netcat as a IPv4 to IPv6 / IPv6 to IPv4 proxy!
No comments :
Post a Comment