Continuing from the comment, not knowing exactly what was in ./myProgram
made it a bit difficult to guess, but there are several logical things to try given what you reported.
As you point out, you need to take the hex input as the first argument to ./myProgram
rather than passing it to the program on stdin
. You correctly note that python -c "print '\x48\x65\x6c\x6c\x6f'" | ./myProgram
fails for that reason. As you know, piping to a program redirects stdout
of the initial process to stdin
of the subsequent process, rather than as an argument to it.
That is where process substitution can help. When placing a process within $(...)
(or the older format within backticks '...'
), the output of the program is returned. Therefore, you can provide the output of python -c "print '\x48\x65\x6c\x6c\x6f'"
as an argument by:
./myProgram $(python -c "print '\x48\x65\x6c\x6c\x6f'")
Lastly, if myProgram
is simply looking for hexadecimal input in string format, then there is no reason for multiple escapes. Simply providing a string representation of the hex number may be enough. Something like the following:
./myProgram 0x48656c6c6f
I'm glad one of the suggestions was the "silver-bullet" you needed. Good luck with your shell use. Let us know if you have any further questions.