diff -urbN netcat/Makefile nc/Makefile --- netcat/Makefile Wed Mar 20 12:16:06 1996 +++ nc/Makefile Mon Jan 29 11:07:19 2001 @@ -9,9 +9,11 @@ # pick gcc if you'd rather , and/or do -g instead of -O if debugging # debugging # DFLAGS = -DTEST -DDEBUG -CFLAGS = -O +#CFLAGS = -O +# it's not so gaping if you do strong authentication... +CFLAGS = -O -DGAPING_SECURITY_HOLE -DTINYSRP XFLAGS = # xtra cflags, set by systype targets -XLIBS = # xtra libs if necessary? +XLIBS = -ltinysrp # xtra libs if necessary? # -Bstatic for sunos, -static for gcc, etc. You want this, trust me. STATIC = CC = cc $(CFLAGS) diff -urbN netcat/netcat.c nc/netcat.c --- netcat/netcat.c Thu Mar 21 09:38:04 1996 +++ nc/netcat.c Sat Jan 27 21:19:48 2001 @@ -83,6 +83,13 @@ #define USHORT unsigned short /* use these for options an' stuff */ #define BIGSIZ 8192 /* big buffers */ +#ifdef TINYSRP +#include +USHORT o_tsrp = 0; /* flag that we want to do authentication */ +char *tuser = NULL; /* username to authenticate */ +TSRP_SESSION tsrp_s; /* filled in with user & session key */ +#endif + #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff #endif @@ -751,6 +758,11 @@ errno = ETIMEDOUT; /* fake it */ } arm (0, 0); +#if TINYSRP +/* do SRP authentication */ + if (o_tsrp && !tsrp_client_authenticate(nnetfd, tuser, NULL, &tsrp_s)) + bail ("authentication failed"); +#endif if (rr == 0) return (nnetfd); close (nnetfd); /* clean up junked socket FD!! */ @@ -923,8 +935,17 @@ if (x) /* guilty! */ bail ("invalid connection to [%s] from %s [%s] %d", cp, whozis->name, whozis->addrs[0], z); +#ifdef TINYSRP +/* do SRP authentication */ + if (o_tsrp && !tsrp_server_authenticate(nnetfd, &tsrp_s)) + bail ("authentication failed to [%s] from %s [%s] %d", + cp, whozis->name, whozis->addrs[0], z); + holler ("%s connect to [%s] from %s [%s] %d", + tsrp_s.username, cp, whozis->name, whozis->addrs[0], z); +#else holler ("connect to [%s] from %s [%s] %d", /* oh, you're okay.. */ cp, whozis->name, whozis->addrs[0], z); +#endif return (nnetfd); /* open! */ dol_tmo: @@ -1389,7 +1410,7 @@ /* If your shitbox doesn't have getopt, step into the nineties already. */ /* optarg, optind = next-argv-component [i.e. flag arg]; optopt = last-char */ - while ((x = getopt (argc, argv, "ae:g:G:hi:lno:p:rs:tuvw:z")) != EOF) { + while ((x = getopt (argc, argv, "ae:g:G:hi:lLno:p:rs:tuU:vw:z")) != EOF) { /* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */ switch (x) { case 'a': @@ -1431,6 +1452,12 @@ break; case 'l': /* listen mode */ o_listen++; break; +#ifdef TINYSRP + case 'L': /* SRP authentication in listen mode */ + o_tsrp++; + o_listen++; + break; +#endif case 'n': /* numeric-only, no DNS lookups */ o_nflag++; break; case 'o': /* hexdump log */ @@ -1456,6 +1483,12 @@ #endif /* TELNET */ case 'u': /* use UDP */ o_udpmode++; break; +#ifdef TINYSRP + case 'U': /* SRP authenticate as user */ + o_tsrp++; + tuser = optarg; + break; +#endif case 'v': /* verbose */ o_verbose++; break; case 'w': /* wait time */ @@ -1489,6 +1522,10 @@ ofd = 0; } #endif /* G_S_H */ +#ifdef TINYSRP + if (o_tsrp && tuser && o_listen) /* both -L and -U */ + bail ("can't specify -L with -U"); +#endif if (o_wfile) { ofd = open (stage, O_WRONLY | O_CREAT | O_TRUNC, 0664); if (ofd <= 0) /* must be > extant 0/1/2 */ @@ -1646,7 +1683,12 @@ -G num source-routing pointer: 4, 8, 12, ...\n\ -h this cruft\n\ -i secs delay interval for lines sent, ports scanned\n\ - -l listen mode, for inbound connects\n\ + -l listen mode, for inbound connects"); +#ifdef TINYSRP + holler ("\ + -L listen mode, with TSRP authentication"); +#endif + holler ("\ -n numeric-only IP addresses, no DNS\n\ -o file hex dump of traffic\n\ -p port local port number\n\ @@ -1657,7 +1699,12 @@ -t answer TELNET negotiation"); #endif holler ("\ - -u UDP mode\n\ + -u UDP mode"); +#ifdef TINYSRP + holler ("\ + -U user TSRP authenticate as user (outbound only)"); +#endif + holler ("\ -v verbose [use twice to be more verbose]\n\ -w secs timeout for connects and final net reads\n\ -z zero-I/O mode [used for scanning]"); diff -urbN netcat/scripts/dorlogin nc/scripts/dorlogin --- netcat/scripts/dorlogin Thu Jan 1 09:00:00 1970 +++ nc/scripts/dorlogin Wed Apr 28 17:38:08 1999 @@ -0,0 +1,3 @@ +#! /bin/sh + +exec rlogin -8 -E localhost diff -urbN netcat/scripts/srpcli nc/scripts/srpcli --- netcat/scripts/srpcli Thu Jan 1 09:00:00 1970 +++ nc/scripts/srpcli Mon Jan 29 11:19:17 2001 @@ -0,0 +1,13 @@ +#! /bin/sh + +usage="usage: $0 user host [port]" +test "${1}" = "" && echo $usage && exit 1 +user="${1}" +test "${2}" = "" && echo $usage && exit 1 +host="${2}" +port=1234 +test "${3}" && port="${3}" + +stty raw -icanon -echo +nc -U $user $host $port +stty sane diff -urbN netcat/scripts/srpsrv nc/scripts/srpsrv --- netcat/scripts/srpsrv Thu Jan 1 09:00:00 1970 +++ nc/scripts/srpsrv Mon Jan 29 11:13:20 2001 @@ -0,0 +1,25 @@ +#! /bin/sh + +# This will wait around for connections on the specified port, and +# SRP authenticate them based on the tpasswd file (which defaults to +# being in the current directory unless you changed it in libtinysrp). +# If the authentication is successful, they get a login shell. +# Set scripts to this directory, and, depending on your rlogin, you +# may have to put a line in your ~/.rhosts file that looks like +# localhost + +# The default tpasswd file in this directory contains one user "ncuser" +# with the password "this is not a good password". + +scripts=. +log=/dev/null +#rm -f $log + +port=1234 +test "${1}" && port="${1}" + +while true; do + nc -v -L -p $port -e $scripts/dorlogin >> $log 2>&1 +done + +# you'll have to kill the shell as well as the nc when you want to shut down... diff -urbN netcat/scripts/tpasswd nc/scripts/tpasswd --- netcat/scripts/tpasswd Thu Jan 1 09:00:00 1970 +++ nc/scripts/tpasswd Mon Jan 29 11:11:58 2001 @@ -0,0 +1 @@ +ncuser:2kSQgvzm0abfMz2u1cBBsYh7U8k3N1T/yz0CB3Z7HSv4y/Ri8Hs2M39A2veEaK.KeT7kItYvpDRDIt8LHarmTrr.eU7sl1mEOPUtALRJakXL7DKoeuo2gd2ZZdVogO6JqK2.uES5pqvXxi1UKG62YEgwl4//Xlk2/eYO6HGMDLn:1XM71UYPDAEm91:5
Make your own free website on Tripod.com