我正在 https://exploit-exercises.com/protostar/ 上做 net0 练习.练习的内容是将请求的数字作为 little endian 32bit int 发送到服务器。我想到了以下命令行。
mkfifo /tmp/pipe
cat /tmp/pipe | netcat 127.0.0.1 2999 |tee -a /tmp/log | cut -d ' ' -f 3 | xargs -I{} python -c "import struct; print struct.pack('I',int({}))" > /tmp/pipe
第二个命令行没有完成,我发现 cat/tmp/pipe
在使用 strace
进行调试时阻塞读取(而不是打开)。
最佳答案
我找到了原因。当输出不是终端时,cut
将缓冲输出。 python print
也需要刷新。
https://unix.stackexchange.com/a/226675/194577
关于读取时的linux FIFO block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49848626/