Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when password parameter is entered in serviceChangeConfig method #180

Open
emrahozel opened this issue Mar 10, 2024 · 0 comments
Open

Comments

@emrahozel
Copy link

emrahozel commented Mar 10, 2024

Describe the bug
When I use the changeServiceConfig method in the ServiceControlManagerService class, I get an error when I enter the serviceStartName and password parameters. It works when I leave the password parameter blank.

Code

    public static void changeService(){
        SmbConfig cfg = SmbConfig.builder().build();
        SMBClient client = new SMBClient(cfg);

        // SMB bağlantısını açın
        try (Connection smbConnection = client.connect("192.168.1.200")) {
            AuthenticationContext smbAuthenticationContext = new AuthenticationContext(username, password.toCharArray(), domain);
            Session session = smbConnection.authenticate(smbAuthenticationContext);

            RPCTransport transport = SMBTransportFactories.SVCCTL.getTransport(session);
            ServiceControlManagerService scm = new ServiceControlManagerService(transport);
            String displayName = "Test-Display";
            ServiceType serviceType = ServiceType.WIN32_OWN_PROCESS;
            ServiceStartType serviceStartType = ServiceStartType.DEMAND_START;
            ServiceError serviceError = ServiceError.IGNORE;
            String binaryPathName = "echo";
            String serviceStartName = "contoso.local\\domadmin";
            String password = "Pass123qq!!";
            IServiceConfigInfo info = new ServiceConfigInfo(serviceType,serviceStartType, serviceError, binaryPathName, null, 0, null, serviceStartName, displayName, password);

            ServiceHandle serviceHandle = scm.openServiceHandle(scm.openServiceManagerHandle(), "Test-Service");
            scm.changeServiceConfig(serviceHandle, info);
        }catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

Exception
Exception in thread "main" java.lang.RuntimeException: com.rapid7.client.dcerpc.RPCException: RChangeServiceConfigW returned error code: 0x00000057 (ERROR_INVALID_PARAMETER)
at com.rpc.Main.changeService(Main.java:257)
at com.rpc.Main.main(Main.java:51)
Caused by: com.rapid7.client.dcerpc.RPCException: RChangeServiceConfigW returned error code: 0x00000057 (ERROR_INVALID_PARAMETER)
at com.rapid7.client.dcerpc.service.Service.callExpect(Service.java:65)
at com.rapid7.client.dcerpc.service.Service.callExpectSuccess(Service.java:51)
at com.rapid7.client.dcerpc.msvcctl.ServiceControlManagerService.changeServiceConfig(ServiceControlManagerService.java:127)
at com.rpc.Main.changeService(Main.java:255)

**Environment

  • Operating System: Windows Server 2019
  • Java Version: 17
  • Library Version: 0.12.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant