From b0f2a2365bfdbf7082ab89d1c7881b1f3032e0fc Mon Sep 17 00:00:00 2001 From: Ville Rantanen Date: Thu, 15 Dec 2016 10:23:20 +0200 Subject: [PATCH] lets welcome scotty in this toolbox --- bin/scotty | 1 + web/scotty | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 120000 bin/scotty create mode 100755 web/scotty diff --git a/bin/scotty b/bin/scotty new file mode 120000 index 0000000..64bfd58 --- /dev/null +++ b/bin/scotty @@ -0,0 +1 @@ +../web/scotty \ No newline at end of file diff --git a/web/scotty b/web/scotty new file mode 100755 index 0000000..b0cb5b3 --- /dev/null +++ b/web/scotty @@ -0,0 +1,49 @@ +#!/bin/bash + +_help() { + echo '# Scotty v.5 + +Scotty is the most simple network file transfer utility. It provides +no security what so ever. + +To expose a file/folder for anyone to catch: +* scotty up [folder/file name] +* Pick the hostname from the printed list, and send it to the receiver. + +To download the exposed folder/file: +* scotty down [sender host name] +* Download happens to the current working directory. +* By default, any existing file is overwritten. + +Add tar options by modifying a variable: +* SCOTTY_TAR="pass your tar options here" scotty ... + +Scotty uses port '$PORT' to transfer files. Downloading host needs +to see the uploader directly. +' +exit +} + +PORT=60006 +[[ -z "$2" ]] && _help +[[ "$1" = "-h" ]] && _help + +PV=cat +which pv &> /dev/null && PV=pv + +[[ "$1" = up ]] && { +echo Beam me up, Scotty. Waiting for someone to beam $( hostname ) down... +printf "\n| %15s | %s\n" IP Hostname +for addr in $( hostname -I ); do + printf "| %15s | %s\n" $addr $( dig +short -x $addr ) +done +echo Scotty, beam $( hostname ) down | nc -l -p $PORT +echo Transporter locking to signature +tar -cv $SCOTTY_TAR "$2" | $PV | nc -l -p $PORT +} +[[ "$1" = down ]] && { +nc -w 10 "$2" $PORT +sleep 0.5 +nc -w 10 "$2" $PORT | $PV | tar -x $SCOTTY_TAR +} +true