Terminal escape character for hexadecimal input

You can use echo -e, (which is what I think richardhoskins meant.) Like this:

/bin/echo -n -e "\x01\x00\xaf\x0f\xe1" | netcat -u somewhere 1234
# -n: no newline at end, -e: interpret escapes

If your echo implementation is old, (or simply not GNU-encrusted,) the old-school way is to use octal:

/bin/echo -n -e "\001\000\257\017\341" | netcat -u somewhere 1234

Yes, octal is way, way old-school. Look at ibase and obase in the man for bc. Check to see if echo does the right thing with od ("octal dump") "od -tx1" for hex, "od -to1" for octal.


A simple approach, though not quite what you are looking for...

Use a hex editor to create a file with the bytes in that you want to send (you mention gnome so you may already have ghex but any hex editor should be fine). For short hex sequences I usually include the hex as part of the name (e.g. test0x0100af0fe1).

Then just redirect the content into netcat, e.g.:

mas@voco:~$ nc -o testout 127.0.1.1 80 < test0x0100af0fe1
^C
mas@voco:~$ cat testout
> 00000000 01 00 af 0e 10                                  # .....
mas@voco:~$ 

This has the disadvantage of having to prepare a separate file but it makes replication and documentation of tests easier.