MrSynAckSter
MrSynAckSter

Reputation: 1770

How to run GDB with the results of a script?

Simple, maybe not so simple issue. How can I run GDB with the results of a script?

What I mean is that instead of saying:

run arg1 

You would say:

run "python generatingscript.py" 

which would output the args. I'm aware I could find a way to do this by sleeping the program after run the args from the command line, but it would be really darn convenient if there was a way to do this kind of thing directly in gdb.

Just for context, my use case is a situation where I writing crash test cases that look like long strings of hex data. Putting them in by hand at the command line isn't the most convenient thing.

Upvotes: 0

Views: 3813

Answers (3)

Mou
Mou

Reputation: 165

This works for my ubuntu machine which deploys "<<<" instead of "<".

(gdb) r <<< $(python exploit.py )

Upvotes: 0

Larry E
Larry E

Reputation: 179

You could also use bash to generate an output file

$python generatingscript.py > testinput

then in gdb

gdb$ run < testinput

Upvotes: 0

blatinox
blatinox

Reputation: 843

You can use gdb with the --args option like this: gdb --args your_program $(python generatingscript.py.

Upvotes: 1

Related Questions