diff options
| author | deraadt <> | 1996-09-05 08:55:43 +0000 |
|---|---|---|
| committer | deraadt <> | 1996-09-05 08:55:43 +0000 |
| commit | c7823c0917675fd1ab482937ee1bd01d837b081c (patch) | |
| tree | de25439975bbe0baac0f70799dad301539b7be3b /src/usr.bin/nc/scripts/ncp | |
| parent | c215a9e8412ead0190b788622f09bcdbb08794fa (diff) | |
| download | openbsd-c7823c0917675fd1ab482937ee1bd01d837b081c.tar.gz openbsd-c7823c0917675fd1ab482937ee1bd01d837b081c.tar.bz2 openbsd-c7823c0917675fd1ab482937ee1bd01d837b081c.zip | |
nc is *hobbit*'s netcat; let the sysadm have the same tools the crackers
have, so that he may learn what the network is about and protect it better.
Diffstat (limited to 'src/usr.bin/nc/scripts/ncp')
| -rw-r--r-- | src/usr.bin/nc/scripts/ncp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/usr.bin/nc/scripts/ncp b/src/usr.bin/nc/scripts/ncp new file mode 100644 index 0000000000..1931b03385 --- /dev/null +++ b/src/usr.bin/nc/scripts/ncp | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | ## Like "rcp" but uses netcat on a high port. | ||
| 3 | ## do "ncp targetfile" on the RECEIVING machine | ||
| 4 | ## then do "ncp sourcefile receivinghost" on the SENDING machine | ||
| 5 | ## if invoked as "nzp" instead, compresses transit data. | ||
| 6 | |||
| 7 | ## pick your own personal favorite port, which will be used on both ends. | ||
| 8 | ## You should probably change this for your own uses. | ||
| 9 | MYPORT=23456 | ||
| 10 | |||
| 11 | ## if "nc" isn't systemwide or in your PATH, add the right place | ||
| 12 | # PATH=${HOME}:${PATH} ; export PATH | ||
| 13 | |||
| 14 | test "$3" && echo "too many args" && exit 1 | ||
| 15 | test ! "$1" && echo "no args?" && exit 1 | ||
| 16 | me=`echo $0 | sed 's+.*/++'` | ||
| 17 | test "$me" = "nzp" && echo '[compressed mode]' | ||
| 18 | |||
| 19 | # if second arg, it's a host to send an [extant] file to. | ||
| 20 | if test "$2" ; then | ||
| 21 | test ! -f "$1" && echo "can't find $1" && exit 1 | ||
| 22 | if test "$me" = "nzp" ; then | ||
| 23 | compress -c < "$1" | nc -v -w 2 $2 $MYPORT && exit 0 | ||
| 24 | else | ||
| 25 | nc -v -w 2 $2 $MYPORT < "$1" && exit 0 | ||
| 26 | fi | ||
| 27 | echo "transfer FAILED!" | ||
| 28 | exit 1 | ||
| 29 | fi | ||
| 30 | |||
| 31 | # fall here for receiver. Ask before trashing existing files | ||
| 32 | if test -f "$1" ; then | ||
| 33 | echo -n "Overwrite $1? " | ||
| 34 | read aa | ||
| 35 | test ! "$aa" = "y" && echo "[punted!]" && exit 1 | ||
| 36 | fi | ||
| 37 | # 30 seconds oughta be pleeeeenty of time, but change if you want. | ||
| 38 | if test "$me" = "nzp" ; then | ||
| 39 | nc -v -w 30 -p $MYPORT -l < /dev/null | uncompress -c > "$1" && exit 0 | ||
| 40 | else | ||
| 41 | nc -v -w 30 -p $MYPORT -l < /dev/null > "$1" && exit 0 | ||
| 42 | fi | ||
| 43 | echo "transfer FAILED!" | ||
| 44 | # clean up, since even if the transfer failed, $1 is already trashed | ||
| 45 | rm -f "$1" | ||
| 46 | exit 1 | ||
