Out of malicious curiosity I opened 2 terminals, each running the bash shell. In the first I type :
$ echo $$
11458
and in the second :
$ echo -n "echo this command" >> /proc/11458/fd/0
Then this text echo this command
is indeed piped to the prompt on the first terminal. But on enter in that first terminal, that text is not executed as a command, I just get a new prompt.
In a second attempt, I executed this command in the first terminal:
$ read line;echo $line
and while the read is waiting for input, I again echo some text to /proc/11458/fd/0
in the second terminal. That text does appear on the first terminal, but on pressing <enter>
in the first terminal, the read
terminates, and the echo $line
shows that no input was read.
So I still didn't find a way to do harm; all I can do is modify the text on the first terminal, from the second terminal. Screen readers on that first terminal of course, do pick this up. By screen readers I am thinking of mouse selection, or terminal functions like Save Contents ...
; I tried both.
But if I knew how to also echo, for instance, an end-of-file or other control characters to the first terminal's stdin
, couldn't I mess up things terribly for processes in the first terminal?
/dev/pty#
, mine to/dev/pts/#
. – db-inf Nov 29 '21 at 09:25