Performing an HTTP request #Īlthough there are much better tools for HTTP requests such as curl Now, if you type a message and press ENTER it will be shown on both hosts. On the first host start a Netcat process to listen on port 5555: nc -l 5555įrom the second host run the following command to connect to the listening port: nc 5555 The procedure for creating an online chat between two or more hosts is the same as when transferring files. Once completed, type CTRL+C to close the connection. You can watch the transfer progress on both ends. On the sending host pack the directory and send the data by connecting to the listening nc process on the receiving host: tar czvf - /path/to/dir | nc 5555 The incoming data is piped to the tarĬommand, which will extract the archive: nc -l 5555 | tar xzvf. On the receiving host, set the Netcat tool to listen for an incoming connection on port 5555.
PLAYONLINUX NC NETCAT ARCHIVE
To transfer a directory you can use tar to archive the directory on the source host and to extract the archive on the destination host.
![playonlinux nc netcat playonlinux nc netcat](https://megaobzor.com/uploads/stories/134237/39.jpg)
On the receiving run the following command which will open the port 5555 for incoming connection and redirect the output to the file: nc -l 5555 > file_nameįrom the sending host connect to the receiving host and send the file: This works by setting the Netcat to listen on a specific port (using the -l option) on the receiving host and then establishing a regular TCP connection from the other host and sending the file over it. Netcat can be used to transfer data from one host to another by creating a basic client/server model. Is a better tool than Netcat for complex port scanning. To scan for UDP ports simply add the -u option to the command as shown below: nc -z -v -u 10.10.8.8 20-80 The output will look something like this: SSH-2.0-OpenSSH_7.6p1 Ubuntu-4 For example, if you send an “EXIT” command to the server on the default SSH port 22
PLAYONLINUX NC NETCAT SOFTWARE
You can also use Netcat to find the server software and its version.
![playonlinux nc netcat playonlinux nc netcat](https://miro.medium.com/max/1400/1*k2C7VAQ2qCP0K3YoPXBKWw.png)
If you want to print only the lines with the open ports, you can filter the results with the grepĬommand. Nc: connect to 10.10.8.8 port 79 (tcp) failed: Connection refusedĬonnection to 10.10.8.8 80 port succeeded! Nc: connect to 10.10.8.8 port 23 (tcp) failed: Connection refused Nc: connect to 10.10.8.8 port 21 (tcp) failed: Connection refusedĬonnection to 10.10.8.8 22 port succeeded! The output will look something like this: nc: connect to 10.10.8.8 port 20 (tcp) failed: Connection refused The -z option will tell nc to only scan for open ports, without sending any data to them and the -v option to provide more verbose information. You can scan a single port or a port range.įor example, to scan for open ports in the range 20-80 you would use the following command: nc -z -v 10.10.8.8 20-80
![playonlinux nc netcat playonlinux nc netcat](https://isroot.nl/2019/05/12/vulnhub-write-up-brainpan-1/14.png)
Scanning ports is one of the most common uses for Netcat.