Keeto
Keeto

Reputation: 4198

can bash be executed with stdin and stdout being a tcp socket

To give some context, I am trying to learn about pseudo-terminals (pty). A pseudo-terminal appears to a user process (bash for example) as if it was a real one. This allows to do all sorts of good stuff like telnet, ssh, etc.

My question is, for something like telnet, is it possible to just "exec" bash and set the stdin and stdout to be the tcp connection of the remote client machine. Because if that is possible, then I don't fully understand the value of using a pseudo-terminal

Upvotes: 0

Views: 355

Answers (1)

R.. GitHub STOP HELPING ICE
R.. GitHub STOP HELPING ICE

Reputation: 215193

Yes, it's possible - and in fact this is how lots of "shellcode" exploits against network services traditionally gave the attacker a shell - but you won't be able to control it interactively to the extent you normally would. This is because a socket is not a tty. It can't translate bytes sent over the line into signals for the attached process (things like ^C, ^Z, etc.), it can't send EOFs as data, it can't do job control (suspend on ^Z, suspend on input when in background, etc.), and it can't convey mode switches (canonical/"cooked" mode versus raw mode).

Upvotes: 1

Related Questions