可以处理\ x00“字符”的Bash脚本

时间:2013-07-02 09:42:46

标签: bash binary echo send

    PAYLOAD=`cat $f`
    header=`cat a.hex`
    send=$header$PAYLOAD           #The actual Payload
    echo -en $send | nc -p 3300 127.0.0.1 4000 &

PAYLOAD包含一个简单的字符串

header包含"\x00" "\x01" ...等二进制文件

echo无法发送\x00字符。

部分字符的发送方式为\x01 \x11 \x10...,但不是\x00

如何echoreadcat(等)并将其提供给nc而不会丢失\x00个字符?

1 个答案:

答案 0 :(得分:1)

尝试

cat a.hex $f | ...

而不是说:

PAYLOAD=`cat $f`
header=`cat a.hex`
send=$header$PAYLOAD           #The actual Payload
echo -en $send | ...