Moh*_*ati 25 netcat echoserver socat
我想要一个 UDP 回显服务器来获取数据包,并准确地回复它收到的内容。我怎样才能简单地使用netcat
or做到这一点socat
?它应该永远保持活动状态并处理来自多个主机的数据包。
Mat*_*erg 21
Another netcat-like tool is the nmap version, ncat
, that has lots of built in goodies to simplify things like this. This would work:
ncat -e /bin/cat -k -u -l 1235
Run Code Online (Sandbox Code Playgroud)
-e means it executes /bin/cat (to echo back what you type)
-k means keep-alive, that it keeps listening after each connection
-u means udp
-l 1235 means that it listens on port 1235
小智 7
您还可以使用 socat(而不是使用 netcat)作为回显服务器,使用 netcat 作为客户端。
Socat 回显服务器(侦听 TCP 端口 1234):
socat -v tcp-l:1234,fork exec:'/bin/cat'
Run Code Online (Sandbox Code Playgroud)
Netcat 客户端(在 TCP 端口 1234 上连接到 serverip):
nc serverip 1234
Run Code Online (Sandbox Code Playgroud)