@@ -9,8 +9,11 @@ module Exploit::Remote::DCERPC_SERVICES
9
9
10
10
NDR = Rex ::Encoder ::NDR
11
11
12
+ SC_MANAGER_ALL_ACCESS = 0xF003F
12
13
SERVICE_ALL_ACCESS = 0x0F01FF
13
14
ERROR_SUCCESS = 0x0
15
+ ERROR_FILE_NOT_FOUND = 0x2
16
+ ERROR_ACCESS_DENIED = 0x5
14
17
ERROR_SERVICE_EXISTS = 0x431
15
18
16
19
# Calls OpenSCManagerW() to obtain a handle to the service control manager.
@@ -19,9 +22,9 @@ module Exploit::Remote::DCERPC_SERVICES
19
22
# @param rhost [String] the target host.
20
23
# @param access [Fixnum] the access flags requested.
21
24
#
22
- # @return [String] the handle to the service control manager or nil if
23
- # the call is not successful.
24
- def dce_openscmanagerw ( dcerpc , rhost , access = SERVICE_ALL_ACCESS )
25
+ # @return [String, Integer ] the handle to the service control manager or nil if
26
+ # the call is not successful and the Windows error code
27
+ def dce_openscmanagerw ( dcerpc , rhost , access = SC_MANAGER_ALL_ACCESS )
25
28
scm_handle = nil
26
29
scm_status = nil
27
30
stubdata =
@@ -40,7 +43,7 @@ def dce_openscmanagerw(dcerpc, rhost, access = SERVICE_ALL_ACCESS)
40
43
print_error ( "#{ peer } - Error getting scm handle: #{ e } " )
41
44
end
42
45
43
- scm_handle
46
+ return scm_handle , scm_status
44
47
end
45
48
46
49
@@ -103,7 +106,7 @@ def dce_createservicew(dcerpc, scm_handle, service_name, display_name, binary_pa
103
106
begin
104
107
response = dcerpc . call ( 0x0c , stubdata )
105
108
if response
106
- svc_status = response [ 20 , 4 ] . unpack ( 'V' ) . first
109
+ svc_status = response [ 24 , 4 ] . unpack ( 'V' ) . first
107
110
108
111
if svc_status == ERROR_SUCCESS
109
112
svc_handle = response [ 4 , 20 ]
0 commit comments