跳转至

Netcat

netcat的版本

nmap的netcat可以这样实现一个echo-server:

$ ncat -l 2000 --keep-open --exec "/bin/cat"

用nc测试不断地连接、断开

watch -n 0.1 "echo sdfadf |nc -w0 -N localhost 4646"

socat - Multipurpose relay

http://www.dest-unreach.org/socat/ http://www.dest-unreach.org/socat/doc/socat.html

“多用途中继”,看着是想代替netcat.

使用socat监听unix socket

$ sudo mv /path/to/sock /path/to/sock.original
$ sudo socat -t100 -x -v UNIX-LISTEN:/path/to/sock,mode=777,reuseaddr,fork UNIX-CONNECT:/path/to/sock.original

例:

$ sudo socat -t100 -x -v UNIX-LISTEN:/var/run/ubus.sock,mode=777,reuseaddr,fork UNIX-CONNECT:/var/run/ubus.sock.original

< 2019/11/28 19:37:35.355383  length=12 from=0 to=11
 00 00 00 00 8a fe d1 a8 00 00 00 04              ............
--
> 2019/11/28 19:37:35.355631  length=12 from=0 to=11
 00 04 00 01 00 00 00 00 00 00 00 04              ............
--
< 2019/11/28 19:37:35.355823  length=20 from=12 to=31
 00 01 00 01 00 00 00 00 00 00 00 0c 01 00 00 08  ................
 00 00 00 00                                      ....
--