20200903-nc使用方法及实例

nc:netcat的简写,有着网络界的瑞士军刀美誉。因为它短小精悍、功能实用,被设计为一个简单、可靠的网络工具

作用:

1、实现任意TCP/UDP端口的侦听,nc可以作为server以TCP或UDP方式侦听指定端口
2、端口的扫描,nc可以作为client发起TCP或UDP连接
3、机器之间传输文件
4、机器之间网络测速  
参数:
root@kali:~# nc -h
[v1.10-41.1]
connect to somewhere:  nc [-options] hostname port[s] [ports] ... 
listen for inbound:    nc -l -p port [-options] [hostname] [port]
options:
    -c shell commands  as `-e'; use /bin/sh to exec [dangerous!!]      使用/bin/sh来执行
    -e filename        program to exec after connect [dangerous!!]     连接后执行程序
    -b                 allow broadcasts                                允许广播
    -g gateway         source-routing hop point[s], up to 8            设置路由器网关最多8个
    -G num             source-routing pointer: 4, 8, 12, ...           设置来源路由指向器,其数值为4的倍数
    -h                 this cruft
    -i secs            delay interval for lines sent, ports scanned    设置延迟秒数,以便传送信息及扫描通信端口
    -k                 set keepalive option on socket
    -l                 listen mode, for inbound connects               侦听模式,用于接受连接,
    -n                 numeric-only IP addresses, no DNS               使用IP,不通过DNS
    -o file            hex dump of traffic
    -p port            local port number                               本地端口号
    -r                 randomize local and remote ports                随机的本地或远程端口        
    -q secs            quit after EOF on stdin and delay of secs       
    -s addr            local source address                            设置发送数据的源IP 
    -T tos             set Type Of Service                             设置服务类型
    -t                 answer TELNET negotiation                       
    -u                 UDP mode                                        使用udp协议
    -v                 verbose [use twice to be more verbose]          显示详细信息
    -w secs            timeout for connects and final net reads        超时秒数,设置等待连线时间
    -C                 Send CRLF as line-ending                        发送CRLF作为行尾
    -z                 zero-I/O mode [used for scanning]               使用0输入/输出模式,只在扫描通信端口时使用
port numbers can be individual or ranges: lo-hi [inclusive];           端口可以是单个或范围
hyphens in port names must be backslash escaped (e.g. 'ftp-data').    端口名中的连字符必须是反斜杠转义的

1、扫描weblogic服务器和真实机,TCP端口扫描

nc -v -z -w2 192.168.230.144 1-65535 
 
加-u参数,扫描udp端口

 服务器侦听9999端口,kali中通过9999端口和服务器进行通信

 

 


 
 
#####################################
参考链接:
原文地址:https://www.cnblogs.com/lookmefly/p/13602755.html