当前位置:   article > 正文

nc命令说明_nc -v

nc -v

nc

ncnetcat)是一种用于在网络上传输数据的命令行工具,支持TCP、UDP、Unix域套接字和其他协议。它可以用于创建客户端和服务器,也可以用于在不同主机之间传输文件、扫描端口、进行端口转发等。

以下是一些nc命令的常见用法:

  1. 创建TCP或UDP连接:
nc host port
  • 1

例如,要连接到远程主机example.com的80端口(HTTP),可以使用以下命令:

nc example.com 80
  • 1
  1. 创建监听TCP或UDP连接:
nc -l -p port
  • 1

例如,要在本地主机的8080端口上监听HTTP请求,可以使用以下命令:

nc -l -p 8080
  • 1
  1. 文件传输:

从本地主机向远程主机发送文件:

nc host port < file
  • 1

从远程主机向本地主机接收文件:

nc -l -p port > file
  • 1
  1. 端口扫描:
nc -zv host port
  • 1

例如,要扫描远程主机example.com的80端口是否开放,可以使用以下命令:

nc -zv example.com 80
  • 1
  1. 端口转发:
nc -l -p local_port -c 'nc remote_host remote_port'
  • 1

例如,要将本地主机的8080端口上的HTTP请求转发到远程主机example.com的80端口,可以使用以下命令:

nc -l -p 8080 -c 'nc example.com 80'
  • 1

这只是nc命令的一些常见用法,该命令还可以用于许多其他用途,具体取决于您的需求。

nc -v host port

当使用 “nc -v host port” 命令连接到指定的主机和端口时,命令的返回结果将提供以下信息:

  • 如果连接成功,则命令将显示 “Connection to host port [tcp/*] succeeded!” 的消息,其中 host 和 port 是指定的主机和端口号。这表示连接已成功建立。

  • 如果连接失败,则命令将显示 “nc: connect to host port [tcp/*] failed: Connection refused” 或类似的错误消息,其中 host 和 port 是指定的主机和端口号。这表示连接尝试失败,可能是由于主机或端口不可用或防火墙阻止了连接。

  • 如果命令没有连接到指定的主机和端口,则命令将保持运行状态,直到手动中断或超时。在这种情况下,命令没有返回结果,但可以通过 Ctrl+C 中断命令。

  • 如果指定了多个 “-v” 选项,则命令将显示更详细的信息,例如连接状态、数据传输速率和其他相关详细信息。

nc -h

nc -h
Ncat 7.50 ( https://nmap.org/ncat )
Usage: ncat [options] [hostname] [port]

Options taking a time assume seconds. Append 'ms' for milliseconds,
's' for seconds, 'm' for minutes, or 'h' for hours (e.g. 500ms).
  -4                         Use IPv4 only
  -6                         Use IPv6 only
  -U, --unixsock             Use Unix domain sockets only
  -C, --crlf                 Use CRLF for EOL sequence
  -c, --sh-exec <command>    Executes the given command via /bin/sh
  -e, --exec <command>       Executes the given command
      --lua-exec <filename>  Executes the given Lua script
  -g hop1[,hop2,...]         Loose source routing hop points (8 max)
  -G <n>                     Loose source routing hop pointer (4, 8, 12, ...)
  -m, --max-conns <n>        Maximum <n> simultaneous connections
  -h, --help                 Display this help screen
  -d, --delay <time>         Wait between read/writes
  -o, --output <filename>    Dump session data to a file
  -x, --hex-dump <filename>  Dump session data as hex to a file
  -i, --idle-timeout <time>  Idle read/write timeout
  -p, --source-port port     Specify source port to use
  -s, --source addr          Specify source address to use (doesn't affect -l)
  -l, --listen               Bind and listen for incoming connections
  -k, --keep-open            Accept multiple connections in listen mode
  -n, --nodns                Do not resolve hostnames via DNS
  -t, --telnet               Answer Telnet negotiations
  -u, --udp                  Use UDP instead of default TCP
      --sctp                 Use SCTP instead of default TCP
  -v, --verbose              Set verbosity level (can be used several times)
  -w, --wait <time>          Connect timeout
  -z                         Zero-I/O mode, report connection status only
      --append-output        Append rather than clobber specified output files
      --send-only            Only send data, ignoring received; quit on EOF
      --recv-only            Only receive data, never send anything
      --allow                Allow only given hosts to connect to Ncat
      --allowfile            A file of hosts allowed to connect to Ncat
      --deny                 Deny given hosts from connecting to Ncat
      --denyfile             A file of hosts denied from connecting to Ncat
      --broker               Enable Ncat's connection brokering mode
      --chat                 Start a simple Ncat chat server
      --proxy <addr[:port]>  Specify address of host to proxy through
      --proxy-type <type>    Specify proxy type ("http" or "socks4" or "socks5")
      --proxy-auth <auth>    Authenticate with HTTP or SOCKS proxy server
      --ssl                  Connect or listen with SSL
      --ssl-cert             Specify SSL certificate file (PEM) for listening
      --ssl-key              Specify SSL private key (PEM) for listening
      --ssl-verify           Verify trust and domain name of certificates
      --ssl-trustfile        PEM file containing trusted SSL certificates
      --ssl-ciphers          Cipherlist containing SSL ciphers to use
      --version              Display Ncat's version information and exit

See the ncat(1) manpage for full options, descriptions and usage examples
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/194784
推荐阅读
相关标签
  

闽ICP备14008679号