广告
返回顶部
首页 > 资讯 > 服务器 >使用netcat(瑞士军刀)进行文件传输
  • 309
分享到

使用netcat(瑞士军刀)进行文件传输

文件传输瑞士军刀netcat 2022-06-04 21:06:27 309人浏览 安东尼
摘要

nc(netcat)被誉为网络工具中的“瑞士军刀”,体积虽小但功能强大,nc最简单的功能是端口扫描,这里我主要笔记一下它作为文件传输的妙用。 首先看一下帮助信息。 $ nc -h OpenBSD ne

nc(netcat)被誉为网络工具中的“瑞士军刀”,体积虽小但功能强大,nc最简单的功能是端口扫描,这里我主要笔记一下它作为文件传输的妙用。

首先看一下帮助信息。


$ nc -h
OpenBSD netcat (Debian patchlevel 1.105-7ubuntu1)
This is nc from the netcat-openbsd package. An alternative nc is available
in the netcat-traditional package.
usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
   [-P proxy_username] [-p source_port] [-q seconds] [-s source]
   [-T toskeyWord] [-V rtable] [-w timeout] [-X proxy_protocol]
   [-x proxy_address[:port]] [destination] [port]
  Command Summary:
    -4    Use IPv4
    -6    Use IPv6
    -b    Allow broadcast
    -C    Send CRLF as line-ending
    -D    Enable the debug Socket option
    -d    Detach from stdin
    -h    This help text
    -I length  tcp receive buffer length
    -i secs    Delay interval for lines sent, ports scanned
    -j    Use jumbo frame
    -k    Keep inbound sockets open for multiple connects
    -l    Listen mode, for inbound connects
    -n    Suppress name/port resolutions
    -O length  TCP send buffer length
    -P proxyuser  Username for proxy authentication
    -p port    Specify local port for remote connects
      -q secs    quit after EOF on stdin and delay of secs
    -r    Randomize remote ports
    -S    Enable the TCP MD5 signature option
    -s addr    Local source address
    -T toskeyword  Set IP Type of Service
    -t    Answer TELNET neGotiation
    -U    Use UNIX domain socket
    -u    UDP mode
    -V rtable  Specify alternate routing table
    -v    Verbose
    -w secs    Timeout for connects and final net reads
    -X proto  Proxy protocol: "4", "5" (SOCKS) or "connect"
    -x addr[:port]  Specify proxy address and port
    -Z    DCCP mode
    -z    Zero-I/O mode [used for scanning]
  Port numbers can be individual or ranges: lo-hi [inclusive]

端口扫描:


$ nc -z -v -n 127.0.0.1 20-100
...
Connection to 127.0.0.1 80 port [tcp/*] succeeded!
...

简单文件传输:

客户端:


$ nc -l 192.168.1.11 1234 > passwd.txt &

服务端:


$ nc 192.168.1.11 1234 < /etc/passwd

也可以是


cat /etc/passwd | nc 192.168.1.11 1234

服务端ip是192.169.1.11,端口是1234

如此,当两台linux机器需要简单传输文件时,再好不过了~

--结束END--

本文标题: 使用netcat(瑞士军刀)进行文件传输

本文链接: https://www.lsjlt.com/news/19129.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作