NetCat

Netcat is an OLD networking utility tool, which is used to read and write data across network connections, using the TCP/IP protocol.
It is a reliable “back-end” tool that can be used directly or easily driven by other programs and scripts. It is also very efficient in network debugging and exploration.

Features of Netcat, which drive me to keep it at first place are as follows:

  1. outbound or inbound connections, TCP or UDP, to or from any ports
  2. Full DNS forward/reverse checking, with appropriate warnings
  3. Ability to use any local source port
  4. Ability to use any locally-configured network source address
  5. Built-in port-scanning capabilities, with randomization
  6. Built-in loose source-routing capability
  7. Hex dump of transmitted and received data
  8. Optional telnet-options responder
  9. Featured tunneling mode which allows also special tunneling such as UDP to TCP, with the possibility of specifying all network parameters

It looks something like this:

Port Scanning

nc -v -n -z -w 1 127.0.0.1 22-1000
for i in {21..29}; do nc -v -n -z -w 1 192.168.0.$i 21-443; done

Web Headers

$ cat http1.0.txt
HEAD / HTTP/1.0
$
$ cat http1.1.txt
HEAD /RCS/index.html,v HTTP/1.1
Host: www.example.com
$
$ cat http1.0.txt | nc www.example.com 80
HTTP/1.1 200 OK
Date: Mon, 30 Dec 2009 02:22:15 GMT
Server: Apache/1.4.18 (Unix)
Last-Modified: Wed, 27 Feb 2009 09:28:34 GMT
ETag: "2bd02-0-3r7ca6c2"
Accept-Ranges: bytes
Content-Length: 0
Connection: close
Content-Type: text/html
X-Pad: avoid browser bug

Connection closed by foreign host.
$
$ cat http1.1.txt | nc www.example.com 80
HTTP/1.1 403 Forbidden
Date: Mon, 30 Dec 2009 02:26:10 GMT
Server: Apache/1.4.18 (Unix)
Content-Type: text/html

Connection closed by foreign host.

SMTP

$ cat smtp_relay.txt
HELO myhost
MAIL FROM: Sender Name <user@example.org>
RCPT TO: Recipient Name <user@example.net>
DATA
From: Sender Name <user@example.org>
To: Recipient Name <user@example.net>
Subject: test

.
QUIT
$ 

Time

$ time nc www.example.com 80
GET / HTTP/1.1
Host: www.example.com

real    0m34.031s
user    0m0.003s
sys     0m0.002s
$ 

Be the first to comment

Leave a Reply

Your email address will not be published.


*


*