Jump to content

remote console

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
Guest_h4x_*

Guest_h4x_*
  • Guests
i want to write remote console server

i conenct to it and get the shell. windows and unix.

easy approach is to redirect std in/out/err to socket file, but that sucks. I would like to have control signals, like ctrl+c. So if it hang, i would be able to reset without reconnecting.

Any ideas? And i want to be able to connect from this server to other, then other and make chain if needed. What approach should i take? ctrl+c and such events should be redirected, or not? or maybe a nest level? or bad idea.

im counting on your exp in this matter.


im using stnadard dlls on windows (or maybe i also do it on syscalls), and syscalls on linux.

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
Just set handlers for control codes (check out signal.h at the very least) and just send the control codes from there to the socket. For example:

/*initialize this in main() or something*/
int g_socket;

int ctrl_c_handler(int unused) {
    write(g_socket,"\003",1);
}

sudo rm -rf /

#3
Guest_h4x_*

Guest_h4x_*
  • Guests
ok, but if i run something from this console?
for example
conenct>consile>console>console>console>send ctrl+c.
wich one should process it?

if i forward it to the last, i risk deadlock in chain.
if i wont forward - only first will processm killing chain.

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
Deadlock avoidance/detection algorithms, perhaps? What kind of deadlock are you thinking?
sudo rm -rf /

#5
Guest_h4x_*

Guest_h4x_*
  • Guests
i told you.
i redirect stdin to child, and it will permanently loop to write.
its deadlock, i can do nothing but disconnect and wait untill connection timeout will terminate parent and its children.

i want to send ctrl+c to kill process if i no longer need it.
but i dont know how, i could write server and protocol for it, like 0x00 = command to forward, 0x01 = control, check and take action (like kill or switch to background).

i have no experience in doing that.

#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
0x03 is CTRL-C. I would definitely rethink how you're doing this, as you're correct, there is a potential for deadlock. Plus CTRL-C won't always kill a process, sometimes you need the kill signal (0x09 if I remember correctly).
sudo rm -rf /

#7
Guest_h4x_*

Guest_h4x_*
  • Guests
ok nvm.
do you know how signals are delivered?
do they go via stdin, or kernel send them to inner function?

fir example, ctrl+c.
can i just send it via stdin, or console windows recive message that key was pressed and call kill() function, wich tell kernel to send signal to process actually attached to console.

#8
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,720 posts
Probably the second; I don't know the inner workings of the Linux kernel very well.
sudo rm -rf /