[jcifs] Re: Remote command Execution?

michaelm michaelm at managesoft.com
Tue Sep 14 13:06:02 GMT 2004

On Fri, 2004-09-10 at 21:14, Michael B Allen wrote:
> On Fri, 10 Sep 2004 16:19:19 +0200
> "michael melhem" <michaelm at managesoft.com> wrote:
> > Hi Mike, et al.
> > 
> >  
> > 
> > Remote execution via atsvc + jarapac is working fine for me. However there
> > are two issues:
> > 
> >  
> > 
> > 1. There appears to be no way of running tasks immediately using atsvc.
> > the best I can do is work out the time of the remote windows machine and
> > calculate a invocation time + 2mins. I can get the time from the remote
> > windows machine using NET TIME. (Seems strange that relative or immediate
> > scheduling is not supported by the standard windows schedulers) 
> It's gotta be better than 2 minutes. If I look at the clock and run an
> at command in a cmd window for the next minute, the instant the clock
> changes the command runs.
> Add a method to SmbFile that returns
> tree.session.transport.server.serverTime. Compute the milliseconds
> since 12am (compute the 12am today in milliseconds and subtract from
> serverTime) and add 10 seconds. I bet it works. At some point you have
> to be concerned that network latency could cause your message to miss
> the time window so you'll want to be able to tune the delay.

Yep I think that might work. Im just worried about about network latency
but 10 sec should be enough.
> > 2. The other problem with this is that you cannot get the return code of
> > remote command. This we might just have to live with.
> That's the at command. Make a bat that echos the return code and redirects
> output to a file in temp and then flips the archive bit on or creates and
> '.end' file when the command completes. Then retrieve it to get the output.

I can store the return code on a samba File Share within a appropriately
named File. This will make its easer to retireve the return codes from
the remote machine. 

> > An aside:
> > 
> > I think its possible using RPC to remotely install and start an arbitrary
> > service on a remote windows machine (from a windows machine). Is it
> > possible to do something similar from Linux, using jarapac perhaps? This
> > could be another way to implement remote command execution by installing
> > the appropriate service.
> I think so. You could try to MIDLize the appropriate samba4 svcctl.idl
> functions:
> http://websvn.samba.org/cgi-bin/viewcvs.cgi/*checkout*/branches/SAMBA_4_0/source/librpc/idl/svcctl.idl?rev=1920
> There's probably a good way to do this. I recommand asking on the
> microsoft.public.* newsgroups how to remotely execute a command (don't
> mention anything about Java). Then write a little Win32 program to do it and
> take a packet capture. Look at what messages are used and see if there are
> MSRPCs involved.

Cool, thanks for the tips.

I think one can use 
the actual service binary can be made accessible on a samba share so
that it cab be loaded onto the remote machine ready to be run.

Thanks again.

> Mike

More information about the jcifs mailing list