I want to bind an existing process to a socket listenning on a specific port with nc and send input to it (a python interactive shell, an editor...) whatever process, just send a pid and bind it, since file descriptors are meaningless for another process rather than the existing process and can't use /proc/<pid>/fd/0 to send input to process (the fds are just symlinks to a terminal).

The last statement is too conclusive to be true since strace -p<pid> -s9999 -e write can spy STDIN and STDOUT (don't know how)of a process but that's something I will investigate later, from now I want to bind an existing process to a socket and send data to it via a socket.

  • 1
    “The last statement is too conclusive to be true” — nice... Why repeat a statement if you don’t believe it then? – Stephen Kitt Apr 11 '18 at 14:45
  • Pointer: combine two things: 1/ pass around fd descriptors through unix sockets 2/ use a tool like gdb to execute the missing code from your running processes to just implement 1/ . random links: 1/ stackoverflow.com/questions/28003921/… 2/ unix.stackexchange.com/questions/208617/… . I'm quite sure SO or reverseengineering SE have other examples for both – A.B Apr 11 '18 at 18:28
  • let's say nano is pid 18541 and I want to send its input over a socket. I have a listening nc on port 5555 and type /proc/18541/fd/0 > /dev/tcp/localhost/5555 I got bash: /proc/18541/fd/0: Permission denied even though I'm root – aDoN Apr 12 '18 at 11:02
  • I have been able to send data to another process with gdb -p <pid> with call write(0,"test",4) but I want to bind the process to a port and send data through it (it doesn't matter if I get the stdout or the process in question does, those are details I don't want to delve into right now, just the input is what interests me) – aDoN Apr 12 '18 at 13:37

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.