Article View: aus.computers.linux
Article #677Re: using netcat with pesky newsserver
From: Nick Andrew
Date: Mon, 29 Jun 2009 07:28
Date: Mon, 29 Jun 2009 07:28
60 lines
3383 bytes
3383 bytes
John Savage <rookswood@suburbian.com.au> writes:
>Here's as far as it goes using netcat:
># { echo authinfo user XYZ;echo authinfo pass XYZ;
>} | netcat -i 1 -w 5 eu.usenet-news.net 119
>200 (newsfe23.ams2) -- Welcome (Tornado v1.2.7.560)
>#
Most TCP "text" protocols are defined to use CRLF on line
endings, for whatever reason. Most servers are liberal in
accepting either LF or CRLF, but some aren't. See:
$ ( echo -e 'authinfo user XYZ\r' ; echo -e 'authinfo pass XYZ\r' ) | nc -i 1 -w 5 eu.usenet-news.net 119
200 (newsfe27.ams2) -- Welcome (Tornado v1.2.7.560-1)
381 More Authentication Required
502 Authentication Failed
Also you could add "-q 5" to your netcat options to make it
wait 5 seconds after seeing EOF on STDIN for any final data
from the other connection.
But basically you are probably using the wrong tool for the job.
netcat wasn't designed for interactive protocols; as another poster
mentioned you could use "expect" (which is), or more conveniently
you could use a programming language which implements the NNTP
protocol, e.g. Net::NNTP in perl:
$nntp = Net::NNTP->new("some.host.name");
e.g.
$ perl -MNet::NNTP -e '$net = Net::NNTP->new("eu.usenet-news.net", Debug => 1); $net->authinfo("XYZ", "XYZ");'
Net::NNTP>>> Net::NNTP(2.24)
Net::NNTP>>> Net::Cmd(2.29)
Net::NNTP>>> Exporter(5.62)
Net::NNTP>>> IO::Socket::INET(1.31)
Net::NNTP>>> IO::Socket(1.30_01)
Net::NNTP>>> IO::Handle(1.27)
Net::NNTP=GLOB(0x8c0f8d8)<<< 200 (newsfe27.ams2) -- Welcome (Tornado v1.2.7.560-1)
Net::NNTP=GLOB(0x8c0f8d8)>>> MODE READER
Net::NNTP=GLOB(0x8c0f8d8)<<< 200 (newsfe27.ams2) -- Welcome (Tornado v1.2.7.560-1)
Net::NNTP=GLOB(0x8c0f8d8)>>> AUTHINFO USER XYZ
Net::NNTP=GLOB(0x8c0f8d8)<<< 381 More Authentication Required
Net::NNTP=GLOB(0x8c0f8d8)>>> AUTHINFO PASS ....
Net::NNTP=GLOB(0x8c0f8d8)<<< 502 Authentication Failed
Net::NNTP=GLOB(0x8c0f8d8)>>> QUIT
Net::NNTP=GLOB(0x8c0f8d8)<<< 205 GoodBye
>Now, this could be termed a "problem" server. Not all so-called
>"telnets" will correctly connect to it. For example, the "telnet"
>on Puppy Linux gets no further than what I've shown above for
>netcat. Puppy's telnet hangs right after the 200 (newsfe23....)
>line and doesn't make use of the authinfo line or any further.
Telnet is even worse than netcat for non-interactive use.
Nick.
--
PGP Key ID = 0x418487E7 http://www.nick-andrew.net/
PGP Key fingerprint = B3ED 6894 8E49 1770 C24A 67E3 6266 6EB9 4184 87E7
Technical Details
Message-ID:
<h29qfp$t39$1@aioe.org>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!not-for-mailReferences:
<0906200192042.20Jun09$rookswood@suburbian.com>Show Full Headers
Complete Article Headers
X-Google-Thread: cfc73a2246,3aabcee40a190dee X-Google-Attributes: gidcfc73a2246,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!not-for-mail From: Nick Andrew <nick@spamtrap.nick-andrew.net> Newsgroups: aus.computers.linux Subject: Re: using netcat with pesky newsserver Date: Mon, 29 Jun 2009 07:28:58 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 60 Message-ID: <h29qfp$t39$1@aioe.org> References: <0906200192042.20Jun09$rookswood@suburbian.com> NNTP-Posting-Host: QgwHv3sgFaJX71X8ZhrvQw.user.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.7.9 Cancel-Lock: sha1:bK53TsLKC5SAmZEZ+7u27S8+pAY= User-Agent: nn/6.7.3