使用 JCIFS 与远程 Windows 实例通信时出现 nca_proto_error/DERPC_FAULT_PROTO_ERROR

发布于 2024-12-25 04:55:46 字数 1287 浏览 4 评论 0原文

我目前正在尝试做一些类似于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

变身佩奇 2025-01-01 04:55:46

好的,

我解决了这个问题。问题是,请求类型未初始化,因此设置为 -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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文