Hi I'd like to run a python command python -c 'print "\x90"*52' when the program start in GDB, as I would do when I execute : python -c 'print "\x90"*52' | ./myProg . Does anyone knows any way to acheive this?

What I've tried so far :

  • `python -c 'print "\x90"*52' ` run
  • run `python -c 'print "\x90"*52' `

I really apologies if I'm not asking on the right StackExchange forum. Thanks.

  • 1
    i ususally save the output to a file and execute "r < /file" – Amirag Jun 18 '18 at 21:49
  • 1
    @Amirag I just tried this. Looks like it work just fine, thanks a lot ! Please create an answer on this topic so I can mark this topic as "answered". – Nark Jun 18 '18 at 22:01
  • See this answer. – perror Jul 3 at 12:33

You do not have to use another file, it is just redundant

You can do this by using "Here strings". In your example you can do :

r <<< $(python -c "print '\x90'*52")

You can read about "Here strings" here

  • Although this answer does provide a solution, I would love seeing an edit that takes us through the anwer and actually explain it. Naturally, there's no need to explain the python command itself. Thanks! – NirIzr Feb 4 at 11:24

I don't know of any way to run a script as a run argument.
A common solution is to redirect your input from a file.

You first need to run the script and save the result:

python -c "print 'A'*50" > my_file

and redirect it to gdb run.

r < my_file

also, from the help run command:

Input and output redirection with ">", "<", or ">>" are also allowed.

which means you can also redirect output if needed.

Your Answer

