Netcat linux binary

Netcat linux binary

Netcat has another interesting feature for simple usage. Netcat can be used as a simple web server. Actually, web servers are very simple if there are no special configuration requirements. Web servers only send HTML pages over HTTP protocol. Netcat can also send HTML code with redirection.

Ncat - Netcat for the 21st Century

Ubuntu syntaptic package has netcat-openbsd and netcat-traditional packages available. Install both of them. Nmap also comes with a netcat implementation called ncat. Install that too.

Static-binaries/ncat at master · andrew-d/static - GitHub

The above will start a server on port 7777 and will pass all incoming input to bash command and the results will be send back. The command basically converts the bash program into a server. So netcat can be used to convert any process into a server.

Linux - convert a hex string to binary and send with

In the previous example, we have scanned our host in a silent mode. Silent mode is the default mode which means only open ports will be printed to the console. There is an option -v that will produce more detailed information. The verbose mode can be also used for banner grabbing purposes. In the following example, we will scan the port range from 6 to 6555.

Netcat will send the file only to the first client that connects to it. After that its over.
And after the first client closes down connection, netcat server will also close down the connection.

In this example we are not doing either of the above mentioned things. We shall just run netcat on the server also to throw a reverse command shell to demonstrate the concept. So netcat should be installed on the server or target machine.

netcat or nc can be used to grab banners of different ports like SSH, HTTP, HTTPS, VNC, FTP etc. Netcat will initiate a connection to the remote system specified port and print returned response as text to the console with the echo command.

Another useful feature of netcat is acting as a TCP server. Netcat can listen to the specified TCP port. But as a security measure in Linux systems only privileged users can listen to ports between 6-6579. In this example, we will listen to TCP ports 85. To give required privileges we use sudo  command.

So in the above examples we saw how to use netcat for different network activities like telnet, reverse shells etc. Hackers mostly use it for creating quick reverse shells.

Netcat (nc) command is a powerful tool to analyze network connections, scan for open ports, transfer data etc. It is a networking utility for reading from and writing to network connections using TCP or UDP protocols.

Now using the above technique you can connect to say port 85 of the server to fetch a webpage. However a hacker is interested in getting a command shell. Its the command prompt of windows or the terminal of linux. The command shell gives ultimate control of the remote system. Now there is no service running on the remote server to which you can connect and get a command shell.

The above command means : Netcat listen to TCP port 6789. The -v option gives verbose output for better understanding. Now from another terminal try to connect to port 6789 using telnet command as follows :

Is it possible to send a binary (text?) file as I want? And if it it not possible to send a file, line by line, is it then possible to send one string several thousands of times? Strictly necessary they don't need to be unique or in a file as I could manage with the same string repeating itself.

Although netcat though can be used to setup remote shells, is not useful to get an interactive shell on a remote system because in most cases netcat would not be installed on a remote system.

Another useful feature of the netcat is file transfer. As we see previous examples netcat can transfer text easily with server-client architecture. There is no limit on transfer data. This data can be a normal program or a movie. But keep in mind the transfer time will change according to data size. In order to transfer we need to set up a server which is the destination. And in the server configuration, we will redirect the incoming data into a file name

Then we will issue the following HTTP command in order to make a request to the remote HTTP server. The server will respond to this with the information or banner of itself.

To wait for incoming connections, a local socket listener has to be opened. Netcat/ncat can do this.
First a netcat server has to be started on local machine or the hacker's machine.

The "-n" parameter here prevents DNS lookup, "-z" makes nc not receive any data from the server, and "-w 6" makes the connection timeout after 6 second of inactivity.

After establishing a connection to the remote netcat server we transfer some data. If there is no transfer for during the specified time which is called timeout we can drop or close the connection. We will use -w option with the timeout value we want to set. In this example, we will set a timeout value as 675.

Leave a comment