使用 JCIFS 与远程 Windows 实例通信时出现 nca_proto_error/DERPC_FAULT_PROTO_ERROR
我目前正在尝试做一些类似于 PSExec 但完全用 Java 的事情。 我认为我的问题与我实际正在做的事情并不直接相关,而是与如何做有关。 目前我正在尝试远程实现服务的创建和启动。
为此,我使用了 midlc 工具(版本 0.6.1),并通过 CreateService 和 DeleteService 调用扩展了 svcctl.idl。之后,我使用 midlc 生成与 jcifs ( -t jcifs ) 一起使用的代码。然后,我创建了一个测试程序来使用该类和 jcifs 与远程 Windows 计算机进行通信。
这是代码:
rpc.policy_handle scHandle = new rpc.policy_handle();
SvcCtl.OpenSCManager openSCManagerRpc = new SvcCtl.OpenSCManager(host, null, 0x0001 | 0x0002, scHandle);
// Connection-oriented DCE/RPC over SMB named pipes.
DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + host + "[\\PIPE\\svcctl]",
ConcurrentNtlmAuthenticator.getInstance().getNtlmPasswordAuthentication());
try {
handle.sendrecv(openSCManagerRpc);
if (openSCManagerRpc.retval != 0) {
throw new SmbException(openSCManagerRpc.retval, true);
}
} catch(Exception e) {
e.printStackTrace();
} finally {
try {
handle.close();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
不幸的是,我收到 DCERPC_FAULT_PROTO_ERROR 别名 nca_proto_error 别名 0x1c01000b
所以我的简单问题是......我做错了什么?
克里斯
I am currently trying to do something similar to PSExec but entirely in Java.
I think my problem isnt directly relate to actually what I am doing, but how.
Currently I am trying to implement the creating and starting of a service remotely.
For this I got my hands on the midlc tool (version 0.6.1) and extended the svcctl.idl with the CreateService and DeleteService calls. After that I used midlc to generate code for usage with jcifs ( -t jcifs ). I then created a test-program to use that class and jcifs to communicate with a remote windows machine.
Here comes the code for that:
rpc.policy_handle scHandle = new rpc.policy_handle();
SvcCtl.OpenSCManager openSCManagerRpc = new SvcCtl.OpenSCManager(host, null, 0x0001 | 0x0002, scHandle);
// Connection-oriented DCE/RPC over SMB named pipes.
DcerpcHandle handle = DcerpcHandle.getHandle("ncacn_np:" + host + "[\\PIPE\\svcctl]",
ConcurrentNtlmAuthenticator.getInstance().getNtlmPasswordAuthentication());
try {
handle.sendrecv(openSCManagerRpc);
if (openSCManagerRpc.retval != 0) {
throw new SmbException(openSCManagerRpc.retval, true);
}
} catch(Exception e) {
e.printStackTrace();
} finally {
try {
handle.close();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
Unfortunately I am getting a DCERPC_FAULT_PROTO_ERROR alias nca_proto_error alias 0x1c01000b
So my simple question is ... what am I doing wrong?
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,
我解决了这个问题。问题是,请求类型未初始化,因此设置为 -1,这不是有效值。通过手动设置,我能够实际执行我尝试执行的任务:
https://dev.c-ware.de/confluence/pages/viewpage.action?pageId=15007754
克里斯
Ok,
I sorted this out. The problem was, that the request type was not initialized and hereby set to -1 which is not a valid value. By manually setting this, I was able to actually perform the tasks I was trying to do:
https://dev.c-ware.de/confluence/pages/viewpage.action?pageId=15007754
Chris