0

I'd like to know how to change stdin multiple times for the given binary for debugging purposes. I know I can launch the application with

r2 -r profile.r2 -d binary

Where, inside the profile.r2 file I have

program=binary
stdin=./path/to/some/file

But I'd like to know how, if at all possible, to switch stdin so that I can supply multiple different inputs during a single debugging session

Will I have to use r2pipe and its interface or is there a simpler way of achieving this in radare2? If not possible in radare2, how would I go about doing this with gdb?

Thanks for any help on this.

2 Answers 2

1

You can use the dd command or the :dd one if using r2frida to change any filedescriptor at runtime.

1
  • Thanks, but i was trying more to supply multiple program controlled inputs to the debugee. But thanks for the input, still dont know all the radare2 commands
    – Gordon Zar
    Jul 7 at 22:56
0

I figured it out. I can simply make a named pipe with mkfifo progin

and set

stdin=progin

in my radare profile file. Then i can feed my inputs to the binary one-by-one with cat file1 >> progin or echo 123 >> progin every time the binary attempts to read something from stdin.

Just note that, radare2 will appear to hang when starting if the pipe is empty, so we gotta feed the first input for radare2 to startup. The next call to read will block until more data is available in the pipe, allowing us to supply a different input all while debugging in a single session.

NOTE: The pipes are prone to breaking so recreating them might be necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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