diff options
| author | ericj <> | 2002-02-19 23:19:39 +0000 |
|---|---|---|
| committer | ericj <> | 2002-02-19 23:19:39 +0000 |
| commit | 31a22424aa35acd1cf9df9a6c4c3487c347da1c4 (patch) | |
| tree | cabff89a2fb4291caf9ecdacb0746aafacaf299e | |
| parent | a03c0e851f1aaa82f73eef4a7673768cae02b444 (diff) | |
| download | openbsd-31a22424aa35acd1cf9df9a6c4c3487c347da1c4.tar.gz openbsd-31a22424aa35acd1cf9df9a6c4c3487c347da1c4.tar.bz2 openbsd-31a22424aa35acd1cf9df9a6c4c3487c347da1c4.zip | |
remove more old cruft
Diffstat (limited to '')
| -rw-r--r-- | src/usr.bin/nc/scripts/README | 5 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/alta | 35 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/bsh | 31 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/dist.sh | 25 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/irc | 81 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/iscan | 37 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/ncp | 48 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/probe | 52 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/web | 150 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/webproxy | 140 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/webrelay | 46 | ||||
| -rw-r--r-- | src/usr.bin/nc/scripts/websearch | 79 |
12 files changed, 0 insertions, 729 deletions
diff --git a/src/usr.bin/nc/scripts/README b/src/usr.bin/nc/scripts/README deleted file mode 100644 index 07aee0c8ea..0000000000 --- a/src/usr.bin/nc/scripts/README +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | A collection of example scripts that use netcat as a backend, each | ||
| 2 | documented by its own internal comments. | ||
| 3 | |||
| 4 | I'll be the first to admit that some of these are seriously *sick*, | ||
| 5 | but they do work and are quite useful to me on a daily basis. | ||
diff --git a/src/usr.bin/nc/scripts/alta b/src/usr.bin/nc/scripts/alta deleted file mode 100644 index ed4bd3917c..0000000000 --- a/src/usr.bin/nc/scripts/alta +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: alta,v 1.2 2001/01/29 01:58:12 niklas Exp $ | ||
| 3 | |||
| 4 | ## special handler for altavista, since they only hand out chunks of 10 at | ||
| 5 | ## a time. Tries to isolate out results without the leading/trailing trash. | ||
| 6 | ## multiword arguments are foo+bar, as usual. | ||
| 7 | ## Second optional arg switches the "what" field, to e.g. "news" | ||
| 8 | |||
| 9 | test "${1}" = "" && echo 'Needs an argument to search for!' && exit 1 | ||
| 10 | WHAT="web" | ||
| 11 | test "${2}" && WHAT="${2}" | ||
| 12 | |||
| 13 | # convert multiple args | ||
| 14 | PLUSARG="`echo $* | sed 's/ /+/g'`" | ||
| 15 | |||
| 16 | # Plug in arg. only doing simple-q for now; pg=aq for advanced-query | ||
| 17 | # embedded quotes define phrases; otherwise it goes wild on multi-words | ||
| 18 | QB="GET /cgi-bin/query?pg=q&what=${WHAT}&fmt=c&q=\"${PLUSARG}\"" | ||
| 19 | |||
| 20 | # ping 'em once, to get the routing warm | ||
| 21 | nc -z -w 8 www.altavista.digital.com 24015 2> /dev/null | ||
| 22 | echo "=== Altavista ===" | ||
| 23 | |||
| 24 | for xx in 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 \ | ||
| 25 | 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 ; do | ||
| 26 | echo "${QB}&stq=${xx}" | nc -w 15 www.altavista.digital.com 80 | \ | ||
| 27 | egrep '^<a href="http://' | ||
| 28 | done | ||
| 29 | |||
| 30 | exit 0 | ||
| 31 | |||
| 32 | # old filter stuff | ||
| 33 | sed -e '/Documents .* matching .* query /,/query?.*stq=.* Document/p' \ | ||
| 34 | -e d | ||
| 35 | |||
diff --git a/src/usr.bin/nc/scripts/bsh b/src/usr.bin/nc/scripts/bsh deleted file mode 100644 index 808e8f9968..0000000000 --- a/src/usr.bin/nc/scripts/bsh +++ /dev/null | |||
| @@ -1,31 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: bsh,v 1.2 2001/01/29 01:58:12 niklas Exp $ | ||
| 3 | |||
| 4 | ## a little wrapper to "password" and re-launch a shell-listener. | ||
| 5 | ## Arg is taken as the port to listen on. Define "NC" to point wherever. | ||
| 6 | |||
| 7 | NC=nc | ||
| 8 | |||
| 9 | case "$1" in | ||
| 10 | ?* ) | ||
| 11 | LPN="$1" | ||
| 12 | export LPN | ||
| 13 | sleep 1 | ||
| 14 | echo "-l -p $LPN -e $0" | $NC > /dev/null 2>&1 & | ||
| 15 | echo "launched on port $LPN" | ||
| 16 | exit 0 | ||
| 17 | ;; | ||
| 18 | esac | ||
| 19 | |||
| 20 | # here we play inetd | ||
| 21 | echo "-l -p $LPN -e $0" | $NC > /dev/null 2>&1 & | ||
| 22 | |||
| 23 | while read qq ; do | ||
| 24 | case "$qq" in | ||
| 25 | # here's yer password | ||
| 26 | gimme ) | ||
| 27 | cd / | ||
| 28 | exec csh -i | ||
| 29 | ;; | ||
| 30 | esac | ||
| 31 | done | ||
diff --git a/src/usr.bin/nc/scripts/dist.sh b/src/usr.bin/nc/scripts/dist.sh deleted file mode 100644 index f9519c87a6..0000000000 --- a/src/usr.bin/nc/scripts/dist.sh +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: dist.sh,v 1.2 2001/01/29 01:58:12 niklas Exp $ | ||
| 3 | |||
| 4 | ## This is a quick example listen-exec server, which was used for a while to | ||
| 5 | ## distribute netcat prereleases. It illustrates use of netcat both as a | ||
| 6 | ## "fake inetd" and a syslogger, and how easy it then is to crock up a fairly | ||
| 7 | ## functional server that restarts its own listener and does full connection | ||
| 8 | ## logging. In a half-screen of shell script!! | ||
| 9 | |||
| 10 | PORT=31337 | ||
| 11 | |||
| 12 | sleep 1 | ||
| 13 | SRC=`tail -1 dist.log` | ||
| 14 | echo "<36>elite: ${SRC}" | ./nc -u -w 1 localhost 514 > /dev/null 2>&1 | ||
| 15 | echo ";;; Hi, ${SRC}..." | ||
| 16 | echo ";;; This is a PRERELEASE version of 'netcat', tar/gzip/uuencoded." | ||
| 17 | echo ";;; Unless you are capturing this somehow, it won't do you much good." | ||
| 18 | echo ";;; Ready?? Here it comes! Have phun ..." | ||
| 19 | sleep 8 | ||
| 20 | cat dist.file | ||
| 21 | sleep 1 | ||
| 22 | ./nc -v -l -p ${PORT} -e dist.sh < /dev/null >> dist.log 2>&1 & | ||
| 23 | sleep 1 | ||
| 24 | echo "<36>elite: done" | ./nc -u -w 1 localhost 514 > /dev/null 2>&1 | ||
| 25 | exit 0 | ||
diff --git a/src/usr.bin/nc/scripts/irc b/src/usr.bin/nc/scripts/irc deleted file mode 100644 index e45942c0bc..0000000000 --- a/src/usr.bin/nc/scripts/irc +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: irc,v 1.2 2001/01/29 01:58:12 niklas Exp $ | ||
| 3 | |||
| 4 | ## Shit-simple script to supply the "privmsg <recipient>" of IRC typein, and | ||
| 5 | ## keep the connection alive. Pipe this thru "nc -v -w 5 irc-server port". | ||
| 6 | ## Note that this mechanism makes the script easy to debug without being live, | ||
| 7 | ## since it just echoes everything bound for the server. | ||
| 8 | ## if you want autologin-type stuff, construct some appropriate files and | ||
| 9 | ## shovel them in using the "<" mechanism. | ||
| 10 | |||
| 11 | # magic arg: if "tick", do keepalive process instead of main loop | ||
| 12 | if test "$1" = "tick" ; then | ||
| 13 | # ignore most signals; the parent will nuke the kid | ||
| 14 | # doesn't stop ^Z, of course. | ||
| 15 | trap '' 1 2 3 13 14 15 16 | ||
| 16 | while true ; do | ||
| 17 | sleep 60 | ||
| 18 | echo "PONG !" | ||
| 19 | done | ||
| 20 | fi | ||
| 21 | |||
| 22 | # top level: fire ourselves off as the keepalive process, and keep track of it | ||
| 23 | sh $0 tick & | ||
| 24 | ircpp=$! | ||
| 25 | echo "[Keepalive: $ircpp]" >&2 | ||
| 26 | # catch our own batch of signals: hup int quit pipe alrm term urg | ||
| 27 | trap 'kill -9 $ircpp ; exit 0' 1 2 3 13 14 15 16 | ||
| 28 | sleep 2 | ||
| 29 | |||
| 30 | sender='' | ||
| 31 | savecmd='' | ||
| 32 | |||
| 33 | # the big honkin' loop... | ||
| 34 | while read xx yy ; do | ||
| 35 | case "${xx}" in | ||
| 36 | # blank line: do nothing | ||
| 37 | "") | ||
| 38 | continue | ||
| 39 | ;; | ||
| 40 | # new channel or recipient; if bare ">", we're back to raw literal mode. | ||
| 41 | ">") | ||
| 42 | if test "${yy}" ; then | ||
| 43 | sender="privmsg ${yy} :" | ||
| 44 | else | ||
| 45 | sender='' | ||
| 46 | fi | ||
| 47 | continue | ||
| 48 | ;; | ||
| 49 | # send crud from a file, one line per second. Can you say "skr1pt kidz"?? | ||
| 50 | # *Note: uses current "recipient" if set. | ||
| 51 | "<") | ||
| 52 | if test -f "${yy}" ; then | ||
| 53 | ( while read zz ; do | ||
| 54 | sleep 1 | ||
| 55 | echo "${sender}${zz}" | ||
| 56 | done ) < "$yy" | ||
| 57 | echo "[done]" >&2 | ||
| 58 | else | ||
| 59 | echo "[File $yy not found]" >&2 | ||
| 60 | fi | ||
| 61 | continue | ||
| 62 | ;; | ||
| 63 | # do and save a single command, for quick repeat | ||
| 64 | "/") | ||
| 65 | if test "${yy}" ; then | ||
| 66 | savecmd="${yy}" | ||
| 67 | fi | ||
| 68 | echo "${savecmd}" | ||
| 69 | ;; | ||
| 70 | # default case goes to recipient, just like always | ||
| 71 | *) | ||
| 72 | echo "${sender}${xx} ${yy}" | ||
| 73 | continue | ||
| 74 | ;; | ||
| 75 | esac | ||
| 76 | done | ||
| 77 | |||
| 78 | # parting shot, if you want it | ||
| 79 | echo "quit :Bye all!" | ||
| 80 | kill -9 $ircpp | ||
| 81 | exit 0 | ||
diff --git a/src/usr.bin/nc/scripts/iscan b/src/usr.bin/nc/scripts/iscan deleted file mode 100644 index 237d6b0625..0000000000 --- a/src/usr.bin/nc/scripts/iscan +++ /dev/null | |||
| @@ -1,37 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: iscan,v 1.2 2001/01/29 01:58:12 niklas Exp $ | ||
| 3 | |||
| 4 | ## duplicate DaveG's ident-scan thingie using netcat. Oooh, he'll be pissed. | ||
| 5 | ## args: target port [port port port ...] | ||
| 6 | ## hose stdout *and* stderr together. | ||
| 7 | ## | ||
| 8 | ## advantages: runs slower than ident-scan, giving remote inetd less cause | ||
| 9 | ## for alarm, and only hits the few known daemon ports you specify. | ||
| 10 | ## disadvantages: requires numeric-only port args, the output sleazitude, | ||
| 11 | ## and won't work for r-services when coming from high source ports. | ||
| 12 | |||
| 13 | case "${2}" in | ||
| 14 | "" ) echo needs HOST and at least one PORT ; exit 1 ;; | ||
| 15 | esac | ||
| 16 | |||
| 17 | # ping 'em once and see if they *are* running identd | ||
| 18 | nc -z -w 9 "$1" 113 || { echo "oops, $1 isn't running identd" ; exit 0 ; } | ||
| 19 | |||
| 20 | # generate a randomish base port | ||
| 21 | RP=`expr $$ % 999 + 31337` | ||
| 22 | |||
| 23 | TRG="$1" | ||
| 24 | shift | ||
| 25 | |||
| 26 | while test "$1" ; do | ||
| 27 | nc -v -w 8 -p ${RP} "$TRG" ${1} < /dev/null > /dev/null & | ||
| 28 | PROC=$! | ||
| 29 | sleep 3 | ||
| 30 | echo "${1},${RP}" | nc -w 4 -r "$TRG" 113 2>&1 | ||
| 31 | sleep 2 | ||
| 32 | # does this look like a lamer script or what... | ||
| 33 | kill -HUP $PROC | ||
| 34 | RP=`expr ${RP} + 1` | ||
| 35 | shift | ||
| 36 | done | ||
| 37 | |||
diff --git a/src/usr.bin/nc/scripts/ncp b/src/usr.bin/nc/scripts/ncp deleted file mode 100644 index be87e9343b..0000000000 --- a/src/usr.bin/nc/scripts/ncp +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: ncp,v 1.2 2001/01/29 01:58:13 niklas Exp $ | ||
| 3 | |||
| 4 | ## Like "rcp" but uses netcat on a high port. | ||
| 5 | ## do "ncp targetfile" on the RECEIVING machine | ||
| 6 | ## then do "ncp sourcefile receivinghost" on the SENDING machine | ||
| 7 | ## if invoked as "nzp" instead, compresses transit data. | ||
| 8 | |||
| 9 | ## pick your own personal favorite port, which will be used on both ends. | ||
| 10 | ## You should probably change this for your own uses. | ||
| 11 | MYPORT=23456 | ||
| 12 | |||
| 13 | ## if "nc" isn't systemwide or in your PATH, add the right place | ||
| 14 | # PATH=${HOME}:${PATH} ; export PATH | ||
| 15 | |||
| 16 | test "$3" && echo "too many args" && exit 1 | ||
| 17 | test ! "$1" && echo "no args?" && exit 1 | ||
| 18 | me=`echo $0 | sed 's+.*/++'` | ||
| 19 | test "$me" = "nzp" && echo '[compressed mode]' | ||
| 20 | |||
| 21 | # if second arg, it's a host to send an [extant] file to. | ||
| 22 | if test "$2" ; then | ||
| 23 | test ! -f "$1" && echo "can't find $1" && exit 1 | ||
| 24 | if test "$me" = "nzp" ; then | ||
| 25 | compress -c < "$1" | nc -v -w 2 $2 $MYPORT && exit 0 | ||
| 26 | else | ||
| 27 | nc -v -w 2 $2 $MYPORT < "$1" && exit 0 | ||
| 28 | fi | ||
| 29 | echo "transfer FAILED!" | ||
| 30 | exit 1 | ||
| 31 | fi | ||
| 32 | |||
| 33 | # fall here for receiver. Ask before trashing existing files | ||
| 34 | if test -f "$1" ; then | ||
| 35 | echo -n "Overwrite $1? " | ||
| 36 | read aa | ||
| 37 | test ! "$aa" = "y" && echo "[punted!]" && exit 1 | ||
| 38 | fi | ||
| 39 | # 30 seconds oughta be pleeeeenty of time, but change if you want. | ||
| 40 | if test "$me" = "nzp" ; then | ||
| 41 | nc -v -w 30 -p $MYPORT -l < /dev/null | uncompress -c > "$1" && exit 0 | ||
| 42 | else | ||
| 43 | nc -v -w 30 -p $MYPORT -l < /dev/null > "$1" && exit 0 | ||
| 44 | fi | ||
| 45 | echo "transfer FAILED!" | ||
| 46 | # clean up, since even if the transfer failed, $1 is already trashed | ||
| 47 | rm -f "$1" | ||
| 48 | exit 1 | ||
diff --git a/src/usr.bin/nc/scripts/probe b/src/usr.bin/nc/scripts/probe deleted file mode 100644 index 0b647672ea..0000000000 --- a/src/usr.bin/nc/scripts/probe +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: probe,v 1.2 2001/01/29 01:58:13 niklas Exp $ | ||
| 3 | |||
| 4 | ## launch a whole buncha shit at yon victim in no particular order; capture | ||
| 5 | ## stderr+stdout in one place. Run as root for rservice and low -p to work. | ||
| 6 | ## Fairly thorough example of using netcat to collect a lot of host info. | ||
| 7 | ## Will set off every intrusion alarm in existence on a paranoid machine! | ||
| 8 | |||
| 9 | # where .d files are kept; "." if nothing else | ||
| 10 | DDIR=../data | ||
| 11 | # address of some well-connected router that groks LSRR | ||
| 12 | GATE=192.157.69.11 | ||
| 13 | |||
| 14 | # might conceivably wanna change this for different run styles | ||
| 15 | UCMD='nc -v -w 8' | ||
| 16 | |||
| 17 | test ! "$1" && echo Needs victim arg && exit 1 | ||
| 18 | |||
| 19 | echo '' | $UCMD -w 9 -r "$1" 13 79 6667 2>&1 | ||
| 20 | echo '0' | $UCMD "$1" 79 2>&1 | ||
| 21 | # if LSRR was passed thru, should get refusal here: | ||
| 22 | $UCMD -z -r -g $GATE "$1" 6473 2>&1 | ||
| 23 | $UCMD -r -z "$1" 6000 4000-4004 111 53 2105 137-140 1-20 540-550 95 87 2>&1 | ||
| 24 | # -s `hostname` may be wrong for some multihomed machines | ||
| 25 | echo 'UDP echoecho!' | nc -u -p 7 -s `hostname` -w 3 "$1" 7 19 2>&1 | ||
| 26 | echo '113,10158' | $UCMD -p 10158 "$1" 113 2>&1 | ||
| 27 | rservice bin bin | $UCMD -p 1019 "$1" shell 2>&1 | ||
| 28 | echo QUIT | $UCMD -w 8 -r "$1" 25 158 159 119 110 109 1109 142-144 220 23 2>&1 | ||
| 29 | # newline after any telnet trash | ||
| 30 | echo '' | ||
| 31 | echo PASV | $UCMD -r "$1" 21 2>&1 | ||
| 32 | echo 'GET /' | $UCMD -w 10 "$1" 80 81 210 70 2>&1 | ||
| 33 | # sometimes contains useful directory info: | ||
| 34 | echo 'GET /robots.txt' | $UCMD -w 10 "$1" 80 2>&1 | ||
| 35 | # now the big red lights go on | ||
| 36 | rservice bin bin 9600/9600 | $UCMD -p 1020 "$1" login 2>&1 | ||
| 37 | rservice root root | $UCMD -r "$1" exec 2>&1 | ||
| 38 | echo 'BEGIN big udp -- everything may look "open" if packet-filtered' | ||
| 39 | data -g < ${DDIR}/nfs-0.d | $UCMD -i 1 -u "$1" 2049 | od -x 2>&1 | ||
| 40 | # no wait-time, uses RTT hack | ||
| 41 | nc -v -z -u -r "$1" 111 66-70 88 53 87 161-164 121-123 213 49 2>&1 | ||
| 42 | nc -v -z -u -r "$1" 137-140 694-712 747-770 175-180 2103 510-530 2>&1 | ||
| 43 | echo 'END big udp' | ||
| 44 | $UCMD -r -z "$1" 175-180 2000-2003 530-533 1524 1525 666 213 8000 6250 2>&1 | ||
| 45 | # Use our identd-sniffer! | ||
| 46 | iscan "$1" 21 25 79 80 111 53 6667 6000 2049 119 2>&1 | ||
| 47 | # this gets pretty intrusive, but what the fuck. Probe for portmap first | ||
| 48 | if nc -w 5 -z -u "$1" 111 ; then | ||
| 49 | showmount -e "$1" 2>&1 | ||
| 50 | rpcinfo -p "$1" 2>&1 | ||
| 51 | fi | ||
| 52 | exit 0 | ||
diff --git a/src/usr.bin/nc/scripts/web b/src/usr.bin/nc/scripts/web deleted file mode 100644 index 709c5c410f..0000000000 --- a/src/usr.bin/nc/scripts/web +++ /dev/null | |||
| @@ -1,150 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: web,v 1.2 2001/01/29 01:58:13 niklas Exp $ | ||
| 3 | |||
| 4 | ## The web sucks. It is a mighty dismal kludge built out of a thousand | ||
| 5 | ## tiny dismal kludges all band-aided together, and now these bottom-line | ||
| 6 | ## clueless pinheads who never heard of "TCP handshake" want to run | ||
| 7 | ## *commerce* over the damn thing. Ye godz. Welcome to TV of the next | ||
| 8 | ## century -- six million channels of worthless shit to choose from, and | ||
| 9 | ## about as much security as today's cable industry! | ||
| 10 | ## | ||
| 11 | ## Having grown mightily tired of pain in the ass browsers, I decided | ||
| 12 | ## to build the minimalist client. It doesn't handle POST, just GETs, but | ||
| 13 | ## the majority of cgi forms handlers apparently ignore the method anyway. | ||
| 14 | ## A distinct advantage is that it *doesn't* pass on any other information | ||
| 15 | ## to the server, like Referer: or info about your local machine such as | ||
| 16 | ## Netscum tries to! | ||
| 17 | ## | ||
| 18 | ## Since the first version, this has become the *almost*-minimalist client, | ||
| 19 | ## but it saves a lot of typing now. And with netcat as its backend, it's | ||
| 20 | ## totally the balls. Don't have netcat? Get it here in /src/hacks! | ||
| 21 | ## _H* 950824, updated 951009 et seq. | ||
| 22 | ## | ||
| 23 | ## args: hostname [port]. You feed it the filename-parts of URLs. | ||
| 24 | ## In the loop, HOST, PORT, and SAVE do the right things; a null line | ||
| 25 | ## gets the previous spec again [useful for initial timeouts]; EOF to exit. | ||
| 26 | ## Relative URLs behave like a "cd" to wherever the last slash appears, or | ||
| 27 | ## just use the last component with the saved preceding "directory" part. | ||
| 28 | ## "\" clears the "filename" part and asks for just the "directory", and | ||
| 29 | ## ".." goes up one "directory" level while retaining the "filename" part. | ||
| 30 | ## Play around; you'll get used to it. | ||
| 31 | |||
| 32 | if test "$1" = "" ; then | ||
| 33 | echo Needs hostname arg. | ||
| 34 | exit 1 | ||
| 35 | fi | ||
| 36 | umask 022 | ||
| 37 | |||
| 38 | # optional PATH fixup | ||
| 39 | # PATH=${HOME}:${PATH} ; export PATH | ||
| 40 | |||
| 41 | test "${PAGER}" || PAGER=more | ||
| 42 | BACKEND="nc -v -w 15" | ||
| 43 | TMPAGE=/tmp/web$$ | ||
| 44 | host="$1" | ||
| 45 | port="80" | ||
| 46 | if test "$2" != "" ; then | ||
| 47 | port="$2" | ||
| 48 | fi | ||
| 49 | |||
| 50 | spec="/" | ||
| 51 | specD="/" | ||
| 52 | specF='' | ||
| 53 | saving='' | ||
| 54 | |||
| 55 | # be vaguely smart about temp file usage. Use your own homedir if you're | ||
| 56 | # paranoid about someone symlink-racing your shell script, jeez. | ||
| 57 | rm -f ${TMPAGE} | ||
| 58 | test -f ${TMPAGE} && echo "Can't use ${TMPAGE}" && exit 1 | ||
| 59 | |||
| 60 | # get loopy. Yes, I know "echo -n" aint portable. Everything echoed would | ||
| 61 | # need "\c" tacked onto the end in an SV universe, which you can fix yourself. | ||
| 62 | while echo -n "${specD}${specF} " && read spec ; do | ||
| 63 | case $spec in | ||
| 64 | HOST) | ||
| 65 | echo -n 'New host: ' | ||
| 66 | read host | ||
| 67 | continue | ||
| 68 | ;; | ||
| 69 | PORT) | ||
| 70 | echo -n 'New port: ' | ||
| 71 | read port | ||
| 72 | continue | ||
| 73 | ;; | ||
| 74 | SAVE) | ||
| 75 | echo -n 'Save file: ' | ||
| 76 | read saving | ||
| 77 | # if we've already got a page, save it | ||
| 78 | test "${saving}" && test -f ${TMPAGE} && | ||
| 79 | echo "=== ${host}:${specD}${specF} ===" >> $saving && | ||
| 80 | cat ${TMPAGE} >> $saving && echo '' >> $saving | ||
| 81 | continue | ||
| 82 | ;; | ||
| 83 | # changing the logic a bit here. Keep a state-concept of "current dir" | ||
| 84 | # and "current file". Dir is /foo/bar/ ; file is "baz" or null. | ||
| 85 | # leading slash: create whole new state. | ||
| 86 | /*) | ||
| 87 | specF=`echo "${spec}" | sed 's|.*/||'` | ||
| 88 | specD=`echo "${spec}" | sed 's|\(.*/\).*|\1|'` | ||
| 89 | spec="${specD}${specF}" | ||
| 90 | ;; | ||
| 91 | # embedded slash: adding to the path. "file" part can be blank, too | ||
| 92 | */*) | ||
| 93 | specF=`echo "${spec}" | sed 's|.*/||'` | ||
| 94 | specD=`echo "${specD}${spec}" | sed 's|\(.*/\).*|\1|'` | ||
| 95 | ;; | ||
| 96 | # dotdot: jump "up" one level and just reprompt [confirms what it did...] | ||
| 97 | ..) | ||
| 98 | specD=`echo "${specD}" | sed 's|\(.*/\)..*/|\1|'` | ||
| 99 | continue | ||
| 100 | ;; | ||
| 101 | # blank line: do nothing, which will re-get the current one | ||
| 102 | '') | ||
| 103 | ;; | ||
| 104 | # hack-quoted blank line: "\" means just zero out "file" part | ||
| 105 | '\') | ||
| 106 | specF='' | ||
| 107 | ;; | ||
| 108 | # sigh | ||
| 109 | '?') | ||
| 110 | echo Help yourself. Read the script fer krissake. | ||
| 111 | continue | ||
| 112 | ;; | ||
| 113 | # anything else is taken as a "file" part | ||
| 114 | *) | ||
| 115 | specF=${spec} | ||
| 116 | ;; | ||
| 117 | esac | ||
| 118 | |||
| 119 | # now put it together and stuff it down a connection. Some lame non-unix | ||
| 120 | # http servers assume they'll never get simple-query format, and wait till | ||
| 121 | # an extra newline arrives. If you're up against one of these, change | ||
| 122 | # below to (echo GET "$spec" ; echo '') | $BACKEND ... | ||
| 123 | spec="${specD}${specF}" | ||
| 124 | echo GET "${spec}" | $BACKEND $host $port > ${TMPAGE} | ||
| 125 | ${PAGER} ${TMPAGE} | ||
| 126 | |||
| 127 | # save in a format that still shows the URLs we hit after a de-html run | ||
| 128 | if test "${saving}" ; then | ||
| 129 | echo "=== ${host}:${spec} ===" >> $saving | ||
| 130 | cat ${TMPAGE} >> $saving | ||
| 131 | echo '' >> $saving | ||
| 132 | fi | ||
| 133 | done | ||
| 134 | rm -f ${TMPAGE} | ||
| 135 | exit 0 | ||
| 136 | |||
| 137 | ####### | ||
| 138 | # Encoding notes, finally from RFC 1738: | ||
| 139 | # %XX -- hex-encode of special chars | ||
| 140 | # allowed alphas in a URL: $_-.+!*'(), | ||
| 141 | # relative names *not* described, but obviously used all over the place | ||
| 142 | # transport://user:pass@host:port/path/name?query-string | ||
| 143 | # wais: port 210, //host:port/database?search or /database/type/file? | ||
| 144 | # cgi-bin/script?arg1=foo&arg2=bar&... scripts have to parse xxx&yyy&zzz | ||
| 145 | # ISMAP imagemap stuff: /bin/foobar.map?xxx,yyy -- have to guess at coords! | ||
| 146 | # local access-ctl files: ncsa: .htaccess ; cern: .www_acl | ||
| 147 | ####### | ||
| 148 | # SEARCH ENGINES: fortunately, all are GET forms or at least work that way... | ||
| 149 | # multi-word args for most cases: foo+bar | ||
| 150 | # See 'websearch' for concise results of this research... | ||
diff --git a/src/usr.bin/nc/scripts/webproxy b/src/usr.bin/nc/scripts/webproxy deleted file mode 100644 index f670e4d644..0000000000 --- a/src/usr.bin/nc/scripts/webproxy +++ /dev/null | |||
| @@ -1,140 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: webproxy,v 1.2 2001/01/29 01:58:13 niklas Exp $ | ||
| 3 | |||
| 4 | ## Web proxy, following the grand tradition of Web things being handled by | ||
| 5 | ## gross scripts. Uses netcat to listen on a high port [default 8000], | ||
| 6 | ## picks apart requests and sends them on to the right place. Point this | ||
| 7 | ## at the browser client machine you'll be coming from [to limit access to | ||
| 8 | ## only it], and point the browser's concept of an HTTP proxy to the | ||
| 9 | ## machine running this. Takes a single argument of the client that will | ||
| 10 | ## be using it, and rejects connections from elsewhere. LOGS the queries | ||
| 11 | ## to a configurable logfile, which can be an interesting read later on! | ||
| 12 | ## If the argument is "reset", the listener and logfile are cleaned up. | ||
| 13 | ## | ||
| 14 | ## This works surprisingly fast and well, for a shell script, although may | ||
| 15 | ## randomly fail when hammered by a browser that tries to open several | ||
| 16 | ## connections at once. Drop the "maximum connections" in your browser if | ||
| 17 | ## this is a problem. | ||
| 18 | ## | ||
| 19 | ## A more degenerate case of this, or preferably a small C program that | ||
| 20 | ## does the same thing under inetd, could handle a small site's worth of | ||
| 21 | ## proxy queries. Given the way browsers are evolving, proxies like this | ||
| 22 | ## can play an important role in protecting your own privacy. | ||
| 23 | ## | ||
| 24 | ## If you grabbed this in ASCII mode, search down for "eew" and make sure | ||
| 25 | ## the embedded-CR check is intact, or requests might hang. | ||
| 26 | ## | ||
| 27 | ## Doesn't handle POST forms. Who cares, if you're just watching HTTV? | ||
| 28 | ## Dumbness here has a highly desirable side effect: it only sends the first | ||
| 29 | ## GET line, since that's all you really ever need to send, and suppresses | ||
| 30 | ## the other somewhat revealing trash that most browsers insist on sending. | ||
| 31 | |||
| 32 | # set these as you wish: proxy port... | ||
| 33 | PORT=8000 | ||
| 34 | # logfile spec: a real file or /dev/null if you don't care | ||
| 35 | LFILE=${0}.log | ||
| 36 | # optional: where to dump connect info, so you can see if anything went wrong | ||
| 37 | # CFILE=${0}.conn | ||
| 38 | # optional extra args to the listener "nc", for instance "-s inside-net-addr" | ||
| 39 | # XNC='' | ||
| 40 | |||
| 41 | # functionality switch has to be done fast, so the next listener can start | ||
| 42 | # prelaunch check: if no current client and no args, bail. | ||
| 43 | case "${1}${CLIENT}" in | ||
| 44 | "") | ||
| 45 | echo needs client hostname | ||
| 46 | exit 1 | ||
| 47 | ;; | ||
| 48 | esac | ||
| 49 | |||
| 50 | case "${1}" in | ||
| 51 | "") | ||
| 52 | # Make like inetd, and run the next relayer process NOW. All the redirection | ||
| 53 | # is necessary so this shell has NO remaining channel open to the net. | ||
| 54 | # This will hang around for 10 minutes, and exit if no new connections arrive. | ||
| 55 | # Using -n for speed, avoiding any DNS/port lookups. | ||
| 56 | nc -w 600 -n -l -p $PORT -e "$0" $XNC "$CLIENT" < /dev/null > /dev/null \ | ||
| 57 | 2> $CFILE & | ||
| 58 | ;; | ||
| 59 | esac | ||
| 60 | |||
| 61 | # no client yet and had an arg, this checking can be much slower now | ||
| 62 | umask 077 | ||
| 63 | |||
| 64 | if test "$1" ; then | ||
| 65 | # if magic arg, just clean up and then hit our own port to cause server exit | ||
| 66 | if test "$1" = "reset" ; then | ||
| 67 | rm -f $LFILE | ||
| 68 | test -f "$CFILE" && rm -f $CFILE | ||
| 69 | nc -w 1 -n 127.0.0.1 $PORT < /dev/null > /dev/null 2>&1 | ||
| 70 | exit 0 | ||
| 71 | fi | ||
| 72 | # find our ass with both hands | ||
| 73 | test ! -f "$0" && echo "Oops, cannot find my own corporeal being" && exit 1 | ||
| 74 | # correct launch: set up client access control, passed along thru environment. | ||
| 75 | CLIENT="$1" | ||
| 76 | export CLIENT | ||
| 77 | test "$CFILE" || CFILE=/dev/null | ||
| 78 | export CFILE | ||
| 79 | touch "$CFILE" | ||
| 80 | # tell us what happened during the last run, if possible | ||
| 81 | if test -f "$CFILE" ; then | ||
| 82 | echo "Last connection results:" | ||
| 83 | cat $CFILE | ||
| 84 | fi | ||
| 85 | |||
| 86 | # ping client machine and get its bare IP address | ||
| 87 | CLIENT=`nc -z -v -w 8 "$1" 22000 2>&1 | sed 's/.*\[\(..*\)\].*/\1/'` | ||
| 88 | test ! "$CLIENT" && echo "Can't find address of $1" && exit 1 | ||
| 89 | |||
| 90 | # if this was an initial launch, be informative about it | ||
| 91 | echo "=== Launch: $CLIENT" >> $LFILE | ||
| 92 | echo "Proxy running -- will accept connections on $PORT from $CLIENT" | ||
| 93 | echo " Logging queries to $LFILE" | ||
| 94 | test -f "$CFILE" && echo " and connection fuckups to $CFILE" | ||
| 95 | |||
| 96 | # and run the first listener, showing us output just for the first hit | ||
| 97 | nc -v -w 600 -n -l -p $PORT -e "$0" $XNC "$CLIENT" & | ||
| 98 | exit 0 | ||
| 99 | fi | ||
| 100 | |||
| 101 | # Fall here to handle a page. | ||
| 102 | # GET type://host.name:80/file/path HTTP/1.0 | ||
| 103 | # Additional: trash | ||
| 104 | # More: trash | ||
| 105 | # <newline> | ||
| 106 | |||
| 107 | read x1 x2 x3 x4 | ||
| 108 | echo "=== query: $x1 $x2 $x3 $x4" >> $LFILE | ||
| 109 | test "$x4" && echo "extra junk after request: $x4" && exit 0 | ||
| 110 | # nuke questionable characters and split up the request | ||
| 111 | hurl=`echo "$x2" | sed -e "s+.*//++" -e 's+[\`'\''|$;<>{}\\!*()"]++g'` | ||
| 112 | # echo massaged hurl: $hurl >> $LFILE | ||
| 113 | hh=`echo "$hurl" | sed -e "s+/.*++" -e "s+:.*++"` | ||
| 114 | hp=`echo "$hurl" | sed -e "s+.*:++" -e "s+/.*++"` | ||
| 115 | test "$hp" = "$hh" && hp=80 | ||
| 116 | hf=`echo "$hurl" | sed -e "s+[^/]*++"` | ||
| 117 | # echo total split: $hh : $hp : $hf >> $LFILE | ||
| 118 | # suck in and log the entire request, because we're curious | ||
| 119 | # Fails on multipart stuff like forms; oh well... | ||
| 120 | if test "$x3" ; then | ||
| 121 | while read xx ; do | ||
| 122 | echo "${xx}" >> $LFILE | ||
| 123 | test "${xx}" || break | ||
| 124 | # eew, buried returns, gross but necessary for DOS stupidity: | ||
| 125 | test "${xx}" = " " && break | ||
| 126 | done | ||
| 127 | fi | ||
| 128 | # check for non-GET *after* we log the query... | ||
| 129 | test "$x1" != "GET" && echo "sorry, this proxy only does GETs" && exit 0 | ||
| 130 | # no, you can *not* phone home, you miserable piece of shit | ||
| 131 | test "`echo $hh | fgrep -i netscap`" && \ | ||
| 132 | echo "access to Netscam's servers <b>DENIED.</b>" && exit 0 | ||
| 133 | # Do it. 30 sec net-wait time oughta be *plenty*... | ||
| 134 | # Some braindead servers have forgotten how to handle the simple-query syntax. | ||
| 135 | # If necessary, replace below with (echo "$x1 $hf" ; echo '') | nc... | ||
| 136 | echo "$x1 $hf" | nc -w 30 "$hh" "$hp" 2> /dev/null || \ | ||
| 137 | echo "oops, can't get to $hh : $hp". | ||
| 138 | echo "sent \"$x1 $hf\" to $hh : $hp" >> $LFILE | ||
| 139 | exit 0 | ||
| 140 | |||
diff --git a/src/usr.bin/nc/scripts/webrelay b/src/usr.bin/nc/scripts/webrelay deleted file mode 100644 index a0aa9e2a97..0000000000 --- a/src/usr.bin/nc/scripts/webrelay +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: webrelay,v 1.2 2001/01/29 01:58:13 niklas Exp $ | ||
| 3 | |||
| 4 | ## web relay -- a degenerate version of webproxy, usable with browsers that | ||
| 5 | ## don't understand proxies. This just forwards connections to a given server. | ||
| 6 | ## No query logging, no access control [although you can add it to XNC for | ||
| 7 | ## your own run], and full-URL links will undoubtedly confuse the browser | ||
| 8 | ## if it can't reach the server directly. This was actually written before | ||
| 9 | ## the full proxy was, and it shows. | ||
| 10 | ## The arguments in this case are the destination server and optional port. | ||
| 11 | ## Please flame pinheads who use self-referential absolute links. | ||
| 12 | |||
| 13 | # set these as you wish: proxy port... | ||
| 14 | PORT=8000 | ||
| 15 | # any extra args to the listening "nc", for instance "-s inside-net-addr" | ||
| 16 | XNC='' | ||
| 17 | |||
| 18 | # functionality switch, which has to be done fast to start the next listener | ||
| 19 | case "${1}${RDEST}" in | ||
| 20 | "") | ||
| 21 | echo needs hostname | ||
| 22 | exit 1 | ||
| 23 | ;; | ||
| 24 | esac | ||
| 25 | |||
| 26 | case "${1}" in | ||
| 27 | "") | ||
| 28 | # no args: fire off new relayer process NOW. Will hang around for 10 minutes | ||
| 29 | nc -w 600 -l -n -p $PORT -e "$0" $XNC < /dev/null > /dev/null 2>&1 & | ||
| 30 | # and handle this request, which will simply fail if vars not set yet. | ||
| 31 | exec nc -w 15 $RDEST $RPORT | ||
| 32 | ;; | ||
| 33 | esac | ||
| 34 | |||
| 35 | # Fall here for setup; this can now be slower. | ||
| 36 | RDEST="$1" | ||
| 37 | RPORT="$2" | ||
| 38 | test "$RPORT" || RPORT=80 | ||
| 39 | export RDEST RPORT | ||
| 40 | |||
| 41 | # Launch the first relayer same as above, but let its error msgs show up | ||
| 42 | # will hang around for a minute, and exit if no new connections arrive. | ||
| 43 | nc -v -w 600 -l -p $PORT -e "$0" $XNC < /dev/null > /dev/null & | ||
| 44 | echo \ | ||
| 45 | "Relay to ${RDEST}:${RPORT} running -- point your browser here on port $PORT" | ||
| 46 | exit 0 | ||
diff --git a/src/usr.bin/nc/scripts/websearch b/src/usr.bin/nc/scripts/websearch deleted file mode 100644 index 9391c77bde..0000000000 --- a/src/usr.bin/nc/scripts/websearch +++ /dev/null | |||
| @@ -1,79 +0,0 @@ | |||
| 1 | #! /bin/sh | ||
| 2 | # $OpenBSD: websearch,v 1.2 2001/01/29 01:58:13 niklas Exp $ | ||
| 3 | |||
| 4 | ## Hit the major search engines. Hose the [large] output to a file! | ||
| 5 | ## autoconverts multiple arguments into the right format for given servers -- | ||
| 6 | ## usually worda+wordb, with certain lame exceptions like dejanews. | ||
| 7 | ## Extracting and post-sorting the URLs is highly recommended... | ||
| 8 | ## | ||
| 9 | ## Altavista currently handled by a separate script; may merge at some point. | ||
| 10 | ## | ||
| 11 | ## _H* original 950824, updated 951218 and 960209 | ||
| 12 | |||
| 13 | test "${1}" = "" && echo 'Needs argument[s] to search for!' && exit 1 | ||
| 14 | PLUSARG="`echo $* | sed 's/ /+/g'`" | ||
| 15 | PIPEARG="`echo ${PLUSARG} | sed 's/+/|/g'`" | ||
| 16 | IFILE=/tmp/.webq.$$ | ||
| 17 | |||
| 18 | # Don't have "nc"? Get "netcat" from avian.org and add it to your toolkit. | ||
| 19 | doquery () { | ||
| 20 | echo GET "$1" | nc -v -i 1 -w 30 "$2" "$3" | ||
| 21 | } | ||
| 22 | |||
| 23 | # changed since original: now supplying port numbers and separator lines... | ||
| 24 | |||
| 25 | echo "=== Yahoo ===" | ||
| 26 | doquery "/bin/search?p=${PLUSARG}&n=300&w=w&s=a" search.yahoo.com 80 | ||
| 27 | |||
| 28 | echo '' ; echo "=== Webcrawler ===" | ||
| 29 | doquery "/cgi-bin/WebQuery?searchText=${PLUSARG}&maxHits=300" webcrawler.com 80 | ||
| 30 | |||
| 31 | # the infoseek lamers want "registration" before they do a real search, but... | ||
| 32 | echo '' ; echo "=== Infoseek ===" | ||
| 33 | echo " is broken." | ||
| 34 | # doquery "WW/IS/Titles?qt=${PLUSARG}" www2.infoseek.com 80 | ||
| 35 | # ... which doesn't work cuz their lame server wants the extra newlines, WITH | ||
| 36 | # CRLF pairs ferkrissake. Fuck 'em for now, they're hopelessly broken. If | ||
| 37 | # you want to play, the basic idea and query formats follow. | ||
| 38 | # echo "GET /WW/IS/Titles?qt=${PLUSARG}" > $IFILE | ||
| 39 | # echo "" >> $IFILE | ||
| 40 | # nc -v -w 30 guide-p.infoseek.com 80 < $IFILE | ||
| 41 | |||
| 42 | # this is kinda flakey; might have to do twice?? | ||
| 43 | echo '' ; echo "=== Opentext ===" | ||
| 44 | doquery "/omw/simplesearch?SearchFor=${PLUSARG}&mode=phrase" \ | ||
| 45 | search.opentext.com 80 | ||
| 46 | |||
| 47 | # looks like inktomi will only take hits=100, or defaults back to 30 | ||
| 48 | # we try to suppress all the stupid rating dots here, too | ||
| 49 | echo '' ; echo "=== Inktomi ===" | ||
| 50 | doquery "/query/?query=${PLUSARG}&hits=100" ink3.cs.berkeley.edu 1234 | \ | ||
| 51 | sed '/^<IMG ALT.*inktomi.*\.gif">$/d' | ||
| 52 | |||
| 53 | #djnews lame shit limits hits to 120 and has nonstandard format | ||
| 54 | echo '' ; echo "=== Dejanews ===" | ||
| 55 | doquery "/cgi-bin/nph-dnquery?query=${PIPEARG}+maxhits=110+format=terse+defaultOp=AND" \ | ||
| 56 | smithers.dejanews.com 80 | ||
| 57 | |||
| 58 | # OLD lycos: used to work until they fucking BROKE it... | ||
| 59 | # doquery "/cgi-bin/pursuit?query=${PLUSARG}&maxhits=300&terse=1" \ | ||
| 60 | # query5.lycos.cs.cmu.edu 80 | ||
| 61 | # NEW lycos: wants the User-agent field present in query or it returns nothing | ||
| 62 | # 960206: webmaster@lycos duly bitched at | ||
| 63 | # 960208: reply received; here's how we will now handle it: | ||
| 64 | echo \ | ||
| 65 | "GET /cgi-bin/pursuit?query=${PLUSARG}&maxhits=300&terse=terse&matchmode=and&minscore=.5 HTTP/1.x" \ | ||
| 66 | > $IFILE | ||
| 67 | echo "User-agent: *FUCK OFF*" >> $IFILE | ||
| 68 | echo "Why: go ask todd@pointcom.com (Todd Whitney)" >> $IFILE | ||
| 69 | echo '' >> $IFILE | ||
| 70 | echo '' ; echo "=== Lycos ===" | ||
| 71 | nc -v -i 1 -w 30 twelve.srv.lycos.com 80 < $IFILE | ||
| 72 | |||
| 73 | rm -f $IFILE | ||
| 74 | exit 0 | ||
| 75 | |||
| 76 | # CURRENTLY BROKEN [?] | ||
| 77 | # infoseek | ||
| 78 | |||
| 79 | # some args need to be redone to ensure whatever "and" mode applies | ||
