Wednesday, March 31, 2010

Transferring files with netcat

Netcat is a computer networking service for reading from and writing network connections using TCP or UDP. Netcat is designed to be a dependable “back-end” device that can be used candidly or easily driven by other programs and scripts.

netcat is an application that is mostly used for "backdoor" purposes, and in this tutorial, I will show you how to transfer a file over a network via netcat.

If you're using Windows, you can download netcat from here. Once it is downloaded, copy nc.exe to C:\Windows\System32 so that you can access it from everywhere.

Transferring files

First run the following command on the receiving computer:

nc -v -w 30 -p 5600 -l > test.txt

After the receiving computer starts listening (in this case, on port 5600), run the following command on the sending computer:

nc -v -w 2 5600 < test.txt

where is the address of the receiving computer. In this case, it's localhost because I'm transferring files over the same computer, for demonstration purposes.

The file was now transferred to the other side: