diff -Nu ../nc110/Makefile ./Makefile --- ../nc110/Makefile Wed Mar 20 03:16:06 1996 +++ ./Makefile Thu Sep 5 17:52:04 2002 @@ -9,6 +9,7 @@ # pick gcc if you'd rather , and/or do -g instead of -O if debugging # debugging # DFLAGS = -DTEST -DDEBUG +DFLAGS = -DTELNET CFLAGS = -O XFLAGS = # xtra cflags, set by systype targets XLIBS = # xtra libs if necessary? @@ -67,7 +68,7 @@ make -e $(ALL) $(MFLAGS) XFLAGS='-DAIX' linux: - make -e $(ALL) $(MFLAGS) XFLAGS='-DLINUX' STATIC=-static + make -e $(ALL) $(MFLAGS) XFLAGS='-DLINUX' # irix 5.2, dunno 'bout earlier versions. If STATIC='-non_shared' doesn't # work for you, null it out and yell at SGI for their STUPID default @@ -108,6 +109,11 @@ # Nexstep from mudge: NeXT cc is really old gcc next: make -e $(ALL) $(MFLAGS) XFLAGS='-DNEXT' STATIC=-Bstatic + +# cygwin Unix-emulationlayer for Win9x/NT/... +cygwin: + make -e $(ALL) $(MFLAGS) XFLAGS='-DCYGWIN' STATIC= CC=gcc + # start with this for a new architecture, and see what breaks. generic: @@ -118,5 +124,5 @@ ### RANDOM clean: - rm -f $(ALL) *.o *.obj + rm -f $(ALL) *.o *.obj *.exe diff -Nu ../nc110/changelog.debian ./changelog.debian --- ../nc110/changelog.debian Thu Jan 1 01:00:00 1970 +++ ./changelog.debian Thu Sep 5 16:48:40 2002 @@ -0,0 +1,84 @@ +*************** +*** 1,81 **** +- netcat (1.10-12.1) frozen unstable; urgency=low +- +- * Non-maintained upload. +- * Rename arm() to arm_timer() (Closes: #56390) +- +- -- Edward Brocklesby Tue, 22 Feb 2000 12:59:12 +0000 +- +- netcat (1.10-12) unstable; urgency=low +- +- * Fixed bugs #45669 and #45675 (removed extraneous sleep(1) command and also removed +- * the "punt!" message; added -q feature) +- +- -- Robert S. Edmonds Wed, 22 Sep 1999 19:29:47 -0400 +- +- netcat (1.10-11) unstable; urgency=low +- +- * Applied patch from Graham Stoney that fixes deadlock +- * if the server doesn't close its end until it reads EOF on the connection +- +- -- Robert S. Edmonds Mon, 13 Sep 1999 21:53:59 -0400 +- +- netcat (1.10-10) unstable; urgency=low +- +- * Man page fixed (/usr/doc/netcat/README.gz). Fixes bug #35811 +- +- -- Robert S. Edmonds Sat, 12 Jun 1999 15:21:31 -0400 +- +- netcat (1.10-9) unstable; urgency=low +- +- * Compiled with -DTELNET. +- +- -- Robert S. Edmonds Wed, 4 Nov 1998 09:27:40 -0500 +- +- netcat (1.10-8) unstable frozen; urgency=low +- +- * At the request of many users (and a few bug reports) the binary is now +- * going to be called "nc" as it always was. +- +- -- Robert S. Edmonds Sun, 26 Apr 1998 19:36:00 -0400 +- +- netcat (1.10-7) unstable; urgency=low +- +- * Fixed lintian error possible-name-space-pollution. (binary nc -> netcat) +- +- -- Robert S. Edmonds Mon, 30 Mar 1998 19:11:49 -0500 +- +- netcat (1.10-6) unstable; urgency=low +- +- * Upgraded to Standards-Version 2.4.0.0. +- +- -- Robert S. Edmonds Tue, 17 Feb 1998 13:06:22 -0500 +- +- netcat (1.10-5) unstable; urgency=low +- +- * Merged in changes from Robert Woodcock . +- - Man page updates. +- - Compiled with -DTELNET +- * Removed bogus menu file. +- * Full source upload. +- +- -- Joey Hess Sat, 10 Jan 1998 13:53:59 -0500 +- +- netcat (1.10-4) unstable; urgency=low +- +- * Updated to "new" source format. (#9489) +- * Libc6. (#11716) +- * Orphaned the package. +- * Fixed up description in control file to conform with policy, short +- description doesn't include package name now. +- * Fixed documentation location to comply with current policy. (#13194, +- #11530, #9785) +- * Wrote a man page. (#9785, #5304, #6647) +- * Rewrote debian/rules to use debhelper. +- * Install upstream changelog. +- +- -- Joey Hess Sat, 10 Jan 1998 00:53:45 -0500 +- +- Local variables: +- mode: debian-changelog +- add-log-mailing-address: "stu@novare.net" +- End: +--- 0 ---- diff -Nu ../nc110/compress ./compress --- ../nc110/compress Thu Jan 1 01:00:00 1970 +++ ./compress Thu Sep 5 16:47:38 2002 @@ -0,0 +1,6 @@ +# Tell dh_compress to ignore the examples/ directory. +find usr/info usr/man usr/X11*/man -type f +find usr/doc -type f \ + \( -size +4k -or -name "changelog*" \) \ + ! -name "*.htm*" ! -name "*.gif" \ + ! -name "copyright" | grep -v examples diff -Nu ../nc110/control ./control --- ../nc110/control Thu Jan 1 01:00:00 1970 +++ ./control Thu Sep 5 16:48:40 2002 @@ -0,0 +1,17 @@ +Source: netcat +Section: net +Priority: optional +Maintainer: Robert S. Edmonds +Standards-Version: 2.4.1.0 + +Package: netcat +Architecture: any +Depends: ${shlibs:Depends} +Description: TCP/IP swiss army knife + A simple Unix utility which reads and writes data across network + connections using TCP or UDP protocol. It is designed to be a reliable + "back-end" tool that can be used directly or easily driven by other + programs and scripts. At the same time it is a feature-rich network + debugging and exploration tool, since it can create almost any kind of + connection you would need and has several interesting built-in + capabilities. diff -Nu ../nc110/copyright ./copyright --- ../nc110/copyright Thu Jan 1 01:00:00 1970 +++ ./copyright Thu Sep 5 16:48:40 2002 @@ -0,0 +1,72 @@ +This is the CrossLink/Debian prepackaged version of *Hobbit*'s pretty +nifty "TCP/IP swiss army knife", netcat. + +CrossLink's Debian packages are maintained by Michael Shields +; their development is supported by CrossLink +Internet Access and Networking Services, http://www.crosslink.net or ++1 703 642 1120 x154. + +The `netcat.blurb' file is appended. + +----- +Netcat 1.10 is an updated release of Netcat, a simple Unix utility which reads +and writes data across network connections using TCP or UDP protocol. It is +designed to be a reliable "back-end" tool that can be used directly or easily +driven by other programs and scripts. At the same time it is a feature-rich +network debugging and exploration tool, since it can create almost any kind of +connection you would need and has several interesting built-in capabilities. + +Some of netcat's major features are: + + Outbound or inbound connections, TCP or UDP, to or from any ports + Full DNS forward/reverse checking, with appropriate warnings + Ability to use any local source port + Ability to use any locally-configured network source address + Built-in port-scanning capabilities, with randomizer + Built-in loose source-routing capability + Can read command line arguments from standard input + Slow-send mode, one line every N seconds + Hex dump of transmitted and received data + Optional ability to let another program service established connections + Optional telnet-options responder + +A very short list of potential uses: + + Script backends + Scanning ports and inventorying services, automated probes + Backup handlers + File transfers + Server testing, simulation, debugging, and hijacking + Firewall testing + Proxy gatewaying + Network performance testing + Address spoofing tests + Protecting X servers + 1001 other uses you'll likely come up with + +Changes between the 1.00 release and this release: + + Better portability -- updated generic.h and Makefile [thanx folks!] + Indication of local-end interface address on inbound connections + That's *Dave* Borman's telnet, not Paul Borman... + Better indication of DNS errors + Total byte counts printed if -v -v is used + A bunch of front-end driver companion programs and scripts + Better handling of stdin arguments-plus-data + Hex-dump feature + Telnet responder + Program exec works inbound or outbound now + +Netcat and the associated package is a product of Avian Research, and is freely +available in full source form with no restrictions save an obligation to give +credit where due. Get it via anonymous FTP at avian.org:/src/hacks/nc110.tgz +which is a gzipped tar file and not to be confused with its version 1.00 +precursor, nc100.tgz. Other distribution formats can be accomodated upon +request. Netcat is also mirrored at the following [faster] sites: + + zippy.telcom.arizona.edu:/pub/mirrors/avian.org/hacks/nc110.tgz + ftp.sterling.com:/mirrors/avian.org/src/hacks/nc110.tgz + coast.cs.purdue.edu:/pub/tools/unix/netcat/nc110.tgz + ftp.rge.com:/pub/security/coast/mirrors/avian.org/netcat/nc110.tgz + +_H* 960320 Common subdirectories: ../nc110/data and ./data diff -Nu ../nc110/generic.h ./generic.h --- ../nc110/generic.h Sun Feb 18 01:36:44 1996 +++ ./generic.h Thu Sep 5 17:00:17 2002 @@ -70,6 +70,9 @@ /* a sysvism, I think, but ... */ #define HAVE_SYSINFO +/* not found on cygwin as far as i know (kahl@informatik.uni-kl.de) */ +#define HAVE_RES_INIT + /* ============= */ /* Include files */ /* ============= */ @@ -359,6 +362,19 @@ #undef UTMPX #undef HAVE_SELECT_X #endif /* NeXTSTEP 3.2 motorola */ + +/* cygwin unix-emulation-layer formWin9x/NT/... + * they try to be posix and linux compatible... */ +#ifdef CYGWIN +#undef UTMPX +#undef HAVE_SYSINFO +#undef HAVE_SELECT_H +#undef HAVE_TTYENT_H +#define HAVE_NO_LSRR +#define HAVE_NO_NOP +#undef HAVE_RES_INIT +#endif /* cygwin */ + /* Make some "generic" assumptions if all else fails */ #ifdef GENERIC diff -Nu ../nc110/nc.1 ./nc.1 --- ../nc110/nc.1 Thu Jan 1 01:00:00 1970 +++ ./nc.1 Thu Sep 5 16:48:40 2002 @@ -0,0 +1,134 @@ +.TH NC 1 +.SH NAME +nc \- TCP/IP swiss army knife +.SH SYNOPSIS +.B nc +.I "[-options] hostname port[s] [ports] ..." +.br +.B nc +.I "-l -p port [-options] [hostname] [port]" +.SH "DESCRIPTION" +.B netcat +is a simple unix utility which reads and writes data across network +connections, using TCP or UDP protocol. It is designed to be a reliable +"back-end" tool that can be used directly or easily driven by other programs +and scripts. At the same time, it is a feature-rich network debugging and +exploration tool, since it can create almost any kind of connection you +would need and has several interesting built-in capabilities. Netcat, or +"nc" as the actual program is named, should have been supplied long ago as +another one of those cryptic but standard Unix tools. +.P +In the simplest usage, "nc host port" creates a TCP connection to the given +port on the given target host. Your standard input is then sent to the host, +and anything that comes back across the connection is sent to your standard +output. This continues indefinitely, until the network side of the connection +shuts down. Note that this behavior is different from most other applications +which shut everything down and exit after an end-of-file on the standard input. +.P +Netcat can also function as a server, by listening for inbound connections +on arbitrary ports and then doing the same reading and writing. With minor +limitations, netcat doesn't really care if it runs in "client" or "server" +mode -- it still shovels data back and forth until there isn't any more +left. In either mode, shutdown can be forced after a configurable time of +inactivity on the network side. +.P +And it can do this via UDP too, so netcat is possibly the "udp telnet-like" +application you always wanted for testing your UDP-mode servers. UDP, as +the "U" implies, gives less reliable data transmission than TCP connections +and some systems may have trouble sending large amounts of data that way, but +it's still a useful capability to have. +.P +You may be asking "why not just use telnet to connect to arbitrary ports?" +Valid question, and here are some reasons. Telnet has the "standard input +EOF" problem, so one must introduce calculated delays in driving scripts to +allow network output to finish. This is the main reason netcat stays running +until the *network* side closes. Telnet also will not transfer arbitrary +binary data, because certain characters are interpreted as telnet options +and are thus removed from the data stream. Telnet also emits some of its +diagnostic messages to standard output, where netcat keeps such things +religiously separated from its *output* and will never modify any of the +real data in transit unless you *really* want it to. And of course telnet is +incapable of listening for inbound connections, or using UDP instead. Netcat +doesn't have any of these limitations, is much smaller and faster than telnet, +and has many other advantages. +.SH OPTIONS +.TP 13 +.I \-g gateway +source-routing hop point[s], up to 8 +.TP 13 +.I \-G num +source-routing pointer: 4, 8, 12, ... +.TP 13 +.I \-h +Display help. +.TP 13 +.I \-i secs +delay interval for lines sent, ports scanned +.TP 13 +.I \-l +listen mode, for inbound connects +.TP 13 +.I \-n +numeric-only IP addresses, no DNS +.TP 13 +.I \-o file +hex dump of traffic +.TP 13 +.I \-p port +local port number +(port numbers can be individual or ranges: lo-hi [inclusive]) +.TP 13 +.I \-q seconds +Quit after EOF is detected on stdin and after a delay. "-q 0" makes "nc" +quit as soon as EOF is detected. +.TP 13 +.I \-r +randomize local and remote ports +.TP 13 +.I \-s addr +local source address +.TP 13 +.I \-t +Enable telnet negotiation +.TP 13 +.I \-u +UDP mode +.TP 13 +.I \-v +verbose [use twice to be more verbose] +.TP 13 +.I \-w secs +timeout for connects and final net reads +.TP 13 +.I \-z +zero-I/O mode [used for scanning] +.SH COPYRIGHT +Netcat is entirely my own creation, although plenty of other code was used as +examples. It is freely given away to the Internet community in the hope that +it will be useful, with no restrictions except giving credit where it is due. +No GPLs, Berkeley copyrights or any of that nonsense. The author assumes NO +responsibility for how anyone uses it. If netcat makes you rich somehow and +you're feeling generous, mail me a check. If you are affiliated in any way +with Microsoft Network, get a life. Always ski in control. Comments, +questions, and patches to hobbit@avian.org. +.SH BUGS +Efforts have been made to have netcat "do the right thing" in all its +various modes. If you believe that it is doing the wrong thing under whatever +circumstances, please notify me and tell me how you think it should behave. +If netcat is not able to do some task you think up, minor tweaks to the code +will probably fix that. It provides a basic and easily-modified template for +writing other network applications, and I certainly encourage people to make +custom mods and send in any improvements they make to it. Continued feedback +from the Internet community is always welcome! +.P +Some port names in /etc/services contain hyphens -- netcat currently will not +correctly parse those, so specify ranges using numbers if you can. +.SH "SEE ALSO" +/usr/doc/netcat/README.gz +.SH AUTHOR +This manual page was written by Joey Hess and +Robert Woodcock , cribbing heavily from Netcat's README +file. +.P +Netcat was written by a guy we know as the Hobbit, +or _H* . diff -Nu ../nc110/netcat.c ./netcat.c --- ../nc110/netcat.c Thu Mar 21 00:38:04 1996 +++ ./netcat.c Thu Sep 5 16:58:33 2002 @@ -160,6 +160,7 @@ USHORT o_verbose = 0; unsigned int o_wait = 0; USHORT o_zero = 0; +int o_quit = -1; /* 0 == quit-now; >0 == quit after o_quit seconds */ /* o_tn in optional section */ /* Debug macro: squirt whatever message and sleep a bit so we can see it go @@ -211,7 +212,6 @@ o_verbose = 1; holler (str, p1, p2, p3, p4, p5, p6); close (netfd); - sleep (1); exit (1); } /* bail */ @@ -222,7 +222,15 @@ errno = 0; if (o_verbose > 1) /* normally we don't care */ bail (wrote_txt, wrote_net, wrote_out); - bail (" punt!"); + bail (""); +} + +/* quit : + handler for a "-q" timeout (exit 0 instead of 1) */ +void quit() +{ + close(netfd); + exit(0); } /* timeout and other signal handling cruft */ @@ -235,9 +243,9 @@ longjmp (jbuf, jval); } -/* arm : +/* arm_timer : set the timer. Zero secs arg means unarm */ -void arm (num, secs) +void arm_timer (num, secs) unsigned int num; unsigned int secs; { @@ -250,7 +258,7 @@ alarm (secs); jval = num; } /* if secs */ -} /* arm */ +} /* arm_timer */ /* Hmalloc : malloc up what I want, rounded up to *4, and pre-zeroed. Either succeeds @@ -713,6 +721,7 @@ if (gatesidx) { /* if we wanted any srcrt hops ... */ /* don't even bother compiling if we can't do IP options here! */ #ifdef IP_OPTIONS +#ifndef HAVE_NO_LSRR if (! optbuf) { /* and don't already *have* a srcrt set */ char * opp; /* then do all this setup hair */ optbuf = Hmalloc (48); @@ -737,20 +746,23 @@ rr = setsockopt (nnetfd, IPPROTO_IP, IP_OPTIONS, optbuf, x); if (rr == -1) bail ("srcrt setsockopt fuxored"); +#else /* HAVE_NO_LSRR */ + holler ("Warning: source routing unavailable on this machine, ignoring"); +#endif #else /* IP_OPTIONS */ holler ("Warning: source routing unavailable on this machine, ignoring"); #endif /* IP_OPTIONS*/ } /* if gatesidx */ /* wrap connect inside a timer, and hit it */ - arm (1, o_wait); + arm_timer (1, o_wait); if (setjmp (jbuf) == 0) { rr = connect (nnetfd, (SA *)remend, sizeof (SA)); } else { /* setjmp: connect failed... */ rr = -1; errno = ETIMEDOUT; /* fake it */ } - arm (0, 0); + arm_timer (0, 0); if (rr == 0) return (nnetfd); close (nnetfd); /* clean up junked socket FD!! */ @@ -820,14 +832,14 @@ actually does work after all. Yow. YMMV on strange platforms! */ if (o_udpmode) { x = sizeof (SA); /* retval for recvfrom */ - arm (2, o_wait); /* might as well timeout this, too */ + arm_timer (2, o_wait); /* might as well timeout this, too */ if (setjmp (jbuf) == 0) { /* do timeout for initial connect */ rr = recvfrom /* and here we block... */ (nnetfd, bigbuf_net, BIGSIZ, MSG_PEEK, (SA *) remend, &x); Debug (("dolisten/recvfrom ding, rr = %d, netbuf %s ", rr, bigbuf_net)) } else goto dol_tmo; /* timeout */ - arm (0, 0); + arm_timer (0, 0); /* I'm not completely clear on how this works -- BSD seems to make UDP just magically work in a connect()ed context, but we'll undoubtedly run into systems this deal doesn't work on. For now, we apparently have to @@ -845,12 +857,12 @@ /* fall here for TCP */ x = sizeof (SA); /* retval for accept */ - arm (2, o_wait); /* wrap this in a timer, too; 0 = forever */ + arm_timer (2, o_wait); /* wrap this in a timer, too; 0 = forever */ if (setjmp (jbuf) == 0) { rr = accept (nnetfd, (SA *)remend, &x); } else goto dol_tmo; /* timeout */ - arm (0, 0); + arm_timer (0, 0); close (nnetfd); /* dump the old socket */ nnetfd = rr; /* here's our new one */ @@ -1216,6 +1228,7 @@ if (rr <= 0) { /* at end, or fukt, or ... */ FD_CLR (0, ding1); /* disable and close stdin */ close (0); + shutdown(fd, 1); } else { rzleft = rr; zp = bigbuf_in; @@ -1315,9 +1328,11 @@ char * randports = NULL; #ifdef HAVE_BIND +#ifdef HAVE_RES_INIT /* can *you* say "cc -yaddayadda netcat.c -lresolv -l44bsd" on SunLOSs? */ res_init(); #endif +#endif /* I was in this barbershop quartet in Skokie IL ... */ /* round up the usual suspects, i.e. malloc up all the stuff we need */ lclend = (SAI *) Hmalloc (sizeof (SA)); @@ -1389,7 +1404,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:lno:p:q:rs:tuvw:z")) != EOF) { /* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */ switch (x) { case 'a': @@ -1443,6 +1458,8 @@ break; case 'r': /* randomize various things */ o_random++; break; + case 'q': /* quit after stdin does EOF */ + o_quit = atoi(optarg); break; case 's': /* local source address */ /* do a full lookup [since everything else goes through the same mill], unless -n was previously specified. In fact, careful placement of -n can @@ -1651,6 +1668,7 @@ -o file hex dump of traffic\n\ -p port local port number\n\ -r randomize local and remote ports\n\ + -q secs quit after EOF on stdin and delay of secs\n\ -s addr local source address"); #ifdef TELNET holler ("\ diff -Nu ../nc110/rules ./rules --- ../nc110/rules Thu Jan 1 01:00:00 1970 +++ ./rules Thu Sep 5 16:47:38 2002 @@ -0,0 +1,54 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp +build-stamp: + dh_testdir + $(MAKE) CC="gcc" CFLAGS="-O2" linux + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + # Add here commands to clean up after the build process. + -$(MAKE) clean + dh_clean + +# Build architecture-independent files here. +binary-indep: build +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs usr/bin + install -s nc debian/tmp/usr/bin + dh_installdocs README + dh_installexamples data/ scripts/ + dh_installmanpages + dh_installchangelogs Changelog + dh_movefiles + dh_strip + dh_compress + gzip -9v debian/tmp/usr/share/man/man1/nc.1 + gzip -9v debian/tmp/usr/share/doc/netcat/changelog.Debian + gzip -9v debian/tmp/usr/share/doc/netcat/changelog + dh_fixperms + dh_suidregister + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_makeshlibs + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary Common subdirectories: ../nc110/scripts and ./scripts