Benutzer-Werkzeuge

Webseiten-Werkzeuge


Action disabled: source
linux:file_transfer_using_ncat

file transfer using ncat

Summary

This setup provides a fast way to copy files between different computers.

Main

Hi,

today seiichiro0185 and I have found a fast and unusual way to copy files.

Warranty

Warranty

There is no warranty that this setup works for any system which provide the dependencies listed below.
I'm just providing these information because it worked for me.
If you have questions you can leave a message here but I decide whether I'll answer and help or not.

Security - Connection

Security issue

If you use the described setup you'll copy files using an unencrypted connection.
That is why it is possible to sniff data about you, your systems and your infrastructure.
You should only use it within a secure network and only if you trust everybody who is using it.

Security issue

If you use the described setup you'll copy files using an unencrypted connection.
That is why it is possible to sniff data about you, your systems and your infrastructure.
You should only use it within a secure network and only if you trust everybody who is using it.

Dependencies:

  • sshfs
  • ncat (mostly provided by nmap)

Setup

file recieving system

  1. copy this script on your system which should recieve the files:
    recv-file.sh
    #!/bin/bash
     
    # directory all files and folders will be copied into
    basedir="/<any base directory>/"
     
    read filename
    echo "$filename" >&2
    if [[ "${filename}" =~ / ]]
    then
      [ -d "${basedir}/${filename%%/*}" ] || mkdir -p "${basedir}/${filename%%/*}"
    fi
    cat - > "${basedir}/${filename}"
  2. run the following command:
    ncat -lkvnp 3334 --recv-only -e /path/to/your/recv-file.sh

Now the server is running and listening on port 3334. All files and directories are created with permissions of the running ncat.

file sending system

  1. copy the following script on the system you to send files from:
    send-file.sh
    #!/bin/bash
     
    host="$1"
    port="$2"
     
    [[ ${port} =~ ^[0-9][0-9]*$ ]] || { echo "The given port $port (2. argument) is not valid." >&2 && exit 1 ; }
    shift 2
     
    IFS=","
    for f in $@
    do
      { echo "${f}" && cat "${f}" ; } | ncat -i1 $host $port
    done
  2. use the script like this:
    bash send-file.sh <host> <port> <file1>,<file2>,..,<fileN>
  • if you give the directory in your filelist they are also created on the server side

Comments



B S L​ I F
linux/file_transfer_using_ncat.txt · Zuletzt geändert: 2012/08/30 10:12 von Andrwe Lord Weber