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:>ncat -nv 172.16.0.182 333 < lybbnclient.txt
(6)客户端使用ncat加密连接服务器
服务端
root@lalays:~# ncat -nvl 333 -c bash --ssl
客户端
C:> ncat -nv 172.16.0.182 333 --ssl
原文始发于微信公众号(菜鸟小新):ncat工具详细介绍
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论