netcat strange behaviour
shibbsd at spymac.com
shibbsd at spymac.com
Tue Apr 26 01:05:57 PDT 2005
Hi,
I recently came across a very stupid behaviour of netcat - the one in base system
(/usr/bin/nc in my FreeBSD 5.4-RC3).
I just wanted to connect to a POP3 server, authenticate and grab the STAT
information, so
I issued the following command:
printf "USER XXX\nPASS XXX\nSTAT\nQUIT\n" | nc -i 1 <mypopserver> 110
And what I got on stdout was:
+OK <greeting string>
+OK
+OK
...and nothing more, the command just exited without any error (FIN_WAIT in
netstat). The
server had interpreted USER and PASS commands, but ignored anything that came
later... The
error is 100% reproductible, has been observed on a few different FreeBSD 5
machines, and
- what is more - does not depend on a POP3 server! I tried a couple of public
ISPs. I have
also used a range of -i delays without success.
I investigated more and ran tcpdump -xx -v dst host <mypopserver>, and what I got
was:
[...omitted...]
08:55:23.196753 IP (tos 0x0, ttl 64, id 145, offset 0, flags [DF], length: 80)
mypc.63175
>
mypopserver.pop3: P [bad tcp cksum 2f41 (->71d2)!] 0:40(40) ack 36 win 65535
0x0000: 0050 da74 56b1 0011 11c1 fa55 0800 4500 .P.tV......U..E.
0x0010: 0050 0091 4000 4006 0b19 0a01 0ac7 d94a .P.. at .@........J
0x0020: 40ec f6c7 006e f760 36fd f3cd 8805 5018 @....n.`6.....P.
0x0030: ffff 2f41 0000 5553 4552 20XX XXXX XXXX ../A..USER.XXXXX
0x0040: XXXX XXXX 0a50 4153 5320 XXXX XXXX XXXX XXXX.PASS.XXXXXX
0x0050: XXXX XX0a 5354 4154 0a51 5549 540a XXX.STAT.QUIT.
[...omitted...]
And my BIG question is:
should netcat send all these POP3 commands in one packet? I thought that separate
lines
ought to be separated in TCP/IP terms too - and what is more, I wanted a 1 second
delay
between lines! (-i option).
Any suggestions, bug anticipations or maybe networking lectures for me? ;) I just
wanted
to check mail :P Thanks
Kuba <shibbsd at spymac.com>
More information about the freebsd-questions
mailing list