Nmap Development mailing list archives

Re: [Ncat] I'd like to contribute a feature


From: David Fifield <david () bamsoftware com>
Date: Sat, 4 Sep 2010 19:31:09 -0600

On Thu, Sep 02, 2010 at 03:43:44PM +0200, miniBill wrote:
2010/7/29 David Fifield <david () bamsoftware com>:
Thanks for your interest! Please help us understand what you have in
mind by showing some example command lines and explaining how they will
work. A use case, a real-world problem that this will solve, is good
too.

You will want to refer to this documentation for getting the source
code.

http://nmap.org/book/install.html#inst-svn
http://nmap.org/book/inst-source.html

As for code organization, --sh-exec and --exec are handled in the files
ncat_posix.c and ncat_exec_win.c. Whatever changes you make should work
on both POSIX and Windows. With luck, you'll only have to use the netrun
and netexec function, which are already abstracted.

I've rapidly checked ncat_listen.c which is the file which, as far as
I could understand,
actually invokes the platform-specific calls. As it works now it
executes the command
every time someone connects. What I would like to do is to have one
single command
execution, which collects all the users' input, and whose output is
copied to every user.
As small as I can understand it, it won't be easy.

I don't think it will be that hard. You can see that in ncat_listen.c,
there is special code that handles stdin and stdout; stdin and stdout
are treated like a special kind of "client." You would start a
subprocess with netrun and then treat its file handles specially also. I
think, in essence, that you want to replace the Ncat server's stdin and
stdout with that of another process. You are right that --exec doesn't
work that way.

You might be able to implement this with a Perl script that runs your
subcommand, runs ncat --listen, and connects their filehandles with dup
or dup2.

You might try starting a server in --broker mode, and then connect to it
with a client using --exec. Then that client will receive anything sent
by any other connecting client, and it will send its output to all other
connected clients.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: