Netcat无法在监听模式下启动

我使用的是CentOS 6.7(Final)系统,当我尝试在监听模式下运行nc ,它打印出下列内容:

 # nc -l 1234 nc: Protocol not available 

港口没有绑定。 我也尝试了其他的端口号。 这个bug似乎已经被报告了: https : //access.redhat.com/solutions/1753753 。 不幸的是它不是很详细。

包装信息:

 Name : nc Arch : x86_64 Version : 1.84 Release : 24.el6 

还有什么我需要尝试?

我遇到了同样的问题。 你可以这样解决:

 # Removes the old package yum erase nc # Manually downloads the working package from the Official Repository wget http://vault.centos.org/6.6/os/x86_64/Packages/nc-1.84-22.el6.x86_64.rpm # Installs the package rpm -iUv nc-1.84-22.el6.x86_64.rpm 

请注意,该软件包用于x86_64 (64位)。 如果你需要i386 (32位),正确的是:

 wget http://vault.centos.org/6.6/os/i386/Packages/nc-1.84-22.el6.i686.rpm 

这个特定版本的netcat有一个bug。 直到有一个修复它,唯一可以做的是降级到以前的版本 – sudo yum remove nc-1.84-24.el6.x86_64; sudo yum install nc-1.84-22.el6.x86_64 sudo yum remove nc-1.84-24.el6.x86_64; sudo yum install nc-1.84-22.el6.x86_64应该可以做到。

回答这个问题:

  1. 是的,降级是需要的,所以NC可以听。 至于其他评论:

a)-p在听音模式下不应该被使用。 来自nc手册页:

-l用于指定nc应监听传入连接,而不是启动到远程主机的连接。 将此选项与-p,-s或-z选项结合使用是错误的。

b)降级可以一步完成,yum降级命令与url一起工作到包:

 $ rpm -q nc nc-1.84-24.el6.x86_64 $ nc -l 12345 #Although the syntax is correct, the command fails nc: Protocol not available $ nc -l -p 12345 #attempt to run with incorrect syntax usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port] [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version] [-x proxy_address[:port]] [hostname] [port[s]] $ sudo yum downgrade http://vault.centos.org/6.6/os/x86_64/Packages/nc-1.84-22.el6.x86_64.rpm #shortcut to downgrade ... Setting up Downgrade Process nc-1.84-22.el6.x86_64.rpm | 57 kB 00:00 Examining /var/tmp/yum-root-Iq4yc7/nc-1.84-22.el6.x86_64.rpm: nc-1.84-22.el6.x86_64 Resolving Dependencies --> Running transaction check ---> Package nc.x86_64 0:1.84-22.el6 will be a downgrade ---> Package nc.x86_64 0:1.84-24.el6 will be erased --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================== Package Arch Version Repository Size ============================================================================================================== Downgrading: nc x86_64 1.84-22.el6 /nc-1.84-22.el6.x86_64 109 k Transaction Summary ============================================================================================================== Downgrade 1 Package(s) Total size: 109 k Is this ok [y/N]: y ... Removed: nc.x86_64 0:1.84-24.el6 Installed: nc.x86_64 0:1.84-22.el6 Complete! $ nc -l -p 12345 #attempt to run with incorrect syntax usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port] [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version] [-x proxy_address[:port]] [hostname] [port[s]] $ nc -l 12345 # try to listen again ^C $#nc successully opens a socket on 12345. had to stop it with ctrl+C 
 # nc -l -p 1234 

您可以通过使用-p标志显式地监听端口:

 -p source_port Specifies the source port nc should use, subject to privilege restrictions and availability. 

问题出在nc把1234作为目标端口(尽pipe是在监听模式下运行),并试图监听端口0(这产生了奇怪的消息)。 显式传递-p可以解决这个问题。

安装nmap:

yum安装nmap

尝试:

ncat -1234