首先介绍下NC,这个号称网络瑞士军刀的工具。
What is Netcat?
Netcat is a featured networking utility which reads and writes data across network connections, using the TCP/IP protocol.
It is designed to be a reliable “back-end” tool that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need and has several interesting built-in capabilities.
It provides access to the following main features:
* Outbound and inbound connections, TCP or UDP, to or from any ports.
* Featured tunneling mode which allows also special tunneling such as UDP to TCP, with the possibility of specifying all network parameters (source port/interface, listening port/interface, and the remote host allowed to connect to the tunnel.
* Built-in port-scanning capabilities, with randomizer.
* Advanced usage options, such as buffered send-mode (one line every N seconds), and hexdump (to stderr or to a specified file) of trasmitted and received data.
* Optional RFC854 telnet codes parser and responder.
项目主页:http://netcat./
Wiki: http://en./wiki/Netcat
再看下我们如何使用NC:
在RHEL服务器里面NC是标配,无需用户自己安装,手册也很全 man nc就好了。
之前在开发服务端程序的时候经常用nc来发报文,模拟客服端的行为, 省的自己写个客户端的麻烦,比如:
$ echo -n "GET / HTTP/1.0\r\n\r\n" | nc host.example.com 80 |
$ nc [-C] localhost 25 << EOF |
MAIL FROM: <user@host.example.com> |
RCPT TO: <user2@host.example.com> |
这二天从鸣嵩那里学了招模拟服务端的行为, 在调查自己的客户端的时候很方便,来看下:
NC还有其他的功能,读者自己来挖掘!
祝玩得开心!