6

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.

EDIT

here is a useful link I found talking about input payloads redirection : Managing inputs for payload injection?

Nark
  • 283
  • 1
  • 2
  • 9

2 Answers2

10

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

yehuda corsia
  • 216
  • 2
  • 3
  • 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 04 '19 at 11:24
7

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.