The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
My first thought was that it might be an undesirable property (if only
for "security reasons", or more likely, generally).
What I can do is
* sending some data to another shell session, say,
ls > /dev/pts/22
* get the output of a command executed on another host, say,
ssh somehost ls
* send the output of a remote execution to another shell, say,
ssh somehost ls > /dev/pts/22
Note that the latter will not operate in the shell context of the shell >session that is running on somehost with /dev/pts/22.
I guess the answer to my question is simply "no", but I'd like to have
a confirmation (and possibly more specific rationales or remarks).
PS: On an old SunOS 4 SPARC system I was (without privileges) able to
even change the remote users system characteristics (like mouse speed),
but I suppose that must be considered a security issue on that platform.
In article <vquhba$3817f$1@dont-email.me>,[...]
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
PS: On an old SunOS 4 SPARC system I was (without privileges) able to
even change the remote users system characteristics (like mouse speed),
but I suppose that must be considered a security issue on that platform.
I no longer recall how such things were controlled on SunOS 4,
but I imagine that you opened a device file and issued an ioctl
to control things like that. What this suggests to me is that
you were able to connect to some remote machine where the device
files in question were permitted so that you could open them and
issue those controls. Had they had more restrictive permissions
(say 0600 and owned by the logged-in user) then I suspect you
would not have been able to do that. But there were bugs in
SunOS 4, which came from a simpler time, so perhaps I'm wrong.
I do recall once crashing my boss's workstation by accident: his
name was Dave, and we found some audio clips in Sun audio format
of HAL from the movie "2001" saying, "I'm sorry, Dave, I can't
let you do that..." or "why don't you sit back, relax, and take
a stress pill..." and were having fun rsh'ing into his machine
and `cat`'ing them into `/dev/audio` there (so they played on
the builtin speaker, which of course was in his office. Note
that we could only do this because we had write access to the
audio device; we also had root access, so he couldn't depermit
it).
Anyway, we would do that, and get a file playing, and he'd kill
the process writing to the audio device, and the speech would
stop. So we kept escalating by trying newer, more creative ways
to buffer the audio data in the kernel before we he could kill
off the writing process. It seems we took this a little too far
though, as I tripped a bug in the audio driver (I think a NULL
op in the cdevsw used by some system call we were using that
wasn't implemented by the driver; the details are fuzzy now) and
it crashed his machine. I didn't realize this had happened, but
we all also ran little programs that `tail -f`'d the more
important log files consolidating important events from around
our network. So I saw his workstation rebooting and thought I'd
been so clever that the only way he could stop HAL was by
rebooting. Then I saw him log into my machine, which suddenly
rebooted. "Hey! What'd you do that for?!" I shouted across the
hall. "You did it to me!" he responded.
Of course, this was all in good fun, but we stopped trying to
prank each other with random audio files after that.
In article <vquhba$3817f$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
I don't think I understand what you mean. Do you mean that you
would be able to hijack a user's TTY in order to run commands on
some other system (e.g., via `ssh` or something) as them?
My first thought was that it might be an undesirable property (if only
for "security reasons", or more likely, generally).
Yeah, that seems bad.
What I can do is
[...]
Note that the latter will not operate in the shell context of the shell
session that is running on somehost with /dev/pts/22.
This is the part where I'm not sure what you mean. You are
executing a command on "somehost"; in this case, `ls`.
But you
are redirecting output to the _local_ `/dev/pts/22` (again,
assuming you have write permissions to that device). That is,
the `ssh` command is running on the same system where you are
writing to `/dev/pts/22`, and the `ssh` client command has its
standard output connected to that pty device; whatever runs on
"somehost" as a result of you running `ssh` is happening on that
system, as invoked by the SSH server, that has no knowledge of,
or interest in, how the client is configured with respect to its
IO configuration, let alone local ptys: that is, the distant
end, assuming that "somehost" is a distinct system other than
the one you're doing all of this on, has no access to the state
of the local pty devices on the source end. Indeed, given
the way that you've run this, `ls` on "somehost" is likely not
assocaited with any terminal device at all.
If instead you had run:
ssh somehost 'ls > /dev/pts/22'
Then you would be writing to `/dev/pts/22` on the distant end,
not locally.
I guess the answer to my question is simply "no", but I'd like to have
a confirmation (and possibly more specific rationales or remarks).
I'm still not sure what you're asking.
[ SunOS stuff answered in previous post ]
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
On 13.03.2025 14:01, Dan Cross wrote:
In article <vquhba$3817f$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
I don't think I understand what you mean. Do you mean that you
would be able to hijack a user's TTY in order to run commands on
some other system (e.g., via `ssh` or something) as them?
Actually that question arose after a necessary reboot of my system,
which had shown a strange effect[*] and was unusable. - I wanted to
obtain from my shell sessions some information, and since I happen
to have dozens of shell windows open in parallel - and I considered
it boring to go through all virtual windows with all it's individual
shell windows - I thought about starting that request on each window
uniquely from one shell window. That's how it started why I pondered
about the question and tried a couple things.
So, no; no hijack intended, no other users concerned. (I'm the only
user on my system, or so I hope.) It was at that point actually an
academical question.
My first thought was that it might be an undesirable property (if only
for "security reasons", or more likely, generally).
Yeah, that seems bad.
What I can do is
[...]
Note that the latter will not operate in the shell context of the shell
session that is running on somehost with /dev/pts/22.
This is the part where I'm not sure what you mean. You are
executing a command on "somehost"; in this case, `ls`.
I used the "somehost" just as describing the general case for using
these remote tools. In my case I actually used 127.0.0.1 (localhost)
for the test case I was interested in.
[snip]
I used 'ls' just as an example to show that the remotely executed
program needs shell context information from that remote terminal
since each shell window will reside in an own working directory.
(Note: In my environment I actually can get that $PWD information
after a reboot because I have set it up to memorize that for each
shell window. But a shell session has yet more context, and, as
said, it was a principle academic question at that point whether
it was doable in the first place or prohibited or impossible by
other principle factors.)
If instead you had run:
ssh somehost 'ls > /dev/pts/22'
Then you would be writing to `/dev/pts/22` on the distant end,
not locally.
I guess the answer to my question is simply "no", but I'd like to have
a confirmation (and possibly more specific rationales or remarks).
I'm still not sure what you're asking.
I hope it got clearer from the additional information.
[ SunOS stuff answered in previous post ]
[*] Something I never noticed before, BTW. - My CPU% was at "0%",
not even the typical high basis load of Firefox was displayed. The
whole window manager stuff (mouse movement, menu item selection,
change of virtual sessions, switch to plain non-WM consoles, some
tools in the task-bar like the clock was still counting, etc.) was
working, though, but not a single (other) command got executed;
not even a new cursor shown when hitting <Enter> in a shell window.
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
My first thought was that it might be an undesirable property (if only
for "security reasons", or more likely, generally).
What I can do is
* sending some data to another shell session, say,
ls > /dev/pts/22
* get the output of a command executed on another host, say,
ssh somehost ls
* send the output of a remote execution to another shell, say,
ssh somehost ls > /dev/pts/22
Note that the latter will not operate in the shell context of the shell session that is running on somehost with /dev/pts/22.
I guess the answer to my question is simply "no", but I'd like to have
a confirmation (and possibly more specific rationales or remarks).
Janis
PS: On an old SunOS 4 SPARC system I was (without privileges) able to
even change the remote users system characteristics (like mouse speed),
but I suppose that must be considered a security issue on that platform.
On some systems, opening a tty and calling ioctl(fd, TIOCSTI, ptr),
where ptr is a char*, will cause the single character *p to appear
as if it had been typed.
In article <vqv1c0$3gq75$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
[...]
I think I understand; let me paraphrase, and tell me if I'm
correct?
[...paraphrase snipped...]
If that's correct, then the answer, generally is no: you can't
do that. If you open the pty device associated with that shell,
you're and write to it, you're really writing to the same
output that the shell process is connected to, not it's input.
There's no simple way to interpose onto the input stream.
[...]
[*] Something I never noticed before, BTW. - My CPU% was at "0%",
not even the typical high basis load of Firefox was displayed. The
whole window manager stuff (mouse movement, menu item selection,
change of virtual sessions, switch to plain non-WM consoles, some
tools in the task-bar like the clock was still counting, etc.) was
working, though, but not a single (other) command got executed;
not even a new cursor shown when hitting <Enter> in a shell window.
Are you sure the issue wasn't with your keyboard? I'd have
maybe tried to disconnect and reconnect it.
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
My first thought was that it might be an undesirable property (if only
for "security reasons", or more likely, generally).
What I can do is
[...]
I guess the answer to my question is simply "no", but I'd like to have
a confirmation (and possibly more specific rationales or remarks).
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
My first thought was that it might be an undesirable property (if only
for "security reasons", or more likely, generally).
What I can do is
* sending some data to another shell session, say,
ls > /dev/pts/22
* get the output of a command executed on another host, say,
ssh somehost ls
* send the output of a remote execution to another shell, say,
ssh somehost ls > /dev/pts/22
Note that the latter will not operate in the shell context of the shell
session that is running on somehost with /dev/pts/22.
I guess the answer to my question is simply "no", but I'd like to have
a confirmation (and possibly more specific rationales or remarks).
Janis
PS: On an old SunOS 4 SPARC system I was (without privileges) able to
even change the remote users system characteristics (like mouse speed),
but I suppose that must be considered a security issue on that platform.
Writing to a tty is easy, if you have the right permissions.
Pushing text input into a tty so it behaves as if it had been typed
is trickier, and not necessarily possible
On some systems, opening a tty and calling ioctl(fd, TIOCSTI, ptr),
where ptr is a char*, will cause the single character *p to appear
as if it had been typed. This might not work for a tty other than
the current stdin, and it's started requiring root access in recent
Ubuntu releases.
At a previous job several decades ago, we had a command `typein`
that used this mechanism. In most cases, I've found `eval` to be
a cleaner way to do what I was using `typein` for.
Emacs uses this mechanism for the `suspend-emacs` function:
(suspend-emacs &optional STUFFSTRING)
...
If optional arg STUFFSTRING is non-nil, its characters are stuffed
to be read as terminal input by EmacsrCOs parent, after suspension.
...
On some operating systems, stuffing characters into terminal input
buffer requires special privileges or is not supported at all. On
such systems, calling this function with non-nil STUFFSTRING might
either signal an error or silently fail to stuff the characters.
You can do this with tmux, which allocated and controls a pty for each >window. For example:
echo echo hello world | tmux load-buffer -
tmux paste-buffer -t 1
This causes the pane named "1" to act as if you had typed "echo
hello world" into it. You can use a named buffer ("-b TEMP") if
you don't want to step on the default one, and delete the buffer if
you don't want to keep the text (I sometimes use this for passwords).
Of course if the target pane doesn't happen to be sitting at a shell
prompt, odd things can happen.
I don't know whether GNU screen has a similar feature.
On some systems, opening a tty and calling ioctl(fd, TIOCSTI, ptr),
where ptr is a char*, will cause the single character *p to appear
as if it had been typed.
This might not work for a tty other than
the current stdin, and it's started requiring root access in recent
Ubuntu releases.
On 2025-03-13, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
On some systems, opening a tty and calling ioctl(fd, TIOCSTI, ptr),
where ptr is a char*, will cause the single character *p to appear
as if it had been typed.
I associate TIOCSTI with csh(1)'s filename expansion feature, but
I associate TIOCSTI with csh(1)'s filename expansion feature, but
Seriously? Is this what I think it is: that csh tromboned out characters
to the TTY driver to get the OS to type in the expansion as if the user
typed it?
Wow, ... I see considering only csh *programming* to be harmful was
an overly optimistic view.
In article <vqv1c0$3gq75$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
On 13.03.2025 14:01, Dan Cross wrote:
In article <vquhba$3817f$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
The question occurred to me whether it would be possible to remotely
execute a command as if started from another shell session *in* that
shell session.
I don't think I understand what you mean. Do you mean that you
would be able to hijack a user's TTY in order to run commands on
some other system (e.g., via `ssh` or something) as them?
Actually that question arose after a necessary reboot of my system,
which had shown a strange effect[*] and was unusable. - I wanted to
obtain from my shell sessions some information, and since I happen
to have dozens of shell windows open in parallel - and I considered
it boring to go through all virtual windows with all it's individual
shell windows - I thought about starting that request on each window >>uniquely from one shell window. That's how it started why I pondered
about the question and tried a couple things.
So, no; no hijack intended, no other users concerned. (I'm the only
user on my system, or so I hope.) It was at that point actually an >>academical question.
I think I understand; let me paraphrase, and tell me if I'm
correct?
I think you're asking if you can write to a terminal device, and
have what you write be treated as input data for whatever
program is running on that tty/pty; is that right? And then, if
that is possible, whether you can do this over the network?
So that, for example, if you have a terminal emulator with a
window that is running some shell process, controlled by some
pty device, you could execute a command on that computer over
the network that would get the shell running in that window
run some command?
If that's correct, then the answer, generally is no: you can't
do that. If you open the pty device associated with that shell,
you're and write to it, you're really writing to the same
output that the shell process is connected to, not it's input.
There's no simple way to interpose onto the input stream.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 59 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 18:04:03 |
| Calls: | 810 |
| Calls today: | 1 |
| Files: | 1,287 |
| D/L today: |
10 files (21,017K bytes) |
| Messages: | 193,396 |