ncat工具详细介绍
  

老眼 9643

{{ttag.title}}
本帖最后由 老眼 于 2016-7-3 21:47 编辑

ncat简介


说起ncat我们不得不说一下Netcat。Netcat用于从TCP/UDP连接中读取或发送网络数据。cat是Linux中查看或连接文件的命令,所以netcat本意为从网络上查看文件内容。而Netcat的作者Hobbit为它添加了非常丰富的功能,使它几乎能够完成网络操作中各式各样的操作,所以Netcat在网络安全领域被称作“TCPIP的瑞士军刀”("Swiss-army knife forTCP/IP")。


Netcat稳定版1.10由Hobbit在1996年3月发布(开源软件),之后作者没有再对其进行维护,但该工具十多年来依然在被广泛地使用,而且基于Netcat的各种衍生工具也层出不穷,他们在很多方面增强或扩展了Netcat的功能。


Nmap团队开发了Ncat作为Netcat的升级版本,增加了更多的功能(如ssl加密、代理连接通过socks4 获取http),让其更能适应现代网络环境的需求。


ncat安装


在安装nmap的时候就会自动安装ncat


ncat使用语法及参数


ncat [OPTIONS...] [hostname] [port]

root@lalays:~# ncat -h
Ncat 7.01 ( [color=white !important][size=1em]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
      --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

ncat常用参数


-u    使用udp连接(不适用-u的话默认是使用tcp连接)
-v    输出详细的连接产生的日志
-n    不解析域名
-l    绑定并侦听传入的连接(一般用于服务端)
-c    通过/bin/sh 执行客户端参数过来的指令(通常使用方法为 -c bash)
-w    设置连接超时时间

--ssl    传输过程中使用ssl加密(服务端和客户端都要使用这个参数)

ncat使用案例



(1)连接目标端口

ncat lybbn.cn 80


(2)端口转发

ncat --sh-exec  "www.lybbn.cn 80" -l 8080 --keep-open


(3)使用代理(使用socks4代理连接邮件服务器)

ncat --proxy  www.lybbn.cn  --proxy-type socks4 --proxy-auth user smtphost 25


(4)创建本地HTTP代理

ncat -l --proxy-type http localhost 8888


(5)文件传输(可以反向传输)


服务端


root@lalays:~# ncat -lv 333 > lybbn.txt


注意:服务端的文件可以不用存在,传输时会自动创建


客户端

C:\&gt;ncat -nv 172.16.0.182 333 < lybbnclient.txt



(6)客户端使用ncat加密连接服务器


服务端

root@lalays:~# ncat -nvl 333 -c bash --ssl

客户端

C:\&gt; ncat -nv 172.16.0.182 333 --ssl



原文:www.lybbn.cn

打赏鼓励作者,期待更多好文!

打赏
暂无人打赏

Sangfor_闪电回_朱丽 发表于 2016-7-5 10:31
  
感谢楼主的分享~
liangjiahang 发表于 2016-7-27 15:36
  
谢谢分享!
发表新帖
热门标签
全部标签>
每日一问
技术盲盒
技术笔记
技术咨询
功能体验
干货满满
新版本体验
2023技术争霸赛专题
标准化排查
产品连连看
GIF动图学习
信服课堂视频
自助服务平台操作指引
运维工具
技术晨报
通用技术
安装部署配置
每日一记
用户认证
秒懂零信任
安全攻防
云计算知识
SDP百科
设备维护
深信服技术支持平台
答题自测
sangfor周刊
资源访问
社区帮助指南
畅聊IT
专家问答
技术圆桌
在线直播
MVP
网络基础知识
升级
上网策略
测试报告
日志审计
问题分析处理
流量管理
原创分享
解决方案
VPN 对接
项目案例
SANGFOR资讯
专家分享
技术顾问
信服故事
功能咨询
终端接入
授权
迁移
玩转零信任
山东区技术晨报
地址转换
虚拟机
存储
加速技术
排障笔记本
产品预警公告
信服圈儿
S豆商城资讯
技术争霸赛
「智能机器人」
追光者计划
答题榜单公布
纪元平台
卧龙计划
华北区拉练
天逸直播
以战代练
文档捉虫活动
齐鲁TV
华北区交付直播
每周精选

本版达人

新手68983...

本周分享达人

零和一网络

本周提问达人