I am writing an exploit for a binary on Linux using IDA Pro. This binary, first accepts an input using getchar() and after few more code sections, it accepts a buffer as an input through stdin and it uses the read() function to read the input. This buffer is then copied to another memory region using memcpy() which results in a crash.
Now, I want to automatically pass the input to program so that I don't have to pass these values in interactive mode.
Usually, I would do something like:
./linux_server binary < data
where data contains the input to be supplied to program. This takes care of the first getchar() function and it reads the input from data file. However, the next read() function, doesn't read anything from stdin because I think, the input was already processed by getchar() function.
How can I automatically pass multiple inputs to a program without interacting manually?