Pantek Selected as a 2010 NEOSA Best of Tech Awards Finalist

Pantek Inc. is excited to announce that they have been selected as a finalist in the Best IT Services Company category for the 2010 NEOSA Best of Tech Awards. The Best IT Services Company category recognizes outstanding achievement for firms providing information technology related services and/or products, such as infrastructure support, staffing solutions, custom development and so on. Winners will be announced and awards presented at the 4th Annual NEOSA Best of Tech Awards Dinner on Wednesday, May 19, 2010.

“We are committed to providing the best Linux and Open Source consulting and support in Northeastern Ohio and across the globe”, said Pantek President, Barry Zack. “NEOSA’s recognition underscores our expertise and achievements.”

Netcat: Network Swiss Army Knife

Netcat is a networking utility which reads and writes data across network connections, using the TCP/IP protocol, and because of its vast diversity of function it has been called the network Swiss army knife,

It has a full suite of port-scanning capabilities and can be utilized in much the same way as nmap for standard security scanning, but unlike nmap it has features that far exceed network scanning. It was designed to be a tool that can be used directly or easily used by other programs and scripts. It can create and accept almost any kind of connection you can dream of. Have you ever piped a drive image over the network? With netcat you can. Netcat has been called the network swiss army knife for good reason; it does just about everything.

Lets start with a fairly simple example; a proxy. Lets say for some reason you need a basic proxy. With netcat this is simple. A uni-directional proxy is easy, just use a pipe like this:

rweaver@core:~$ nc -l -p 5555 | nc www.pantek.com 80

However, this is of limited use in most cases so we need to look at making it bi-directional and the easiest way to do that is with the -c option like this:

rweaver@core:~$ nc -l -p 5555 -c 'nc www.pantek.com 80'

You now have a bi-directional proxy setup between port 5555 on the local machine and port 80 on pantek’s website.

How about some simple port scanning ala nmap? Easy enough…

rweaver@core:~$ nc -z core.domain.tld 1-32768

Need to do some simple bi-directional testing of a tcp port, say when you connect it sends some simple data back to you?

rweaver@core:~$ nc -l -p 5555 -c 'echo "You are the weakest connection, goodbye!"'

If your version of netcat is compiled with ‘GAPING_SECURITY_HOLE’ defined, which allows remote executions that may be a security risk to the system if used incorrectly, it can execute this command:

rweaver@core:~$ nc -l -p 5555 -e '/bin/bash'

Giving you the ability to open up a shell on port 5555 that is remotely connectible. Up to this point we’ve been using netcat in single fire mode, you execute the command and it waits for a connect, does what it’s asked and then terminates netcat. There is a very good reason for this… netcat mis-used is a gaping security hole as listed in the previous example. You might find a need to perform an operation like that, but you absolutely wouldn’t want to let multiple connections occur to that unrestricted. If the script you are proxying needs to be reconnectable (for example a server that sends a file multiple times) you can use a -L instead of -l.

Speaking of the ability to send a file via netcat, how do we go about this operation?

rweaver@core:~$ cat filename | gzip -9 | nc -l -p 5555

Then on the client machine you would execute…

rweaver@mail:~$ nc core.domain.tld 5555 > filename.gz

The reason we compress the output is netcat does no compression on its own internally. This is not absolutely necessary but it typically speeds transfer times a notable amount.

What about imaging a hard drive from one host to another? Easy with netcat.

root@core:~# dd if=/dev/sda | gzip -9 | nc -l -p 5555

Then on the client…

root@live-cd:~# nc core.domain.tld 5555 | gzip -d | dd of=/dev/sda

You should consider adding a block size option to the dd operation as it will drastically reduce the transfer times. The second operation should be performed from a live cd so you’re not dealing with live information being overwritten.

One last trick with netcat before I close. Short a telnet client? Try netcat…

rweaver@mail:~$ nc -t host.domain.tld 23

With a bit of fore thought netcat is an extremely versatile application that can network enable many operations that would normally be available only locally. It can substitute for a wide variety of applications making it a great tool for a small distribution where you need to reduce the system foot print. Furthermore because it handles pipes exceptionally well when mixing standard networking and system level operations often times it can become an impromptu solution for a problem that might have otherwise required a traditional development effort.

If you need further assistance with netcat or any other open source application, the experts at Pantek Inc. are always available at info@pantek.com, or 216-344-1614, and 877-LINUX-FIX.