1

I have a program running on terminal 1 and waiting for input from stdin. I programmed this program so it is vulnerable to buffer-overflow. I want to change it's flow to function2() within the program so I opened GDB in terminal 2, attached it to the program in terminal 1 using its PID and found out the address of function2().

Now I want to use printf in third terminal to create a certain output and redirect this output to the program in terminal 1. How do I do it?

PS: I'm new to this kind of exercise and do not know if there's a better way of doing this. Please let me know if there is.

  • The TIOCSTI ioctl can spam random terminals with input e.g. github.com/thrig/scripts/blob/master/tty/ttywrite.c – thrig Jul 28 '17 at 13:46
  • @thrig: I can spam a random terminal with input too. Simply echo anything and redirect it to /dev/pts/<terminal_number>. But the question is would it be redirected to the stdin of the program waiting on that terminal. In my case it doesn't. – 7_R3X Jul 28 '17 at 13:51
  • @7_R3X you miss the point that thrig is making. The referenced ttywrite.c program will put data into the terminal's input stream as if it had been typed on a keyboard. This is what you wanted, isn't it? – roaima Jul 28 '17 at 14:09
  • @roaima: Yup! That's exactly what I need. Thanks for confirming. – 7_R3X Jul 28 '17 at 14:39

Your Answer

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

Browse other questions tagged or ask your own question.