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?

3
  • 1
    i ususally save the output to a file and execute "r < /file"
    – user22970
    Jun 18, 2018 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, 2018 at 22:01
  • See this answer.
    – perror
    Jul 3, 2019 at 12:33

2 Answers 2

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

1
  • 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, 2019 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.