Netcat/2/en

From aldeid
Jump to navigation Jump to search

Use

Listen To A Port

From a client, establishing a connection to a server (host) on a specific port (port) is simply:

# nc <hostname> <port>

On the server to listen on a specific port:

# nc –l –p <port>

For example, in a first terminal, enter the following command (listening on port 23):

# nc –l –p 23

In a second terminal, enter the command

# nc 127.0.0.1 23

Then enter the text. This appears in the first terminal.

Note
Once the client logs off, the connection is automatically closed. The -l option can be replaced by the -L option to leave the connection open, even if the client disconnects.

« Detach » Option

On Windows, the -d option allows detaching Netcat, that is to say, add it to the list of active services. For example, the following command, run on a Windows client, adds a listener on port 1234 Service:

$ nc -d –L –e cmd.exe –p 1234

It will then be enough from the server, as the following command line to access the client:

$ netcat 192.168.182.1 10001
Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\cygwin\home\a011830>

Creating a Rudimentary Backdoor

Shell

The -e option allows you to run commands via netcat. This makes it easy to create a rudimentary backdoor, as shown in the following example.