Re: man-in-the-middle translation of input
- From: Barry Margolin <barmar@xxxxxxxxxxxx>
- Date: Wed, 02 Aug 2006 20:21:47 -0400
In article <eapvt1$4fui8$1@xxxxxxxxxxxxxx>,
Daniel Franke <franke@xxxxxxxxxxxxxxx> wrote:
Hi there.
I would like to ease my life with an interactive console based program
(source not available). This program (a MUD like game, actually) takes a
couple of commands. For some of its puzzles, it's tiring to retype the same
command sequences over and over again. Therefore I decided to write a small
program that spawns the game, forwards its output to stdout, reads my input
at stdin, checks for keywords and either forwards the command as-is or
replaces my input by a series of valid game commands. To achieve this, I
tried a combination of pipe(), fork(), dup2(), execve(), select(), read()
and write() but failed. While I can easily permit the spawned child to
write to stdout, I couldn't find a way to read from stdin, preprocess the
input and feed it through a pipe to the child (invalid seek).
You need TWO pipes, one for the child's stdin, and the other for its
stdout/stderr. Your MITM program should read from its stdin, preprocess
this, and write to its end of the child's stdin pipe. It should also
read from its end of the child's stdout pipe and write this to its own
stdout.
Actually, you may not need the second pipe. If you don't need to modify
the child's output, you can simply let it inherit your stdout and write
to it directly.
Which program is reporting the invalid seek, the child or your MITM?
I'm not sure why the MUD would be trying to seek, since you can't seek
on a terminal device, which is presumably its normal stdin.
--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.
- Follow-Ups:
- Re: man-in-the-middle translation of input
- From: Daniel Franke
- Re: man-in-the-middle translation of input
- References:
- man-in-the-middle translation of input
- From: Daniel Franke
- man-in-the-middle translation of input
- Prev by Date: Re: setgid problem
- Next by Date: Re: problem with ftp command
- Previous by thread: Re: man-in-the-middle translation of input
- Next by thread: Re: man-in-the-middle translation of input
- Index(es):
Relevant Pages
|