问题描述
默认情况下,在Ubuntu 20.04.01上安装的
netcat命令具有-X选项,但是从源代码编译的netcat 0.7.1没有-X选项。有什么区别?
在Ubuntu 20.04.01上安装的netcat:
foo@foo:~/data/tmp$ netcat --help
netcat: invalid option -- '-'
usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]
[-m minttl] [-O length] [-P proxy_username] [-p source_port]
[-q seconds] [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout]
[-X proxy_protocol] [-x proxy_address[:port]] [destination] [port]
从源代码编译的netcat 0.7.1:
foo@foo:~/data/tmp$ ./netcat/bin/netcat --help
GNU netcat 0.7.1,a rewrite of the famous networking tool.
Basic usages:
connect to somewhere: ./netcat/bin/netcat [options] hostname port [port] ...
listen for inbound: ./netcat/bin/netcat -l -p port [options] [hostname] [port] ...
tunnel to somewhere: ./netcat/bin/netcat -L hostname:port -p port [options]
Mandatory arguments to long options are mandatory for short options too.
Options:
-c,--close close connection on EOF from stdin
-e,--exec=PROGRAM program to exec after connect
-g,--gateway=LIST source-routing hop point[s],up to 8
-G,--pointer=NUM source-routing pointer: 4,8,12,...
-h,--help display this help and exit
-i,--interval=SECS delay interval for lines sent,ports scanned
-l,--listen listen mode,for inbound connects
-L,--tunnel=ADDRESS:PORT forward local port to remote address
-n,--dont-resolve numeric-only IP addresses,no DNS
-o,--output=FILE output hexdump traffic to FILE (implies -x)
-p,--local-port=NUM local port number
-r,--randomize randomize local and remote ports
-s,--source=ADDRESS local source address (ip or hostname)
-t,--tcp TCP mode (default)
-T,--telnet answer using TELNET negotiation
-u,--udp UDP mode
-v,--verbose verbose (use twice to be more verbose)
-V,--version output version @R_214_4045@ion and exit
-x,--hexdump hexdump incoming and outgoing traffic
-w,--wait=SECS timeout for connects and final net reads
-z,--zero zero-I/O mode (used for scanning)
Remote port number can also be specified as range. Example: '1-1024'
解决方法
来自Ubuntu的netcat是Open BSD one:
$ netcat -help
OpenBSD netcat (Debian patchlevel 1.206-1ubuntu1)
然后您编译了GNU版本:
$ ./netcat/bin/netcat --help
GNU netcat 0.7.1,a rewrite of the famous networking tool.
此post讨论了两者之间的区别。