通过 netcat 连接发送字符串
Send String over netcat connection
我打开了两台虚拟机,一台正在侦听连接,另一台通过 python 子进程调用与 nc <ip> <port>
连接。我只想通过连接发送 1 行文本,然后关闭它。我知道如何发送文件 cat cat <file> | nc <ip> <port>
但我怎样才能在 nc 命令中发送一行文本(不使用文件)?
试试这个:
echo -n 'Line of text' | nc <ip> <port>
您也可以使用临时文件语法:
cat <(echo "Line of test") | nc <ip> <port>
创建文件test.txt
,文件内容为1
netcat [ip-address] [port] <test.txt
在目的地你一定有东西可以听。
@cb0 显示的临时文件语法也可以用作:
nc <ip> <port> <( echo "Line of text" )
无需使用 cat
命令。这将创建一个内容为“文本行”的临时文件,然后将其重定向到 netcat 命令。
我打开了两台虚拟机,一台正在侦听连接,另一台通过 python 子进程调用与 nc <ip> <port>
连接。我只想通过连接发送 1 行文本,然后关闭它。我知道如何发送文件 cat cat <file> | nc <ip> <port>
但我怎样才能在 nc 命令中发送一行文本(不使用文件)?
试试这个:
echo -n 'Line of text' | nc <ip> <port>
您也可以使用临时文件语法:
cat <(echo "Line of test") | nc <ip> <port>
创建文件test.txt
,文件内容为1
netcat [ip-address] [port] <test.txt
在目的地你一定有东西可以听。
@cb0 显示的临时文件语法也可以用作:
nc <ip> <port> <( echo "Line of text" )
无需使用 cat
命令。这将创建一个内容为“文本行”的临时文件,然后将其重定向到 netcat 命令。