Netcat 无法以监听模式启动

Netcat 无法以监听模式启动

我正在使用 CentOS 6.7(最终版)系统,当我尝试nc在监听模式下运行时,它会打印以下内容:

nc -l 1234
nc: Protocol not available

端口未绑定。我也尝试了其他端口号。这个错误似乎已经被报告过了:https://access.redhat.com/solutions/1753753。遗憾的是它不够详细。

封装信息:

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

我还需要尝试其他什么吗?

答案1

我遇到了同样的问题。你可以用以下方法解决:

# 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_6464 位。如果您需要i38632 位,则正确的软件包是:

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

答案2

此特定版本的 netcat 存在错误。在修复之前,您唯一能做的就是降级到以前的版本 -sudo yum remove nc-1.84-24.el6.x86_64; sudo yum install nc-1.84-22.el6.x86_64应该可以解决问题。

答案3

回答问题:

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

a) 在监听模式下不应使用 -p。摘自 nc 手册页:

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

b) 降级可以一步完成,yum downgrade 命令与包的 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

答案4

安装 nmap:

yum 安装 nmap

尝试:

ncat -l 1234

相关内容