LokiSec.com

LokiSec.com
  • Security
    • Security Tools
    • Website Defense
    • Personal Security
    • Standards
  • Books
    • Technical

Using Netcat, the TCP/IP swiss army knife

May 5, 2011 by CyberRad

Netcat has been called the TCP/IP swiss army knife and rightfully so.  It can act as a service by listening for a connection, a client and connect to open ports, a port scanner, a tool used to fingerprint a connectable service, and much more.  In this article I will touch on handful of these abilities.

So lets first assume that you have a Windows machine with nc.exe already on it (Which can be achieved through exploiting your target.) and an updated Backtrack instance.  We can set the Windows machine to listen for a connection on port 1337.

NC.exe listening on a Windows box

In this example we used the -l, -v, and -p triggers to run netcat in listen mode on port 1337.  -l (lowercase L) to tell Netcat to listen for a connection.  -v told Netcat to be verbose with it’s output.  -p gave Netcat the port to listen to for a connection request.

To connect to the Windows NC listener from Backtrack we use the -v and -n switches along with the IP address and port we want to connect to.

NC connecting to a Windows box from Backtrack

Just like above, the -v tells Netcat to be verbose and -n tells Netcat not to do a look up on the IP address.  Now, what ever we type in the client on Backtrack…

Type something in the Backtrack session

…will be echoed to the Netcat session on the Windows machine.

Echo to the Windows session

There are many nefarious things you can do with this connection if setup on both ends of the connection correctly.  This site has a few walk-throughs that outline how to eavesdrop on a compromised box.  Be forewarned that anyone can connect to the boxes you compromise with Netcat as there isn’t an authentication mechanism.

Netcat can also act as a port scanner.  Netcat is no replacement for Nmap but it does the job if you are not worried about being discreet.  Netcat makes a complete connection, sending an ACK packet, when it does it’s scan. Nmap sends a RST packet after receiving a SYN-ACK response causing the connection to not be fully established which, for most systems, does not get logged.

Netcat TCP Scan

Here we use the z, n, and v flags to tell Netcat to scan our IP (this can be a CIDR range as well) for TCP ports that fall in the range of 21 through 1000.   -z puts Netcat into zero-I/O mode which is used for scanning.  -n and -v are the same as above.  To do a UDP scan we use the -u flag.

Netcat UDP Scan

Banner grabbing allows you to fingerprint the application and OS that is running on an open port.  Lets do a banner grab on the lokisec.com web server.

Netcat Banner Grab

In the example above we used the following command:
nc lokisec.com 80
followed by:
HEAD / HTTP/1.0
and two returns (press Enter twice).

This netted us information that lokisec.com is running an Apache 2.2.14 web server with PHP 5.3.2 on Ubuntu.  This information can be used to narrow down your search for known vulnerabilities to exploit.

As you can see Netcat is a very robust tool with many features.  If you would like to know more about Netcat take a look at their SourceForge project site.

Posted in Security Tools and tagged with Backtrack, netcat, network, Pentest, swiss army knife, tools, tutorial. RSS 2.0 feed.
« Using Metasploit
PTES – Penetration Testing Execution Standard »

2 Responses to Using Netcat, the TCP/IP swiss army knife

  1. indra says:
    October 27, 2011 at 2:36 am

    Does netcat generate xml output of the scan result.

    Reply
    • CyberRad says:
      October 27, 2011 at 7:02 am

      I do not believe so. The Netcat Source Forge site does not list that as an option and I have not used Netcat in that manner.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent Posts

  • Backtrack 5 r3 has been released!
  • Metasploit: The Penetration Tester’s Guide
  • Google Hacking
  • Backtrack 5 r2 has been released!
  • Going Phishing with the Social Engineering Toolkit

Twitter Feed

  • RT @smhack1: The Space is open for the members hangout. Become a dues paying member and hangout with us. 5 days ago

  • RT @smhack1: We are participating in the Extra Life 2013 event http://t.co/aqg6mWYllF 1 week ago

  • I'm supporting @CMNHospitals through @ExtraLife4Kids! http://t.co/BtApLZUBx9 via @DonorDrive Help me reach my goal! 1 week ago

Archives

  • August 2012
  • June 2012
  • April 2012
  • March 2012
  • January 2012
  • December 2011
  • October 2011
  • September 2011
  • August 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011

Tags

802.11 aircrack-ng aliases apache armitage audit Backtrack cree.py creepy flicker geolocation GUI hacker iis Linux metasploit meterpreter netcat network Nmap No Pentest php PTES Quality scan security SET Snort SQLi swiss army knife tools tutorial twitter Uber user-agent vulnerability w3af web weblabyrinth website WEP wireless WPA WPA2

Search

Spread the word!

Blogroll

  • Carnal0wnage
  • Darknet
  • DigiNinja
  • McGrew Security
  • mubix
  • PaulDotCom
  • SpyLogic
  • TaoSecurity

© 2011-2013 LokiSec.com All Rights Reserved