Details

This week we are getting into using Netcat to file transfer network.

Download HD  |   Download MP4

Netcat 101: Using Netcat to Transfer Files!

Since we’ve covered how to get Netcat, and how to use it for chats, we’re going to delve a little further this week with file transfers. Normally, you would use FTP or another option to transfer files, but if none of those are available, Netcat offers an easy way to transfer files of any kind. Let’s say I have a .txt document I need to get from my Linux computer over to my Windows one, and I’m way too lazy to walk over to my office or up the stairs.

Open Netcat on the Windows machine. nc -h shows me that it opens as it should. Now, I have a text document on my desktop that I want to transfer: C:\Users\Shannon\Desktop\technolust.txt.

On this PC, considered the ‘listener’, I type into the command line: nc –v –w 30 –p 31337 –l < C:\Users\Shannon\Desktop\technolust.txt. Let’s break these down: nc is Netcat. -v means verbose. Using -v gives you feedback during an operation on the screen. -w 30 tells Netcat to wait 30 seconds before timing out after a transfer is initiated. It will also terminate the connection 30 seconds after the transfer is complete. Again, -p 31337 is the port. -l means this pc is the listener. The < means you are taking the file and pushing it through to the listener machine.

So we’ve already typed in the command to transfer a file on my Windows computer, but we haven’t initiated it by pressing enter just yet. First, lets take a look at my Linux machine, which will receive the transferred file. This is what we will type: nc –v –w 2 10.73.31.179 31337 > technolust.txt.

Again, nc is Netcat, -v is verbose, -w 2 is wait 2 seconds before cancelling the transfer if there is a loss of connection. This is not the same as the listener PC, because you are more likely to get an error on the listener than the client, so we give the listener 30 seconds wait time, instead of 2. You can vary this depending on your own needs.

The ip address is my Windows machine, with the same port. The > technolust.txt means we are taking what my Windows machine is offering, and outputting it to the new technolust.txt file. Press enter on your listener machine, then your client. If all goes well, you should see a few updates, then be able to open the text file on your client with ‘cat’. Make note that Netcat WILL overwrite a file if it is of the same name, or you can append a file with >>.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

3 Comments

  • Jason 4 months ago

    I like how you pulled the command line to the bottom of the screen and explained the attributes.

    • Shannon 4 months ago

      Agree. I think it’s important to break down the command options, otherwise the more advanced sections wouldn’t make any sense!

  • I really missed HakTip :) Thanks!