Search code examples
bashbinaryechosend

Bash script which can handle \x00 "chars"


    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 contains a simple string

header contains "\x00" "\x01" ... etc in binary

echo can't send the \x00 chars.

Some of the chars are sent for example \x01 \x11 \x10... but not the \x00

How to echo or read or cat (etc) and give it to the nc without losing the \x00 characters?


Solution

  • Try

    cat a.hex $f | ...
    

    instead of saying:

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