Tuesday, October 03, 2006

Geek Tools: netcat

LifeHacker: Roll Your Own Servers

One of my all time favorite Unix tools is netcat. This tiny command allows you to work incredible network magic.

Some of my favorite hacks include:

- Rigging up a proxy server to record and debug JDBC traffic

- Turn any Unix command into one that can be monitored by a browser by creating a tiny webserver around it

- Create a local Scheme/Beanshell REPL by talking to a remote port embedded in a sevlet instance

- Roll a tiny webclient that allows for arbitrary HTTP requests and shows the entire response (with headers)

- Mix netcat with tar to create an effective remote backup solution for a dead box that can only be booted with a floppy disk distro

- Check on a mail server's configuration by forging test messages and seeing interactivly the results of sending them

- Check for open ports a firewall when no other tools to do so are available

- Simulate heavy load on your network to see if routing issues and packet collisions are a problem

- Create a command line HTTP PUT utility

And probably many more.

All of the above hacks were done with netcat and other standard shell utilities.

While the above link appears to give a comprensive tutorial for netcat, you really should read the README that comes with the Unix distribution. It's part instruction and part inspiration and makes for some of the best reading software documentation ever.

Oh, and it's worth mentioning that Windows folks aren't left out. There's a Windows version of netcat which has also saved my butt a few times. I have it on my thumbdrive as one of my top three utilities I always carry with me.

--Ben

2 comments:

  1. Anonymous9:07 PM

    If you have any of these scripts handy, please link or inline them! I'd love to take a look.

    ReplyDelete
  2. Alex -

    Great question! Great enough to deserve its own blog entry.

    I wish I had more to post than just this one hack. But it's a start.

    ReplyDelete