0

I'm trying to use pwntools's process and to write a string to a specific fd

In the documentation, there is a parameter to process of stdin and stdout but I do not understand how to use it correctly. I tried using open("<named pipe">) since I saw in the documentation that a file object is a valid argument, but then remembered that it will not work since writing is blocked until someone starts reading.

1 Answer 1

1

Just so there’s no magic: you can only write data into a process’s STDIN; STDERR is always an output FD you can only read or redirect. If you want to feed your program on fd 2 (e.g. it actually does an os.read(2,…)), you must dup your stdin‐pipe onto fd 2 in the child before exec. Otherwise just use send/sendline to write to STDIN and stderr=PIPE (or a file) to capture its error‐output.

Sign up to request clarification or add additional context in comments.

1 Comment

How might I perform what you suggested? i.e, "dup your stdin-pipe onto another fd in the child before exec........"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.