Bind an existing process to a socket

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












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.







share|improve this question
















  • 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 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 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 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 at 13:37














up vote
1
down vote

favorite
1












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.







share|improve this question
















  • 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 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 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 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 at 13:37












up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





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.







share|improve this question












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.









share|improve this question











share|improve this question




share|improve this question










asked Apr 11 at 14:39









aDoN

2862515




2862515







  • 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 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 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 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 at 13:37












  • 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 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 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 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 at 13:37







1




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 at 14:45




“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 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 at 18:28





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 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 at 11:02




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 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 at 13:37




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 at 13:37















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f437035%2fbind-an-existing-process-to-a-socket%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f437035%2fbind-an-existing-process-to-a-socket%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay