Netcat – The Tcp/Udp Rambo Knife

Netcat
The netcat utility is used for practically anything involving TCP or UDP. It can open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, port scan, and is cool with both IPv4 and IPv6 connections.

In this example, open port 6881 using nc command:

nc -l 6881

On a second console or from a second UNIX / Linux machine, connect to the machine and port being listened on:

nc localhost 6881

OR

nc unix.system.ip.here 6881

In this example, send data from one computer to another:

nc -l 6881 > output.txt

Using a second machine, connect to the listening nc process (@ port 6881), feeding it the file which is to be transferred:

nc your.ip.address 6881 < input.txt

You can run netstat command to view open ports:

netstat -a
netstat -nat | grep LISTEN

Sample outputs:

netstat -nat | grep LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:7634 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:17500 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:55788 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:49198 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN

Advertisements

One thought on “Netcat – The Tcp/Udp Rambo Knife

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s