[jcifs] Remote command Execution?

Michael B Allen mba2000 at ioplex.com
Fri Sep 3 00:27:42 GMT 2004


michael melhem said:
> Given the appropriate windows credentials, I need to be able to run an
> arbitrary remote command on a windows machine from a Linux machine. Does
> anyone have any idea how to do this?? Preferably from within Java Code?

Yeah, I think you could do that with Jarapac + atsvc.idl + idlc + jcifs.
Bascially you would have to write idl for the atsvc interface and compile
it with idlc. The jarapac/examples/samba/atsvc.idl would be a good start
but idlc needs MIDL compatible IDL so you'll have to rewrite it. Look at
the srvsvc.idl, lsarpc.idl, and samr.idl in jarapac/examples/idl. They're
a lot more complicated than atavc.idl so you should be able to figure out
how to MIDL-ize atavc from looking at those. Then create a TestAtsvc.java
like the other examples in Jarapac. Then get yourself a packet capture of
an AT job on the network. To run an AT job you do:

H:\>at 8:18pm /interactive notepad.exe
Added a new job with job ID = 1

Now just prefix \\computername. See at /? for help. There's probably some
special time to mean "now".

Then run your TestAtsvc program. It probably won't work the first time
around but compare the hexdump generated by your test program with the
body of the atsvc call in Ethereal.

It's a lot of work for a beginner but we're just getting started with rpcs
so I think this is the procedure until we actually create a nice API
around such things.

Mike


More information about the jcifs mailing list