1

I have a file that I want to use as the user input in a C program that ask for user input trough a scanf (playing and learning in linux)

lets call the program a.out and the file with the contents myImput, thereby:

  • in shell I can go: cat myInput | ./a.out
  • in gdb I could do: run < myInput once loaded with gdb a.out

is that possible in radare2 ? I see how to inject parameters, but not content files as user input

gokunef
  • 31
  • 3

1 Answers1

0

To type input to a program when you debug, follow these instructions:

  1. Create a file profile.r22
  2. Write the content of this file:
#!/usr/bin/rarun2
program=./a.out
input=aaabbbccc

where aaabbbccc is the content of the file that you want to read

  1. Tell to radare2 to use this file to send the previous input with the command: r2 -d ./a.out -e dbg.profile=profile.rr2
  2. type dc in radare2 to launch debugging

You can also do it faster in some commands:

{ echo -ne '#!/usr/bin/rarun2\nprogram=./a.out\ninput='; cat myInput; } > profile.rr2;
r2 -d ./a.out -e dbg.profile=profile.rr2

And then still launch the command dc.