Friday, September 19, 2008

Netcat: Playing with Network Sockets


Another great command-line tool starting with N!

Netcat is a great tool to interact with network services (it's just like telnet but has more options).

The official website says "Netcat is a featured networking utility which reads and writes data across network connections, using the TCP/IP protocol"

What I really like about netcat is the ability to act like a network server and listen on a port.

This is useful to learn how a network client behaves.

For example, here's netcat listening on port 87 of my localhost on the top screen and wget connecting to my localhost on port 87 in the bottom screen.


Here we can see the HTTP commands sent by Wget (I've boxed out the commands in red):



Notice wget identifies itself as Wget/1.10.2. Also notice that the first error is Read Error, since we didn't interact with wget like a web server would and provide a response, we just let it send a command and ignore it.

The second error is Connection Refused since netcat stopped listening to the port afer the first connect by wget, since a connection was made and then closed.

How cool is that?


More info:
http://netcat.sourceforge.net/

0 comments: